From: Ian Kent on
On Tue, 2010-06-22 at 14:49 +0900, J. R. Okajima wrote:
> Ian Kent:
> > +static vfsmount *autofs4_find_vfsmount(struct path *parent, struct dentry *root)
> > +{
> > + struct vfsmount *mnt = NULL;
> > + struct dentry *child;
> > +
> > + spin_lock(&dcache_lock);
> > + list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child) {
>
> dentry->d_subdirs?
> parent->dentry->...?

Yep, thanks, cut and paste error.

Like I said, I don't want to go though the test process unless I have
something that is, in principal, OK.

If whatever approach we use is acceptable, and will work, then I'll put
the effort into it. I just don' want to spend a heap of time on
something that is basically not the right thing to do. For example,
exporting lookup_mnt?

>
> Or how about iterate_mounts() instead of loop over dentries?
> For example (just a example),
>
> struct args {
> /* input */
> struct dentry *root;
>
> /* output */
> struct vfsmount *mnt;
> };
>
> static int compare_mnt(struct vfsmount *mnt, void *arg)
> {
> struct args *a = arg;
>
> if (mnt->mnt_root != a->root)
> return 0;
> a->mnt = mntget(mnt);
> return 1;
> }
>
> struct vfsmount *autofs4_find_vfsmount(struct dentry *root)
> {
> int err;
> struct args args = {
> .root = root
> };
>
> err = iterate_mounts(compare_mnt, &args, current->nsproxy->mnt_ns);
> }

Oh, I'm not up with this, I'll have to check this out, might be useful
for more than just this case, thanks for the comments.

Ian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Ian Kent on
On Tue, 2010-06-22 at 14:49 +0900, J. R. Okajima wrote:
>
> Or how about iterate_mounts() instead of loop over dentries?
> For example (just a example),

I may be missing something about this, but why is it safe to use
iterate_mounts(), since it doesn't take the vfsmount_lock when
traversing the list of mounts?

Ian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Ian Kent on
On Wed, 2010-06-23 at 11:07 +0900, J. R. Okajima wrote:
> Ian Kent:
> > I may be missing something about this, but why is it safe to use
> > iterate_mounts(), since it doesn't take the vfsmount_lock when
> > traversing the list of mounts?
>
> The sample code was not correct.
> We need to acquire vfsmount_lock or down_read(namespace_sem).
>
> Or it may be better to extract the body of iterate_mounts() and create a
> new function __iterate_mounts() such like that.
>
> __iterate_mounts()
> {
> /* equiv to the current iterate_mounts */
> }
>
> iterate_mount()
> {
> down_read(namespace_sem);
> or spin_lock(&vfsmount_lock);
>
> __iterate_mount();
>
> spin_unlock(&vfsmount_lock);
> or up_read(namespace_sem);
> }

Yep, thought so.
That's a useful enough function to warrant that IMHO.
I'll continue checking its usages before I do it though.

Ian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Ian Kent on
On Wed, 2010-06-23 at 11:07 +0900, J. R. Okajima wrote:
> Ian Kent:
> > I may be missing something about this, but why is it safe to use
> > iterate_mounts(), since it doesn't take the vfsmount_lock when
> > traversing the list of mounts?
>
> The sample code was not correct.
> We need to acquire vfsmount_lock or down_read(namespace_sem).

This is looking more and more suspect the more I dig.

The only place iterate_mounts() is called is within the audit subsystem
AFAICS, and I don't see where vfsmount_lock is taken in that code. OTOH,
in fs/namespace.c it is pretty clear that vfsmount->mnt_list is
protected by the vfsmount_lock.

Ummm ... that's gota be broken but maybe someone can give a reason why
it isn't?

Ian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/