Skip to content

Commit

Permalink
Use extra math to pass test and allow avail and free to be different
Browse files Browse the repository at this point in the history
  • Loading branch information
foodprocessor committed Nov 5, 2024
1 parent 951fd02 commit 46a3614
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions component/libfuse/libfuse2_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,19 @@ func (cf *CgofuseFS) Statfs(path string, stat *fuse.Statfs_t) int {
// cloud storage always sets free and avail to zero
statsFromCloudStorage := attr.Bfree == 0 && attr.Bavail == 0
// calculate blocks used from attr
usedBlocks := attr.Blocks - attr.Bfree
blocksUnavailable := attr.Blocks - attr.Bavail
blocksUsed := attr.Blocks - attr.Bfree
// we only use displayCapacity to complement used size from cloud storage
if statsFromCloudStorage {
displayCapacityBlocks := fuseFS.displayCapacityMb * common.MbToBytes / uint64(attr.Bsize)
// if used > displayCapacity, then report used and show that we are out of space
stat.Blocks = max(displayCapacityBlocks, usedBlocks)
stat.Blocks = max(displayCapacityBlocks, blocksUnavailable)
} else {
stat.Blocks = attr.Blocks
}
// adjust avail and free to make sure we display used space correctly
stat.Bavail = stat.Blocks - usedBlocks
stat.Bfree = stat.Blocks - usedBlocks
stat.Bavail = stat.Blocks - blocksUnavailable
stat.Bfree = stat.Blocks - blocksUsed
stat.Files = attr.Files
stat.Ffree = attr.Ffree
stat.Namemax = attr.Namemax
Expand Down

0 comments on commit 46a3614

Please sign in to comment.