Skip to content

Commit 2a8061e

Browse files
author
Al Viro
committed
better lockdep annotations for simple_recursive_removal()
We want a class that nests outside of I_MUTEX_NORMAL (for the sake of callbacks that might want to lock the victim) and inside I_MUTEX_PARENT (so that a variant of that could be used with parent of the victim held locked by the caller). In reality, simple_recursive_removal() * never holds two locks at once * holds the lock on parent of dentry passed to callback * is used only on the trees with fixed topology, so the depths are not changing. So the locking order is actually fine. AFAICS, the best solution is to assign I_MUTEX_CHILD to the locks grabbed by that thing. Reported-by: syzbot+169de184e9defe7fe709@syzkaller.appspotmail.com Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 61c5d53 commit 2a8061e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/libfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void simple_recursive_removal(struct dentry *dentry,
613613
struct dentry *victim = NULL, *child;
614614
struct inode *inode = this->d_inode;
615615

616-
inode_lock(inode);
616+
inode_lock_nested(inode, I_MUTEX_CHILD);
617617
if (d_is_dir(this))
618618
inode->i_flags |= S_DEAD;
619619
while ((child = find_next_child(this, victim)) == NULL) {
@@ -625,7 +625,7 @@ void simple_recursive_removal(struct dentry *dentry,
625625
victim = this;
626626
this = this->d_parent;
627627
inode = this->d_inode;
628-
inode_lock(inode);
628+
inode_lock_nested(inode, I_MUTEX_CHILD);
629629
if (simple_positive(victim)) {
630630
d_invalidate(victim); // avoid lost mounts
631631
if (callback)

0 commit comments

Comments
 (0)