LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@ZenIV.linux.org.uk
Cc: miklos@szeredi.hu, akpm@linux-foundation.org,
linuxram@us.ibm.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [patch 3/6] vfs: mountinfo stable peer group id
Date: Wed, 19 Mar 2008 17:41:15 +0100 [thread overview]
Message-ID: <E1Jc1Ln-0003jm-Bt@pomaz-ex.szeredi.hu> (raw)
In-Reply-To: <20080319114844.GK10722@ZenIV.linux.org.uk> (message from Al Viro on Wed, 19 Mar 2008 11:48:44 +0000)
> > From: Miklos Szeredi <mszeredi@suse.cz>
> >
> > Add a stable identifier for shared mounts.
>
> > +static DEFINE_SPINLOCK(mnt_pgid_lock);
>
> Um? Do you ever need to take it outside of vfsmount_lock?
>
Tried to think this through:
It's always called with namespace_sem, which is enough, no need for a
new lock. The bigger problem, is that it _is_ called with
vfsmount_lock in one case, which is bad, since the allocation may
sleep.
That is in do_change_type(). But do we really need to hold
vfsmount_lock in that case? I think not, the propagation tree has no
relevance outside namespace_sem, so that one should be sufficient.
This patch should fix it (untested, just for review).
I have a half mind to throw out the IDR allocation altogether, and
just go with a 64bit counter, some poeple would much prefer that...
Thanks,
Miklos
---
fs/namespace.c | 2 --
fs/pnode.c | 20 ++++++++------------
2 files changed, 8 insertions(+), 14 deletions(-)
Index: linux/fs/pnode.c
===================================================================
--- linux.orig/fs/pnode.c 2008-03-19 16:39:28.000000000 +0100
+++ linux/fs/pnode.c 2008-03-19 17:26:44.000000000 +0100
@@ -12,7 +12,6 @@
#include <linux/idr.h>
#include "pnode.h"
-static DEFINE_SPINLOCK(mnt_pgid_lock);
static DEFINE_IDA(mnt_pgid_ida);
/* return the next shared peer mount of @p */
@@ -37,19 +36,19 @@ static void __set_mnt_shared(struct vfsm
mnt->mnt_flags |= MNT_SHARED;
}
+/*
+ * - must hold namespace_sem to protect the mnt_pgid_ida
+ * - must not hold vfsmount_lock, because this function might sleep
+ */
void set_mnt_shared(struct vfsmount *mnt)
{
int res;
- retry:
- spin_lock(&mnt_pgid_lock);
- if (IS_MNT_SHARED(mnt)) {
- spin_unlock(&mnt_pgid_lock);
+ might_sleep();
+ if (IS_MNT_SHARED(mnt))
return;
- }
-
+ retry:
res = ida_get_new(&mnt_pgid_ida, &mnt->mnt_pgid);
- spin_unlock(&mnt_pgid_lock);
if (res == -EAGAIN) {
if (ida_pre_get(&mnt_pgid_ida, GFP_KERNEL))
goto retry;
@@ -159,11 +158,8 @@ static int do_make_slave(struct vfsmount
peer_mnt = NULL;
}
- if (IS_MNT_SHARED(mnt) && list_empty(&mnt->mnt_share)) {
- spin_lock(&mnt_pgid_lock);
+ if (IS_MNT_SHARED(mnt) && list_empty(&mnt->mnt_share))
ida_remove(&mnt_pgid_ida, mnt->mnt_pgid);
- spin_unlock(&mnt_pgid_lock);
- }
list_del_init(&mnt->mnt_share);
if (peer_mnt)
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2008-03-19 16:39:28.000000000 +0100
+++ linux/fs/namespace.c 2008-03-19 17:23:06.000000000 +0100
@@ -1351,10 +1351,8 @@ static noinline int do_change_type(struc
return -EINVAL;
down_write(&namespace_sem);
- spin_lock(&vfsmount_lock);
for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
change_mnt_propagation(m, type);
- spin_unlock(&vfsmount_lock);
up_write(&namespace_sem);
return 0;
}
next prev parent reply other threads:[~2008-03-20 0:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-13 21:26 [patch 0/6] vfs: mountinfo update Miklos Szeredi
2008-03-13 21:26 ` [patch 1/6] vfs: mountinfo -mm fix Miklos Szeredi
2008-03-13 21:26 ` [patch 2/6] vfs: pnode cleanup Miklos Szeredi
2008-03-19 11:16 ` Al Viro
2008-03-19 11:48 ` Miklos Szeredi
2008-03-13 21:26 ` [patch 3/6] vfs: mountinfo stable peer group id Miklos Szeredi
2008-03-19 11:48 ` Al Viro
2008-03-19 16:41 ` Miklos Szeredi [this message]
2008-03-19 18:20 ` Al Viro
2008-03-19 18:37 ` Miklos Szeredi
2008-03-20 21:43 ` Al Viro
2008-03-21 8:57 ` Miklos Szeredi
2008-03-22 3:49 ` Al Viro
2008-03-22 3:54 ` Al Viro
2008-03-22 4:11 ` Al Viro
2008-03-22 4:56 ` Al Viro
2008-03-30 19:33 ` Ram Pai
2008-03-24 8:50 ` Ram Pai
2008-03-24 8:54 ` Christoph Hellwig
2008-03-24 9:53 ` Al Viro
2008-03-22 16:27 ` Al Viro
2008-03-24 8:19 ` Ram Pai
2008-03-24 9:34 ` Al Viro
2008-03-13 21:26 ` [patch 4/6] vfs: mountinfo show dominating " Miklos Szeredi
2008-03-19 11:37 ` Al Viro
2008-03-19 12:03 ` Miklos Szeredi
2008-03-19 12:19 ` Miklos Szeredi
2008-03-19 12:41 ` Al Viro
2008-03-19 13:07 ` Miklos Szeredi
2008-03-13 21:26 ` [patch 5/6] vfs: optimization to /proc/<pid>/mountinfo patch Miklos Szeredi
2008-03-19 11:56 ` Al Viro
2008-03-19 16:56 ` Miklos Szeredi
2008-03-13 21:26 ` [patch 6/6] vfs: mountinfo: only show mounts under tasks root Miklos Szeredi
2008-03-19 12:12 ` Al Viro
2008-03-19 12:25 ` Miklos Szeredi
2008-03-13 22:53 ` [patch 0/6] vfs: mountinfo update Andrew Morton
2008-03-14 8:17 ` Miklos Szeredi
2008-03-14 19:29 ` Ram Pai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Jc1Ln-0003jm-Bt@pomaz-ex.szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).