Skip to content

Incorrect quota and tree size calculation after large POSIXFS import and move operations #3109

Open
opencloud-eu/reva
#853

Description

@overlinden

Environment

  • OpenCloud Version: 7.2
  • Deployment: Docker
  • Storage backend: POSIXFS
  • Linux: Debian
  • STORAGE_USERS_POSIX_WATCH_FS=true

Summary

After importing a large dataset into a POSIX-backed Space and performing large move operations via the Web UI, the reported folder sizes and space quota became incorrect.

The filesystem contents are correct and all files are accessible, but OpenCloud reports significantly smaller sizes than actually exist on disk.

Dataset

  • ~199,886 user files
  • ~609 GB of user data
  • ~211,294 metadata files inside .oc-nodes

Steps performed

  1. Created a POSIX-backed Space.
  2. Enabled:
STORAGE_USERS_POSIX_WATCH_FS=true
  1. Imported approximately 200,000 files (~609 GB) directly into the POSIX filesystem.
  2. Waited until OpenCloud detected the files.
  3. Performed large move operations using the OpenCloud Web UI.
  4. During the move operation the following errors appeared repeatedly:
could not get spaceID and nodeID from cache
error="context canceled"

error in jetstream kv operation, retrying
error="context canceled"
  1. Restarted OpenCloud.

The cache-related errors disappeared after the restart, but the incorrect folder sizes and quota remained.

Expected behavior

The reported Space size, folder sizes and quota should match the actual filesystem usage.

Actual behavior

Filesystem:

  • User data: 609 GB
  • User files: 199,886

OpenCloud:

  • Space size: 148 GB
  • Quota used: 148 GB

Both values are incorrect.

Example

Filesystem:

Einsortieren/
170 GB

OpenCloud:

Einsortieren/
38 GB

Another folder:

Filesystem:

2025/
49 GB

OpenCloud:

51 GB

So some folders report correct sizes while others are significantly underestimated.

Additional observations

The filesystem appears completely consistent.

find . -type f | wc -l
199886

OpenCloud metadata:

find .oc-nodes -type f | wc -l
211294

Metadata directory sizes:

.oc-nodes   170 MB
.space      66 KB
.Trash      45 KB
.oc-tmp     512 B

No hardlinks exist:

find . -type f -links +1

returns no output.

Quota behavior

The quota is not correct initially, but is updated incrementally.

Example:

Initial state:

  • Actual filesystem usage: 609 GB
  • Reported quota: 148 GB

After uploading a new 600 MB file:

  • Reported quota immediately increased to 148.6 GB

The uploaded file is added correctly, but the missing ~461 GB are still not reflected.

The reported Space size did not change after the upload.

What has been verified

  • All files are accessible.
  • Random files can be opened successfully.
  • No missing folders found during manual verification.
  • No duplicate user files exist.
  • Filesystem usage is correct.
  • Metadata directories are small.
  • The issue only affects the reported quota and tree size.

Additional information

While searching the documentation I found the following note in the POSIXFS documentation:

"Editing or deleting large numbers of files may cause errors in tree size calculation."

https://docs.opencloud.eu/docs/next/admin/configuration/storage/storage-posix/

This seems related to the behavior I am observing.

Although my scenario is slightly different (large initial import followed by large move operations in the Web UI), the result appears similar:

  • incorrect tree size
  • incorrect quota
  • inconsistent folder sizes
  • existing data remains accessible
  • newly uploaded files increment the reported quota, but the initial values remain incorrect

I am therefore wondering whether the internal tree size / quota metadata may have become inconsistent during the import or move operations.

If this is expected behavior after very large operations, is there currently a supported way to rebuild or recalculate the tree size and quota metadata for an existing POSIXFS Space?

Question

Is there a supported way to rebuild or recalculate the POSIXFS tree size / quota metadata after very large imports or move operations?

Or could this be a bug in the POSIXFS tree size calculation?

