diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-10-10 13:07:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-10 13:07:57 +0800 |
| commit | 411e49f96494629fa3da334e8dc7cc15bd4d19cd (patch) | |
| tree | 1756f0a2f86c871a6db67df7ecbd509c9df32233 /weed/filesys | |
| parent | ac162fc85769cb1b2a1f8694f9644eae7d0ce6c8 (diff) | |
| parent | 4a15e9c830de1b654515308e5be8380ffa34aefa (diff) | |
| download | seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.tar.xz seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.zip | |
Merge pull request #23 from chrislusf/master
sync
Diffstat (limited to 'weed/filesys')
| -rw-r--r-- | weed/filesys/dir.go | 9 | ||||
| -rw-r--r-- | weed/filesys/dir_link.go | 6 | ||||
| -rw-r--r-- | weed/filesys/wfs.go | 5 |
3 files changed, 14 insertions, 6 deletions
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index 7d93dbd9f..4dede3a8b 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -82,9 +82,9 @@ func (dir *Dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *f func (dir *Dir) setRootDirAttributes(attr *fuse.Attr) { attr.Inode = 1 // filer2.FullPath(dir.Path).AsInode() attr.Valid = time.Hour - attr.Uid = dir.entry.Attributes.Uid - attr.Gid = dir.entry.Attributes.Gid - attr.Mode = os.FileMode(dir.entry.Attributes.FileMode) + attr.Uid = dir.wfs.option.MountUid + attr.Gid = dir.wfs.option.MountGid + attr.Mode = dir.wfs.option.MountMode attr.Crtime = dir.wfs.option.MountCtime attr.Ctime = dir.wfs.option.MountCtime attr.Mtime = dir.wfs.option.MountMtime @@ -354,7 +354,8 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error { func (dir *Dir) removeFolder(req *fuse.RemoveRequest) error { glog.V(3).Infof("remove directory entry: %v", req) - err := filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, true, false, false, false, []int32{dir.wfs.signature}) + ignoreRecursiveErr := true // ignore recursion error since the OS should manage it + err := filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, true, false, ignoreRecursiveErr, false, []int32{dir.wfs.signature}) if err != nil { glog.V(0).Infof("remove %s/%s: %v", dir.FullPath(), req.Name, err) if strings.Contains(err.Error(), "non-empty") { diff --git a/weed/filesys/dir_link.go b/weed/filesys/dir_link.go index 368ded442..f6bc41b56 100644 --- a/weed/filesys/dir_link.go +++ b/weed/filesys/dir_link.go @@ -18,6 +18,10 @@ var _ = fs.NodeLinker(&Dir{}) var _ = fs.NodeSymlinker(&Dir{}) var _ = fs.NodeReadlinker(&File{}) +const ( + HARD_LINK_MARKER = '\x01' +) + func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (fs.Node, error) { oldFile, ok := old.(*File) @@ -33,7 +37,7 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f // update old file to hardlink mode if len(oldFile.entry.HardLinkId) == 0 { - oldFile.entry.HardLinkId = util.RandomBytes(16) + oldFile.entry.HardLinkId = append(util.RandomBytes(16), HARD_LINK_MARKER) oldFile.entry.HardLinkCounter = 1 } oldFile.entry.HardLinkCounter++ diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index ef31a9258..57b4c3da5 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -37,6 +37,9 @@ type Option struct { EntryCacheTtl time.Duration Umask os.FileMode + MountUid uint32 + MountGid uint32 + MountMode os.FileMode MountCtime time.Time MountMtime time.Time @@ -86,7 +89,7 @@ func NewSeaweedFileSystem(option *Option) *WFS { cacheDir := path.Join(option.CacheDir, cacheUniqueId) if option.CacheSizeMB > 0 { os.MkdirAll(cacheDir, os.FileMode(0777)&^option.Umask) - wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, cacheDir, option.CacheSizeMB) + wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, cacheDir, option.CacheSizeMB, 1024*1024) } wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), option.UidGidMapper) |
