[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200227194312.GD23230@ZenIV.linux.org.uk>
Date: Thu, 27 Feb 2020 19:43:12 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC][PATCH v2 02/34] fix automount/automount race properly
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@...iv.linux.org.uk> 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 */
Powered by blists - more mailing lists