SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
add template for fs.FSStatfser
Chris Lu2e32b44061e1
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.goindex 5d27bd6cd7..ff482edb52 100644--- a/weed/filesys/wfs.go+++ b/weed/filesys/wfs.go@@ -1,7 +1,9 @@package filesysimport (+ "context""fmt"+ "math""sync""time"@@ -26,6 +28,9 @@ type Option struct {EntryCacheTtl time.Duration}+var _ = fs.FS(&WFS{})+var _ = fs.FSStatfser(&WFS{})+type WFS struct {option *OptionlistDirectoryEntriesCache *ccache.Cache@@ -128,3 +133,34 @@ func (wfs *WFS) ReleaseHandle(fullpath string, handleId fuse.HandleID) {return}++// Statfs is called to obtain file system metadata. Implements fuse.FSStatfser+func (wfs *WFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {++ glog.V(4).Infof("reading fs stats: %+v", req)++ totalDiskSize := uint64(0)+ usedDiskSize := uint64(0)+ actualFileCount := uint64(0)++ // Compute the total number of available blocks+ resp.Blocks = totalDiskSize / blockSize++ // Compute the number of used blocks+ numblocks := uint64(usedDiskSize / blockSize)++ // Report the number of free and available blocks for the block size+ resp.Bfree = resp.Blocks - numblocks+ resp.Bavail = resp.Blocks - numblocks+ resp.Bsize = uint32(blockSize)++ // Report the total number of possible files in the file system (and those free)+ resp.Files = math.MaxInt64+ resp.Ffree = math.MaxInt64 - actualFileCount++ // Report the maximum length of a name and the minimum fragment size+ resp.Namelen = 1024+ resp.Frsize = uint32(blockSize)++ return nil+}