On Sat, Feb 22, 2020 at 06:07:39PM -0800, Linus Torvalds wrote: > On Sat, Feb 22, 2020 at 5:16 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > > > + > > +discard2: > > + namespace_unlock(); > > +discard1: > > + inode_unlock(dentry->d_inode); > > +discard: > > /* remove m from any expiration list it may be on */ > > Would you mind re-naming those labels? > > I realize that the numbering may help show that the error handling is > done in the reverse order, but I bet that a nice name could so that > too. Umm... A bit of reordering in the beginning eliminates discard1, suggesting s/discard2/discard_locked/... Incremental would be diff --git a/fs/namespace.c b/fs/namespace.c index 6228fd1ef94f..777c3116e62e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2844,22 +2844,22 @@ int finish_automount(struct vfsmount *m, struct path *path) * got", not "try to mount it on top". */ inode_lock(dentry->d_inode); + namespace_lock(); if (unlikely(cant_mount(dentry))) { err = -ENOENT; - goto discard1; + goto discard_locked; } - namespace_lock(); rcu_read_lock(); if (unlikely(__lookup_mnt(path->mnt, dentry))) { rcu_read_unlock(); err = 0; - goto discard2; + goto discard_locked; } rcu_read_unlock(); mp = get_mountpoint(dentry); if (IS_ERR(mp)) { err = PTR_ERR(mp); - goto discard2; + goto discard_locked; } err = do_add_mount(mnt, mp, path, path->mnt->mnt_flags | MNT_SHRINKABLE); @@ -2869,9 +2869,8 @@ int finish_automount(struct vfsmount *m, struct path *path) mntput(m); return 0; -discard2: +discard_locked: namespace_unlock(); -discard1: inode_unlock(dentry->d_inode); discard: /* remove m from any expiration list it may be on */