From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Waychison Subject: Re: [RFC][PATCH 6/8] namespace: use mnt_base for proc Date: Mon, 30 May 2005 15:54:11 -0400 Message-ID: <429B6F63.6040305@waychison.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, jamie@shareable.org, viro@parcelfarce.linux.theplanet.co.uk Return-path: Received: from dsl081-242-086.sfo1.dsl.speakeasy.net ([64.81.242.86]:60638 "EHLO lapdance.christiehouse.net") by vger.kernel.org with ESMTP id S261723AbVE3T4k (ORCPT ); Mon, 30 May 2005 15:56:40 -0400 To: Miklos Szeredi In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Miklos Szeredi wrote: > This patch makes /proc/PID/mounts use fs->rootmnt->mnt_base instead of > namespace->root. This means, that if a process changes it's root to a > different namespace, or a detached subtree, the base of that tree will > be used, instead of the process's namespace. > We are going to want to block out any modifications of the tree between start and stop. This should be possible by grabbing a read lock on vfsmountref_lock IIRC. > Signed-off-by: Miklos Szeredi > > Index: linux/fs/namespace.c > =================================================================== > --- linux.orig/fs/namespace.c 2005-05-29 17:15:56.000000000 +0200 > +++ linux/fs/namespace.c 2005-05-29 17:20:32.000000000 +0200 > @@ -242,8 +242,7 @@ static void destroy_vfsmnt(struct vfsmou > /* iterator */ > static void *m_start(struct seq_file *m, loff_t *pos) > { > - struct namespace *n = m->private; > - struct vfsmount *mnt = n->root; > + struct vfsmount *mnt = m->private; > struct vfsmount *p; > loff_t l = *pos; > > @@ -256,8 +255,7 @@ static void *m_start(struct seq_file *m, > > static void *m_next(struct seq_file *m, void *v, loff_t *pos) > { > - struct namespace *n = m->private; > - struct vfsmount *mnt = n->root; > + struct vfsmount *mnt = m->private; > struct vfsmount *p = v; > (*pos)++; > return next_mnt(p, mnt); > Index: linux/include/linux/mount.h > =================================================================== > --- linux.orig/include/linux/mount.h 2005-05-29 16:55:56.000000000 +0200 > +++ linux/include/linux/mount.h 2005-05-29 17:25:53.000000000 +0200 > @@ -51,6 +51,18 @@ static inline struct vfsmount *mntget(st > return mnt; > } > > +static inline struct vfsmount *mntget_base(struct vfsmount *mnt) > +{ > + if (mnt) { > + read_lock(&vfsmountref_lock); > + mnt = mnt->mnt_base; > + atomic_inc(&mnt->mnt_count); > + atomic_inc(&mnt->mnt_group_count); > + read_unlock(&vfsmountref_lock); > + } > + return mnt; > +} > + > extern void destroy_mount_group(struct vfsmount *mnt); > > static inline void mntput_no_expire(struct vfsmount *mnt) > Index: linux/fs/proc/base.c > =================================================================== > --- linux.orig/fs/proc/base.c 2005-05-29 17:18:40.000000000 +0200 > +++ linux/fs/proc/base.c 2005-05-29 17:27:14.000000000 +0200 > @@ -581,16 +581,13 @@ static int mounts_open(struct inode *ino > > if (!ret) { > struct seq_file *m = file->private_data; > - struct namespace *namespace; > - task_lock(task); > - namespace = task->namespace; > - if (namespace) > - get_namespace(namespace); > - task_unlock(task); > - > - if (namespace) > - m->private = namespace; > - else { > + struct fs_struct *fs = get_fs_struct(task); > + if (fs) { > + read_lock(&fs->lock); > + m->private = mntget_base(fs->rootmnt); > + read_unlock(&fs->lock); > + put_fs_struct(fs); > + } else { > seq_release(inode, file); > ret = -EINVAL; > } > @@ -601,8 +598,8 @@ static int mounts_open(struct inode *ino > static int mounts_release(struct inode *inode, struct file *file) > { > struct seq_file *m = file->private_data; > - struct namespace *namespace = m->private; > - put_namespace(namespace); > + struct vfsmount *mnt = m->private; > + mntput(mnt); > return seq_release(inode, file); > } > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCm29jdQs4kOxk3/MRAh82AJ9KkQ1ZSaXBXICKVmwXIqybmOvlNACfdkc1 BhAJt+HydEmWeYHQkt1Uc3Y= =+YA1 -----END PGP SIGNATURE-----