From 2e64c0fe2aee88409c1f9a06ee8f1a08b6b10266 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 10 Apr 2026 16:37:36 -0700 Subject: [PATCH] fix(mount): skip metadata flush for unlinked-while-open files (#9027) When a file is unlinked while still open (open-unlink-close pattern), the synchronous doFlush path would recreate the entry on the filer during close. Check fh.isDeleted before flushing metadata, matching the async flush path which already had this check. --- weed/mount/weedfs_file_sync.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/mount/weedfs_file_sync.go b/weed/mount/weedfs_file_sync.go index 88c88ea97..adfefebd2 100644 --- a/weed/mount/weedfs_file_sync.go +++ b/weed/mount/weedfs_file_sync.go @@ -144,6 +144,13 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32, allowAsync bool) fuse.S return fuse.OK } + // Skip metadata flush if the file was unlinked while open. + // The filer entry is already gone; flushing would recreate it. + if fh.isDeleted { + glog.V(3).Infof("doFlush %s fh %d: file was unlinked, skipping metadata flush", fileFullPath, fh.fh) + return fuse.OK + } + if isOverQuota { return fuse.Status(syscall.ENOSPC) }