aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorswj <1186093704@qq.com>2025-04-23 22:39:28 +0800
committerBernd Schubert <bernd@bsbernd.com>2025-04-23 22:20:34 +0200
commit4bc1a9222a64442bb2bcbdabca2c3c0eb4f9dad6 (patch)
treeed15789c169d3f71909ee1bb01a160ad3ad0b35e
parent2dcc57693c3ff1d4bcaa52f103633b1fc0042ba4 (diff)
downloadlibfuse-4bc1a9222a64442bb2bcbdabca2c3c0eb4f9dad6.tar.gz
example: fix memfs_rename deadlock error
Signed-off-by: swj <1186093704@qq.com>
-rw-r--r--example/memfs_ll.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/example/memfs_ll.cc b/example/memfs_ll.cc
index 9898f25..6038850 100644
--- a/example/memfs_ll.cc
+++ b/example/memfs_ll.cc
@@ -900,6 +900,7 @@ static void memfs_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
Inode *parentInode = nullptr;
Inode *newparentInode = nullptr;
Dentry *child_dentry = nullptr;
+ Dentry *child_dentry_copy = nullptr;
Dentry *existing_dentry = nullptr;
if (flags & (RENAME_EXCHANGE | RENAME_NOREPLACE)) {
@@ -909,8 +910,8 @@ static void memfs_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
Inodes.lock();
- parentInode = Inodes.find(parent);
- newparentInode = Inodes.find(newparent);
+ parentInode = Inodes.find_locked(parent);
+ newparentInode = Inodes.find_locked(newparent);
if (!parentInode || !parentInode->is_dir() || !newparentInode ||
!newparentInode->is_dir()) {
error = ENOENT;
@@ -941,9 +942,9 @@ static void memfs_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
existing_dentry->get_inode()->dec_nlink();
}
+ child_dentry_copy = new Dentry(newname, child_dentry->get_inode());
parentInode->remove_child(name);
- child_dentry->name = newname;
- newparentInode->add_child(newname, child_dentry);
+ newparentInode->add_child_locked(newname, child_dentry_copy);
out_unlock:
parentInode->unlock();