From 28a1969ebf79fd9835ba088ab07f3fdc75241d69 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 26 Oct 2022 17:49:01 +0000 Subject: [PATCH] Remove unneeded 'slave' flag for /data_mirror/data_ce/null Remove the 'slave' mount flag that was added by commit ef9275223c61 (https://r.android.com/2095463) because it doesn't actually do anything in this context. MS_SLAVE can only be used to change the propagation type of an existing mount, and the kernel ignores it if MS_BIND is also specified, due to the way the various high-level operations that the mount() system call can do are prioritized. The reason that the /data/user/0 mount gets propagated into /data_mirror anyway is because the /data mount has the "shared" propagation type. In the above-mentioned commit I had assumed the default Linux mount semantics, but actually Android applies the "shared" propagation type to everything (see SetupMountNamespaces() in init/mount_namespace.cpp). Test: Booted Cuttlefish and verified (via /proc/self/mountinfo) that /data/data is still bind-mounted to both /data/user/0 and /data_mirror/data_ce/null/0. Bug: 156305599 BYPASS_INCLUSIVE_LANGUAGE_REASON=commit message mentioning removed code Change-Id: Idc45d8dcb3a21d4e8e2e72f4d4dda7286f898127 --- rootdir/init.rc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index ec760d3f6..5e755d7ed 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -952,9 +952,10 @@ on post-fs-data mkdir /data_mirror/data_de/null 0700 root root # Bind mount CE and DE data directory to mirror's default volume directory. - # The 'slave' option (MS_SLAVE) is needed to cause the later bind mount of - # /data/data onto /data/user/0 to propagate to /data_mirror/data_ce/null/0. - mount none /data/user /data_mirror/data_ce/null bind rec slave + # Note that because the /data mount has the "shared" propagation type, the + # later bind mount of /data/data onto /data/user/0 will automatically + # propagate to /data_mirror/data_ce/null/0 as well. + mount none /data/user /data_mirror/data_ce/null bind rec mount none /data/user_de /data_mirror/data_de/null bind rec # Create mirror directory for jit profiles