]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
turn do_make_slave() into transfer_propagation()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 25 Jun 2025 03:36:43 +0000 (23:36 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Jun 2025 23:03:30 +0000 (19:03 -0400)
Lift calculation of replacement propagation source, removal from
peer group and assignment of ->mnt_master from do_make_slave() into
change_mnt_propagation() itself.  What remains is switching of
what used to get propagation *through* mnt to alternative source.
Rename to transfer_propagation(), passing it the replacement source
as the second argument.  Have it return void, while we are at it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/pnode.c

index 91d10af867bdef5ae36e26d82057f32e0424ed19..0a54848cbbd1583502ef3497e16d2b81be885eac 100644 (file)
@@ -83,19 +83,10 @@ static struct mount *propagation_source(struct mount *mnt)
        return mnt;
 }
 
-static int do_make_slave(struct mount *mnt)
+static void transfer_propagation(struct mount *mnt, struct mount *to)
 {
-       struct mount *master = propagation_source(mnt);
        struct mount *slave_mnt;
-
-       if (list_empty(&mnt->mnt_share)) {
-               mnt_release_group_id(mnt);
-       } else {
-               list_del_init(&mnt->mnt_share);
-               mnt->mnt_group_id = 0;
-       }
-       CLEAR_MNT_SHARED(mnt);
-       if (!master) {
+       if (!to) {
                struct list_head *p = &mnt->mnt_slave_list;
                while (!list_empty(p)) {
                        slave_mnt = list_first_entry(p,
@@ -103,14 +94,12 @@ static int do_make_slave(struct mount *mnt)
                        list_del_init(&slave_mnt->mnt_slave);
                        slave_mnt->mnt_master = NULL;
                }
-               return 0;
+               return;
        }
        list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
-               slave_mnt->mnt_master = master;
-       list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
+               slave_mnt->mnt_master = to;
+       list_splice(&mnt->mnt_slave_list, to->mnt_slave_list.prev);
        INIT_LIST_HEAD(&mnt->mnt_slave_list);
-       mnt->mnt_master = master;
-       return 0;
 }
 
 /*
@@ -122,8 +111,19 @@ void change_mnt_propagation(struct mount *mnt, int type)
                set_mnt_shared(mnt);
                return;
        }
-       if (IS_MNT_SHARED(mnt))
-               do_make_slave(mnt);
+       if (IS_MNT_SHARED(mnt)) {
+               struct mount *m = propagation_source(mnt);
+
+               if (list_empty(&mnt->mnt_share)) {
+                       mnt_release_group_id(mnt);
+               } else {
+                       list_del_init(&mnt->mnt_share);
+                       mnt->mnt_group_id = 0;
+               }
+               CLEAR_MNT_SHARED(mnt);
+               transfer_propagation(mnt, m);
+               mnt->mnt_master = m;
+       }
        list_del_init(&mnt->mnt_slave);
        if (type == MS_SLAVE) {
                if (mnt->mnt_master)