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 17:55:51 +0200
commitf0dd86451023a6e5b0aeb5625130e404a6cb1db6 (patch)
treebbb8ac6453bd6484185f627c5fe29490130f99bc
parent7c60178b42a301c3cd068d38d5606c9b044ba41c (diff)
downloadlibfuse-f0dd86451023a6e5b0aeb5625130e404a6cb1db6.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();