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 flag to enforce quota
chrislub7c992f41009
diff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.goindex 0e54891985..25a2030446 100644--- a/weed/mount/weedfs.go+++ b/weed/mount/weedfs.go@@ -66,6 +66,7 @@ type WFS struct {fhmap *FileHandleToInodedhmap *DirectoryHandleToInodefuseServer *fuse.Server+ IsOverQuota bool}func NewSeaweedFileSystem(option *Option) *WFS {diff --git a/weed/mount/weedfs_attr.go b/weed/mount/weedfs_attr.goindex 3a5fb756d1..64e9cb5f59 100644--- a/weed/mount/weedfs_attr.go+++ b/weed/mount/weedfs_attr.go@@ -35,6 +35,10 @@ func (wfs *WFS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fusefunc (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+path, fh, entry, status := wfs.maybeReadEntry(input.NodeId)if status != fuse.OK {return statusdiff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.goindex b23245555f..3872102df1 100644--- a/weed/mount/weedfs_dir_mkrm.go+++ b/weed/mount/weedfs_dir_mkrm.go@@ -21,6 +21,10 @@ import (* */func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+if s := checkName(name); s != fuse.OK {return s}diff --git a/weed/mount/weedfs_file_mkrm.go b/weed/mount/weedfs_file_mkrm.goindex 52e15bc539..81186da0ac 100644--- a/weed/mount/weedfs_file_mkrm.go+++ b/weed/mount/weedfs_file_mkrm.go@@ -35,6 +35,10 @@ func (wfs *WFS) Create(cancel <-chan struct{}, in *fuse.CreateIn, name string, o*/func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+if s := checkName(name); s != fuse.OK {return s}diff --git a/weed/mount/weedfs_file_sync.go b/weed/mount/weedfs_file_sync.goindex 4c6dda6eb6..99403fc52e 100644--- a/weed/mount/weedfs_file_sync.go+++ b/weed/mount/weedfs_file_sync.go@@ -100,15 +100,21 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {// send the data to the OSglog.V(4).Infof("doFlush %s fh %d", fileFullPath, fh.handle)- if err := fh.dirtyPages.FlushData(); err != nil {- glog.Errorf("%v doFlush: %v", fileFullPath, err)- return fuse.EIO+ if !wfs.IsOverQuota {+ if err := fh.dirtyPages.FlushData(); err != nil {+ glog.Errorf("%v doFlush: %v", fileFullPath, err)+ return fuse.EIO+ }}if !fh.dirtyMetadata {return fuse.OK}+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {entry := fh.entrydiff --git a/weed/mount/weedfs_file_write.go b/weed/mount/weedfs_file_write.goindex efdf393861..ff0adcf756 100644--- a/weed/mount/weedfs_file_write.go+++ b/weed/mount/weedfs_file_write.go@@ -33,6 +33,10 @@ import (*/func (wfs *WFS) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) {+ if wfs.IsOverQuota {+ return 0, fuse.EPERM+ }+fh := wfs.GetHandle(FileHandleId(in.Fh))if fh == nil {return 0, fuse.ENOENTdiff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.goindex 9468b1fb19..36dc93b2ff 100644--- a/weed/mount/weedfs_link.go+++ b/weed/mount/weedfs_link.go@@ -23,6 +23,10 @@ When creating a link:/** Create a hard link to a file */func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+if s := checkName(name); s != fuse.OK {return s}diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.goindex 5446c7ed13..c36130faa9 100644--- a/weed/mount/weedfs_rename.go+++ b/weed/mount/weedfs_rename.go@@ -131,6 +131,10 @@ const ()func (wfs *WFS) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName string, newName string) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }+if s := checkName(newName); s != fuse.OK {return s}diff --git a/weed/mount/weedfs_symlink.go b/weed/mount/weedfs_symlink.goindex 787a015b62..81bfe8c95a 100644--- a/weed/mount/weedfs_symlink.go+++ b/weed/mount/weedfs_symlink.go@@ -14,6 +14,9 @@ import (/** Create a symbolic link */func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target string, name string, out *fuse.EntryOut) (code fuse.Status) {+ if wfs.IsOverQuota {+ return fuse.EPERM+ }if s := checkName(name); s != fuse.OK {return s}diff --git a/weed/mount/weedfs_xattr.go b/weed/mount/weedfs_xattr.goindex 09cd2e9809..aa95e8c8b9 100644--- a/weed/mount/weedfs_xattr.go+++ b/weed/mount/weedfs_xattr.go@@ -69,6 +69,11 @@ func (wfs *WFS) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr str// Perform a pure replace operation, which fails if the named// attribute does not already exist.func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status {++ if wfs.IsOverQuota {+ return fuse.EPERM+ }+//validate attr nameif len(attr) > MAX_XATTR_NAME_SIZE {if runtime.GOOS == "darwin" {