[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
| Dave Hansen [EMAIL PROTECTED] wrote:
| | On Fri, 2008-09-26 at 14:21 -0700, [EMAIL PROTECTED] wrote:
| | > Dave Hansen [EMAIL PROTECTED] wrote:
| | > | On Fri, 2008-09-12 at 10:53 -0700, [EMAIL PROTECTED] wrote:
| | > | > + *     But for single-mount semantics, devpts cannot use 
get_sb_single(),
| | > | > + *     because get_sb_single()/sget() find and use the super-block 
from
| | > | > + *     the most recent mount of devpts. But that recent mount may be 
a
| | > | > + *     'newinstance' mount and get_sb_single() would pick the 
newinstance
| | > | > + *     super-block instead of the initial super-block.
| | > | 
| | > | Can't you just override the test() function to get what you want here?
| | > 
| | > get_sb_single() does not take a test() parameter and so I would still
| | > need a get_sb_ref() or get_sb_special() interface right ? 
| | > 
| | > This special interface could call sget() with a custom-test function,
| | > to get the super-block.  But in case of devpts, we already have the
| | > super-block. So we don't need to call sget(). We just need get a reference
| | > and remount.
| | 
| | Well, you shouldn't be using get_sb_single() at all any more, right?
| 

Since mqueue_ns is using a different approach, and devpts is the only one
needing this new interface, we can move this into fs/devpts/inode.c.

This patch again applies on current ptsns patchset.

---

>From fc983c743daad24c599215500a2e06e7eff82239 Mon Sep 17 00:00:00 2001
From: Sukadev Bhattiprolu <[EMAIL PROTECTED]>
Date: Fri, 3 Oct 2008 19:33:46 -0700
Subject: [PATCH] Define/use get_init_pts_sb()

get_init_pts_sb() is identical to get_sb_single() except that it
consistently picks up the super-block from initial kernel mount.

get_sb_single() fails to pick up the initial kernel mount if there
has been an 'newinstance' mount of devpts since the initial kernel
mount.

Touch-tested

TODO:
        This patch leaves the 'get_sb_ref() function unused which can be
        deleted.

        If this makes sense, integrate this patch into ptsns patchset.
---
 fs/devpts/inode.c |   53 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 941a3ce..27aa6d3 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -408,6 +408,38 @@ static int is_new_instance_mount(void *data)
        return rc;
 }
 
+static int compare_init_pts_sb(struct super_block *s, void *p)
+{
+       if (devpts_mnt)
+               return devpts_mnt->mnt_sb == s;
+
+       return 0;
+}
+
+static int get_init_pts_sb(struct file_system_type *fs_type, int flags,
+               void *data, struct vfsmount *mnt)
+{
+        struct super_block *s;
+        int error;
+
+        s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL);
+        if (IS_ERR(s))
+                return PTR_ERR(s);
+
+        if (!s->s_root) {
+                s->s_flags = flags;
+                error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
+                if (error) {
+                        up_write(&s->s_umount);
+                        deactivate_super(s);
+                        return error;
+                }
+                s->s_flags |= MS_ACTIVE;
+        }
+        do_remount_sb(s, flags, data, 0);
+        return simple_set_mnt(mnt, s);
+}
+
 /*
  * Mount or remount the initial kernel mount of devpts. This type of
  * mount maintains the legacy, single-instance semantics, while the
@@ -418,21 +450,18 @@ static int init_pts_mount(struct file_system_type 
*fs_type, int flags,
 {
        int err;
 
-       if (!devpts_mnt) {
-               err = get_sb_single(fs_type, flags, data, devpts_fill_super,
-                               mnt);
-
-               err = mknod_ptmx(mnt->mnt_sb);
-               if (err) {
-                       dput(mnt->mnt_sb->s_root);
-                       deactivate_super(mnt->mnt_sb);
-               } else
-                       devpts_mnt = mnt;
-
+       err = get_init_pts_sb(fs_type, flags, data, mnt);
+       if (err || devpts_mnt)
                return err;
+
+       /* first mount of devpts - make ptmx node */
+       err = mknod_ptmx(mnt->mnt_sb);
+       if (err) {
+               dput(mnt->mnt_sb->s_root);
+               deactivate_super(mnt->mnt_sb);
        }
 
-       return get_sb_ref(devpts_mnt->mnt_sb, flags, data, mnt);
+       return err;
 }
 
 static int devpts_get_sb(struct file_system_type *fs_type,
-- 
1.5.2.5

_______________________________________________
Containers mailing list
[EMAIL PROTECTED]
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Devel mailing list
[email protected]
https://openvz.org/mailman/listinfo/devel

Reply via email to