diff options
author | swj <1186093704@qq.com> | 2025-04-23 22:39:28 +0800 |
---|---|---|
committer | Bernd Schubert <bernd@bsbernd.com> | 2025-04-23 17:55:51 +0200 |
commit | f0dd86451023a6e5b0aeb5625130e404a6cb1db6 (patch) | |
tree | bbb8ac6453bd6484185f627c5fe29490130f99bc /example | |
parent | 7c60178b42a301c3cd068d38d5606c9b044ba41c (diff) | |
download | libfuse-f0dd86451023a6e5b0aeb5625130e404a6cb1db6.tar.gz |
example: fix memfs_rename deadlock error
Signed-off-by: swj <1186093704@qq.com>
Diffstat (limited to 'example')
-rw-r--r-- | example/memfs_ll.cc | 9 |
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(); |