Activity

  1. overlinden commented on Jul 14, 2026

    @overlinden
    Author

    After some systematic testing, I found additional information that may help identify the root cause.

    Test setup

    I created a small directory tree:

    Andre/
    ├── file1... (about 6.9 MB total)
    └── subfolder/
        ├── file2 (10 MB)
        └── sub2/
            └── file3 (15 MB)
    

    All files were fully assimilated by OpenCloud:

    • user.oc.id exists
    • user.oc.parentid is correct
    • user.oc.blobsize is correct
    • checksums are present
    • metadata extraction completed successfully

    The files are visible in the Web UI and their individual file sizes are displayed correctly.

    Initial observation

    Several directories had

    user.oc.treesize=0
    

    or no user.oc.treesize attribute at all, although they contain files.

    Experiment 1

    I removed only the user.oc.treesize xattr from a directory containing files.

    Creating a new file inside that same directory caused OpenCloud to recreate user.oc.treesize, and the value was calculated correctly.

    This indicates that OpenCloud is capable of rebuilding a missing treesize, but only for the directory where the write operation occurs.

    Experiment 2

    I removed user.oc.treesize from both a parent directory and its child directory.

    Then I created a file in the parent directory.

    Result:

    • parent treesize was recreated
    • child treesize was still missing

    Deleting the newly created file caused the child directory to receive a treesize attribute, but this behaviour became inconsistent with deeper directory structures.

    Experiment 3 (three-level hierarchy)

    I removed user.oc.treesize from:

    • parent
    • child
    • grandchild

    Then I created a file in the parent.

    Result:

    • parent received a treesize
    • child had treesize=0
    • grandchild still had no treesize

    Next I created a small file directly inside the grandchild.

    Result:

    grandchild treesize = correct (~15 MB + new file)
    child treesize = 7
    parent treesize = previous value + 7
    

    The parent directories only propagated the delta of the new file instead of recalculating their aggregated tree size.

    Conclusion

    The behaviour appears to be:

    • If a directory has no user.oc.treesize, a write operation inside that directory rebuilds its own tree size correctly.
    • Parent directories are not rebuilt recursively.
    • Instead, parents only receive the size delta of the triggering operation.

    This leaves the metadata inconsistent if descendant directories have missing or invalid treesize values.

    This behaviour would explain why:

    • all files are assimilated correctly,
    • blobsize values are correct,
    • files are accessible,
    • but directory sizes and user quota become much smaller than the actual filesystem usage after importing data via POSIXFS.

    It seems that there is currently no recursive "rebuild tree size" operation, and once incorrect treesize values exist, normal delta propagation cannot recover from them.

    This behaviour was reproduced multiple times with different directory structures and consistently produced the same results.

  2. overlinden commented on Jul 14, 2026

    @overlinden
    Author

    After some additional investigation, I found a workaround that successfully repaired the incorrect directory sizes and quota calculation in my environment.

    The issue appears to be caused by incorrect or missing user.oc.treesize xattrs after importing data directly into the POSIXFS backend (in my case via rsync while using the POSIXFS collaborative mode). Files themselves were assimilated correctly (user.oc.id, user.oc.parentid, user.oc.blobsize, checksums, metadata, etc.), but many directory user.oc.treesize values were missing or incorrect.

    I wrote a small Python script that traverses the directory tree bottom-up, calculates the recursive sum of all regular file sizes for each directory, and updates the user.oc.treesize xattr accordingly.

    After stopping OpenCloud, running the script, and starting OpenCloud again, the issue was resolved in my environment:

    • directory sizes were reported correctly again,
    • the user quota matched the actual amount of stored data,
    • existing files remained fully accessible,
    • creating, modifying and deleting files continued to work as expected,
    • newly uploaded files were assigned correct user.oc.treesize values.

    I have not observed any negative side effects so far. Nevertheless, I strongly recommend creating a backup of your xattrs or your storage before using the script, as it directly modifies filesystem metadata.

    The script is attached to this comment in case it helps others who encounter the same issue. Please use it with caution and make sure to create a backup before modifying xattrs on a production system.

    I still believe this should be fixed within OpenCloud itself, as a repair tool should not be necessary. However, until an official solution exists, this script may serve as a useful workaround.

    opencloud_treesize_fix.py

  3. erikboberg commented on Jul 29, 2026

    @erikboberg

    One of my folders had all subfolders registered as 0B in size after moving a lot of files into opencloud (migrating from seafile). I tried your script and it seems to have worked fine! Many thanks! I hope that this gets better implemented into the core opencloud application soon.

  4. lucianomunoz commented on Aug 11, 2026

    @lucianomunoz

    Does it fix the missing data in open cloud,
    i have data i see from the filesystem that OC was supposed to autodetect but never did.. Also to me the discrepacy is quite big, OC repords having 350gb while the data folder itself is about 4tb.
    Thanks

  5. micbar commented on Aug 14, 2026

    @micbar
    Member

    i have data i see from the filesystem that OC was supposed to autodetect but never did..

    Autodetect is not enabled by default. See. https://docs.opencloud.eu/docs/next/admin/configuration/storage/storage-posix#posixfs-non-collaborative-mode

  6. moved this from Qualification to Prio <= 3 in OpenCloud Team Boardon Aug 14, 2026
  7. micbar commented on Aug 14, 2026

    @micbar
    Member

    @tbsbdr @aduffeck @rhafer setting p3.

    It could be p2-ish

  8. NickWalters commented on Oct 6, 2026

    @NickWalters
    Contributor

    Two open reva PRs address this:

    About rebuilding the sizes: on 7.2.1 and later, a restart does it. The startup scan walks the whole storage and writes the tree sizes from disk, as long as STORAGE_USERS_POSIX_SCAN_FS is on, which is the default. On 7.2.0 (reva v2.46.6) that scan skipped the storage root, which is probably why the restart here didn't help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions