From: sukadev@us.ibm.com
To: Andrew Morton <akpm@osdl.org>
Cc: serue@us.ibm.com, matthltc@us.ibm.com,
"Eric W. Biederman" <ebiederm@xmission.com>,
hpa@zytor.com, Pavel Emelyanov <xemul@openvz.org>,
Containers <containers@lists.osdl.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/4]: Enable multiple mounts of /dev/pts
Date: Sat, 12 Apr 2008 10:34:28 -0700 [thread overview]
Message-ID: <20080412173428.GD19449@us.ibm.com> (raw)
In-Reply-To: <20080412172933.GA19295@us.ibm.com>
From: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Subject:[PATCH 4/4]: Enable multiple mounts of /dev/pts
To support multiple PTY namespaces, allow multiple mounts of /dev/pts, once
within each PTY namespace.
This patch removes the get_sb_single() in devpts_get_sb() and uses test and
set sb interfaces to allow remounting /dev/pts.
Changelog [v4]:
- Split-off the simpler changes of moving global=variables into
'pts_namespace' to previous patch.
Changelog [v3]:
- Removed some unnecessary comments from devpts_set_sb()
Changelog [v2]:
- (Pavel Emelianov/Serge Hallyn) Remove reference to pts_ns from
sb->s_fs_info to fix the circular reference (/dev/pts is not
unmounted unless the pts_ns is destroyed, so we don't need a
reference to the pts_ns).
Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
---
fs/devpts/inode.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 59 insertions(+), 3 deletions(-)
Index: 2.6.25-rc8-mm1/fs/devpts/inode.c
===================================================================
--- 2.6.25-rc8-mm1.orig/fs/devpts/inode.c 2008-04-12 10:10:33.000000000 -0700
+++ 2.6.25-rc8-mm1/fs/devpts/inode.c 2008-04-12 10:10:38.000000000 -0700
@@ -154,17 +154,73 @@ fail:
return -ENOMEM;
}
+/*
+ * We use test and set super-block operations to help determine whether we
+ * need a new super-block for this namespace. get_sb() walks the list of
+ * existing devpts supers, comparing them with the @data ptr. Since we
+ * passed 'current's namespace as the @data pointer we can compare the
+ * namespace pointer in the super-block's 's_fs_info'. If the test is
+ * TRUE then get_sb() returns a new active reference to the super block.
+ * Otherwise, it helps us build an active reference to a new one.
+ */
+
+static int devpts_test_sb(struct super_block *sb, void *data)
+{
+ return sb->s_fs_info == data;
+}
+
+static int devpts_set_sb(struct super_block *sb, void *data)
+{
+ sb->s_fs_info = data;
+ return set_anon_super(sb, NULL);
+}
+
static int devpts_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{
- return get_sb_single(fs_type, flags, data, devpts_fill_super, mnt);
+ struct super_block *sb;
+ struct pts_namespace *ns;
+ int err;
+
+ /* hereafter we're very similar to proc_get_sb */
+ if (flags & MS_KERNMOUNT)
+ ns = data;
+ else
+ ns = &init_pts_ns;
+
+ /* hereafter we're very simlar to get_sb_nodev */
+ sb = sget(fs_type, devpts_test_sb, devpts_set_sb, ns);
+ if (IS_ERR(sb))
+ return PTR_ERR(sb);
+
+ if (sb->s_root)
+ return simple_set_mnt(mnt, sb);
+
+ sb->s_flags = flags;
+ err = devpts_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
+ if (err) {
+ up_write(&sb->s_umount);
+ deactivate_super(sb);
+ return err;
+ }
+
+ sb->s_flags |= MS_ACTIVE;
+ ns->mnt = mnt;
+
+ return simple_set_mnt(mnt, sb);
+}
+
+static void devpts_kill_sb(struct super_block *sb)
+{
+ sb->s_fs_info = NULL;
+ kill_anon_super(sb);
}
static struct file_system_type devpts_fs_type = {
.owner = THIS_MODULE,
.name = "devpts",
.get_sb = devpts_get_sb,
- .kill_sb = kill_anon_super,
+ .kill_sb = devpts_kill_sb,
};
/*
@@ -315,7 +371,7 @@ static int __init init_devpts_fs(void)
err = register_filesystem(&devpts_fs_type);
if (!err) {
- mnt = kern_mount(&devpts_fs_type);
+ mnt = kern_mount_data(&devpts_fs_type, &init_pts_ns);
if (IS_ERR(mnt))
err = PTR_ERR(mnt);
else
next prev parent reply other threads:[~2008-04-12 17:34 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-12 17:29 [PATCH 0/4] Helper patches for PTY namespaces sukadev
2008-04-12 17:32 ` [PATCH 1/4]: Propagate error code from devpts_pty_new sukadev
2008-04-12 17:32 ` [PATCH 2/4]: Factor out PTY index allocation sukadev
2008-04-12 17:33 ` [PATCH 3/4]: Move devpts globals into init_pts_ns sukadev
2008-04-12 17:34 ` sukadev [this message]
[not found] ` <20080412172933.GA19295-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-04-12 17:39 ` [PATCH 0/4] Helper patches for PTY namespaces Subrata Modak
[not found] ` <bb33bcf20804121039u409ae37q2dead849ca24dfa-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-12 18:05 ` sukadev-r/Jw6+rmf7HQT0dZR+AlfA
[not found] ` <20080412180533.GE19449-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-04-14 11:20 ` [LTP] " Subrata Modak
[not found] ` <1208172006.5762.21.camel-NRFfyExJdYpgXGGE5LP+UZlqa2bBAFbm0E9HWUfgJXw@public.gmane.org>
2008-04-14 12:31 ` Veerendra Chandrappa
[not found] ` <OF766ECBB8.8B7DAFCE-ON6525742B.00437346-6525742B.0043FD8A-xthvdsQ13ZrQT0dZR+AlfA@public.gmane.org>
2008-04-14 12:31 ` Subrata Modak
[not found] ` <1208176260.5762.36.camel-NRFfyExJdYpgXGGE5LP+UZlqa2bBAFbm0E9HWUfgJXw@public.gmane.org>
2008-04-22 7:11 ` Subrata Modak
[not found] ` <1208848319.4847.16.camel-NRFfyExJdYpgXGGE5LP+UZlqa2bBAFbm0E9HWUfgJXw@public.gmane.org>
2008-04-22 12:25 ` Serge E. Hallyn
[not found] ` <20080422122530.GB8331-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2008-04-22 15:08 ` [LTP] " Subrata Modak
2008-04-23 18:01 ` H. Peter Anvin
2008-04-12 18:09 ` H. Peter Anvin
2008-04-12 18:09 ` H. Peter Anvin
2008-04-12 18:35 ` Al Viro
2008-04-12 18:54 ` Multiple instances of devpts H. Peter Anvin
2008-04-12 19:15 ` Eric W. Biederman
[not found] ` <1208027757.28187.25.camel-xJGG6ySDJhrj0SQisxZUdA@public.gmane.org>
2008-04-12 19:24 ` H. Peter Anvin
2008-04-12 19:24 ` H. Peter Anvin
[not found] ` <48010C70.2030902-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2008-04-12 19:30 ` H. Peter Anvin
2008-04-12 19:30 ` H. Peter Anvin
2008-04-12 19:06 ` [PATCH 0/4] Helper patches for PTY namespaces Eric W. Biederman
2008-04-13 0:59 ` Serge E. Hallyn
[not found] ` <1208027215.28187.17.camel-xJGG6ySDJhrj0SQisxZUdA@public.gmane.org>
2008-08-01 18:12 ` Per-instance devpts H. Peter Anvin
2008-08-01 18:12 ` H. Peter Anvin
2008-08-01 19:23 ` Dave Hansen
2008-08-01 19:35 ` Al Viro
2008-08-01 19:37 ` H. Peter Anvin
[not found] ` <f73f7ab80808020004j15b0d0e5x5fa911242641b34d@mail.gmail.com>
2008-08-02 7:06 ` Kyle Moffett
[not found] ` <f73f7ab80808020006i7f0ac456ve9b9f73568c11294-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-08-02 15:33 ` H. Peter Anvin
2008-08-02 15:33 ` H. Peter Anvin
2008-08-02 8:54 ` Bastian Blank
2008-08-03 5:08 ` sukadev
[not found] ` <20080803050800.GA4322-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-08-03 11:31 ` H. Peter Anvin
2008-08-03 11:31 ` H. Peter Anvin
2008-08-03 12:04 ` Alan Cox
2008-08-03 12:04 ` Alan Cox
2008-08-03 17:46 ` sukadev
2008-08-03 17:54 ` Alan Cox
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=20080412173428.GD19449@us.ibm.com \
--to=sukadev@us.ibm.com \
--cc=akpm@osdl.org \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthltc@us.ibm.com \
--cc=serue@us.ibm.com \
--cc=xemul@openvz.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.