ANDROID: mnt: remount should propagate to slaves of slaves
authorDaniel Rosenberg <drosen@google.com>
Thu, 5 Jan 2017 22:37:11 +0000 (14:37 -0800)
committerAmit Pundir <amit.pundir@linaro.org>
Fri, 3 Feb 2017 09:34:29 +0000 (15:04 +0530)
propagate_remount was not accounting for the slave mounts
of other slave mounts, leading to some namespaces not
recieving the remount information.

bug:33731928
Change-Id: Idc9e8c2ed126a4143229fc23f10a959c2d0a3854
Signed-off-by: Daniel Rosenberg <drosen@google.com>
fs/pnode.c
fs/pnode.h

index 69b86b61af3575c0948bd7c9f614cff69bfbe095..cbaa998ad6252ae36ba587bd3856d812bde7dd1f 100644 (file)
@@ -459,16 +459,31 @@ int propagate_umount(struct list_head *list)
        return 0;
 }
 
-int propagate_remount(struct mount *mnt) {
-       struct mount *m;
+/*
+ *  Iterates over all slaves, and slaves of slaves.
+ */
+static struct mount *next_descendent(struct mount *root, struct mount *cur)
+{
+       if (!IS_MNT_NEW(cur) && !list_empty(&cur->mnt_slave_list))
+               return first_slave(cur);
+       do {
+               if (cur->mnt_slave.next != &cur->mnt_master->mnt_slave_list)
+                       return next_slave(cur);
+               cur = cur->mnt_master;
+       } while (cur != root);
+       return NULL;
+}
+
+void propagate_remount(struct mount *mnt)
+{
+       struct mount *m = mnt;
        struct super_block *sb = mnt->mnt.mnt_sb;
-       int ret = 0;
 
        if (sb->s_op->copy_mnt_data) {
-               for (m = first_slave(mnt); m->mnt_slave.next != &mnt->mnt_slave_list; m = next_slave(m)) {
+               m = next_descendent(mnt, m);
+               while (m) {
                        sb->s_op->copy_mnt_data(m->mnt.data, mnt->mnt.data);
+                       m = next_descendent(mnt, m);
                }
        }
-
-       return ret;
 }
index 4e8e94dc9e6a2fb1069cd086846c2cfc8630b050..3cb58c0cdcbcb5c9af81704f5403c8584e60fbc0 100644 (file)
@@ -44,7 +44,7 @@ int propagate_mnt(struct mount *, struct mountpoint *, struct mount *,
 int propagate_umount(struct list_head *);
 int propagate_mount_busy(struct mount *, int);
 void propagate_mount_unlock(struct mount *);
-int propagate_remount(struct mount *);
+void propagate_remount(struct mount *);
 void mnt_release_group_id(struct mount *);
 int get_dominating_id(struct mount *mnt, const struct path *root);
 unsigned int mnt_get_count(struct mount *mnt);