[PATCH] r/o bind mounts: elevate write count for ncp_ioctl()
[safe/jmp/linux-2.6] / fs / pnode.c
index 37b568e..1d8f544 100644 (file)
@@ -6,7 +6,7 @@
  *     Author : Ram Pai (linuxram@us.ibm.com)
  *
  */
-#include <linux/namespace.h>
+#include <linux/mnt_namespace.h>
 #include <linux/mount.h>
 #include <linux/fs.h>
 #include "pnode.h"
@@ -53,14 +53,13 @@ static int do_make_slave(struct vfsmount *mnt)
        if (master) {
                list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
                        slave_mnt->mnt_master = master;
-               list_del(&mnt->mnt_slave);
-               list_add(&mnt->mnt_slave, &master->mnt_slave_list);
+               list_move(&mnt->mnt_slave, &master->mnt_slave_list);
                list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
                INIT_LIST_HEAD(&mnt->mnt_slave_list);
        } else {
                struct list_head *p = &mnt->mnt_slave_list;
                while (!list_empty(p)) {
-                        slave_mnt = list_entry(p->next,
+                        slave_mnt = list_first_entry(p,
                                        struct vfsmount, mnt_slave);
                        list_del_init(&slave_mnt->mnt_slave);
                        slave_mnt->mnt_master = NULL;
@@ -84,6 +83,8 @@ void change_mnt_propagation(struct vfsmount *mnt, int type)
                mnt->mnt_master = NULL;
                if (type == MS_UNBINDABLE)
                        mnt->mnt_flags |= MNT_UNBINDABLE;
+               else
+                       mnt->mnt_flags &= ~MNT_UNBINDABLE;
        }
 }
 
@@ -224,7 +225,7 @@ out:
  */
 static inline int do_refcount_check(struct vfsmount *mnt, int count)
 {
-       int mycount = atomic_read(&mnt->mnt_count);
+       int mycount = atomic_read(&mnt->mnt_count) - mnt->mnt_ghosts;
        return (mycount > count);
 }
 
@@ -283,10 +284,8 @@ static void __propagate_umount(struct vfsmount *mnt)
                 * umount the child only if the child has no
                 * other children
                 */
-               if (child && list_empty(&child->mnt_mounts)) {
-                       list_del(&child->mnt_hash);
-                       list_add_tail(&child->mnt_hash, &mnt->mnt_hash);
-               }
+               if (child && list_empty(&child->mnt_mounts))
+                       list_move_tail(&child->mnt_hash, &mnt->mnt_hash);
        }
 }