hardlink deletion factors in hardlink counter

This commit is contained in:
Chris Lu
2020-09-24 09:43:52 -07:00
parent 1295347958
commit 2e7c361a0d
3 changed files with 9 additions and 6 deletions

View File

@@ -331,7 +331,8 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error {
// first, ensure the filer store can correctly delete
glog.V(3).Infof("remove file: %v", req)
err = filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, false, false, false, false, []int32{dir.wfs.signature})
isDeleteData := entry.HardLinkCounter <= 1
err = filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, isDeleteData, false, false, false, []int32{dir.wfs.signature})
if err != nil {
glog.V(3).Infof("not found remove file %s/%s: %v", dir.FullPath(), req.Name, err)
return fuse.ENOENT
@@ -342,7 +343,9 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error {
dir.wfs.fsNodeCache.DeleteFsNode(filePath)
// delete the chunks last
dir.wfs.deleteFileChunks(entry.Chunks)
if isDeleteData {
dir.wfs.deleteFileChunks(entry.Chunks)
}
return nil