Commit 0709e3ce authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

mount: do remaps for child-overmount of another overmount

In case we have mounts:

1 /mnt/
2 /mnt/a with parent 1
3 /mnt/a/b with parent 1
4 /mnt/a with parent 2

We determine 2 as needing remap with does_mnt_overmount() and remap it.
Next we mount 4 on top of 2. Next in fixup_remap_mounts() we want to
move 2 back to it's parent 1, but instead move 4 there. So in these case
children-overmounts need to be remapped too.
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent a9ec5829
......@@ -629,7 +629,7 @@ static struct mount_info *find_fsroot_mount_for(struct mount_info *bm)
return NULL;
}
static bool does_mnt_overmount(struct mount_info *m)
static bool mnt_needs_remap(struct mount_info *m)
{
struct mount_info *t;
......@@ -643,6 +643,14 @@ static bool does_mnt_overmount(struct mount_info *m)
return true;
}
/*
* If we are children-overmount and parent is remapped, we should be
* remapped too, else fixup_remap_mounts() won't be able to move parent
* to it's real place, it will move child instead.
*/
if (!strcmp(m->parent->mountpoint, m->mountpoint))
return mnt_needs_remap(m->parent);
return false;
}
......@@ -2497,7 +2505,7 @@ static int try_remap_mount(struct mount_info *m)
{
struct mnt_remap_entry *r;
if (!does_mnt_overmount(m))
if (!mnt_needs_remap(m))
return 0;
BUG_ON(!m->parent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment