linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Waychison <mike@waychison.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, jamie@shareable.org,
	viro@parcelfarce.linux.theplanet.co.uk
Subject: Re: [RFC][PATCH 6/8] namespace: use mnt_base for proc
Date: Mon, 30 May 2005 15:54:11 -0400	[thread overview]
Message-ID: <429B6F63.6040305@waychison.com> (raw)
In-Reply-To: <E1DckNq-0000Vq-00@dorka.pomaz.szeredi.hu>

-----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 <miklos@szeredi.hu>
> 
> 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-----

  reply	other threads:[~2005-05-30 19:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-30 13:32 [RFC][PATCH 6/8] namespace: use mnt_base for proc Miklos Szeredi
2005-05-30 19:54 ` Mike Waychison [this message]
2005-05-31  5:58   ` Miklos Szeredi

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=429B6F63.6040305@waychison.com \
    --to=mike@waychison.com \
    --cc=jamie@shareable.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@parcelfarce.linux.theplanet.co.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).