mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add flag to enforce quota
This commit is contained in:
parent
f1713c96ae
commit
b7c992f410
|
@ -66,6 +66,7 @@ type WFS struct {
|
|||
fhmap *FileHandleToInode
|
||||
dhmap *DirectoryHandleToInode
|
||||
fuseServer *fuse.Server
|
||||
IsOverQuota bool
|
||||
}
|
||||
|
||||
func NewSeaweedFileSystem(option *Option) *WFS {
|
||||
|
|
|
@ -35,6 +35,10 @@ func (wfs *WFS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse
|
|||
|
||||
func (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 status
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -100,15 +100,21 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {
|
|||
// send the data to the OS
|
||||
glog.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.entry
|
||||
|
|
|
@ -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.ENOENT
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 name
|
||||
if len(attr) > MAX_XATTR_NAME_SIZE {
|
||||
if runtime.GOOS == "darwin" {
|
||||
|
|
Loading…
Reference in a new issue