Revert "fusefrontend: don't always clear the dircache in Rename"

As noticed by @slackner in
cb8872577d (commitcomment-39405233) ,
this is not safe.

This reverts commit cb8872577d.
This commit is contained in:
Jakob Unterwurzacher 2020-05-24 23:36:11 +02:00
parent 15ff79bf14
commit 71c0481f0e
1 changed files with 1 additions and 8 deletions

View File

@ -533,6 +533,7 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co
// //
// Symlink-safe through Renameat(). // Symlink-safe through Renameat().
func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) { func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) {
defer fs.dirCache.Clear()
if fs.isFiltered(newPath) { if fs.isFiltered(newPath) {
return fuse.EPERM return fuse.EPERM
} }
@ -548,9 +549,6 @@ func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (cod
defer syscall.Close(newDirfd) defer syscall.Close(newDirfd)
// Easy case. // Easy case.
if fs.args.PlaintextNames { if fs.args.PlaintextNames {
// The rename may replace another directory. Make sure we drop the
// deleted directory from the cache.
defer fs.dirCache.Clear()
return fuse.ToStatus(syscallcompat.Renameat(oldDirfd, oldCName, newDirfd, newCName)) return fuse.ToStatus(syscallcompat.Renameat(oldDirfd, oldCName, newDirfd, newCName))
} }
// Long destination file name: create .name file // Long destination file name: create .name file
@ -577,11 +575,6 @@ func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (cod
// again. // again.
tlog.Debug.Printf("Rename: Handling ENOTEMPTY") tlog.Debug.Printf("Rename: Handling ENOTEMPTY")
if fs.Rmdir(newPath, context) == fuse.OK { if fs.Rmdir(newPath, context) == fuse.OK {
// The rename replaced another directory. Make sure we drop the
// deleted directory from the cache (note: fs.Rmdir also clears it,
// but this is not guaranteed forever, and a double clear does no
// harm).
defer fs.dirCache.Clear()
err = syscallcompat.Renameat(oldDirfd, oldCName, newDirfd, newCName) err = syscallcompat.Renameat(oldDirfd, oldCName, newDirfd, newCName)
} }
} }