]> git.ipfire.org Git - people/ms/linux.git/blobdiff - fs/namespace.c
mnt: Factor out unhash_mnt from detach_mnt and umount_tree
[people/ms/linux.git] / fs / namespace.c
index acc5583764dc0925ad2f4745824d3848b743e978..e669a3bf86e76e4d0c906b5303e6a139101adc4f 100644 (file)
@@ -798,10 +798,8 @@ static void __touch_mnt_namespace(struct mnt_namespace *ns)
 /*
  * vfsmount lock must be held for write
  */
-static void detach_mnt(struct mount *mnt, struct path *old_path)
+static void unhash_mnt(struct mount *mnt)
 {
-       old_path->dentry = mnt->mnt_mountpoint;
-       old_path->mnt = &mnt->mnt_parent->mnt;
        mnt->mnt_parent = mnt;
        mnt->mnt_mountpoint = mnt->mnt.mnt_root;
        list_del_init(&mnt->mnt_child);
@@ -811,6 +809,16 @@ static void detach_mnt(struct mount *mnt, struct path *old_path)
        mnt->mnt_mp = NULL;
 }
 
+/*
+ * vfsmount lock must be held for write
+ */
+static void detach_mnt(struct mount *mnt, struct path *old_path)
+{
+       old_path->dentry = mnt->mnt_mountpoint;
+       old_path->mnt = &mnt->mnt_parent->mnt;
+       unhash_mnt(mnt);
+}
+
 /*
  * vfsmount lock must be held for write
  */
@@ -1362,15 +1370,10 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
 
                pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt, &unmounted);
                if (mnt_has_parent(p)) {
-                       hlist_del_init(&p->mnt_mp_list);
-                       put_mountpoint(p->mnt_mp);
                        mnt_add_count(p->mnt_parent, -1);
                        /* old mountpoint will be dropped when we can do that */
                        p->mnt_ex_mountpoint = p->mnt_mountpoint;
-                       p->mnt_mountpoint = p->mnt.mnt_root;
-                       p->mnt_parent = p;
-                       p->mnt_mp = NULL;
-                       hlist_del_init_rcu(&p->mnt_hash);
+                       unhash_mnt(p);
                }
                change_mnt_propagation(p, MS_PRIVATE);
        }