public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 0/2] volatile-binds: Mitigate workdir cleanup issues
@ 2024-07-18  6:46 mark.jonas
  2024-07-18  6:46 ` [PATCH 1/2] volatile-binds: Do not create workdir if OverlayFS is disabled mark.jonas
  2024-07-18  6:46 ` [PATCH 2/2] volatile-binds: Remove workdir if OverlayFS fails mark.jonas
  0 siblings, 2 replies; 3+ messages in thread
From: mark.jonas @ 2024-07-18  6:46 UTC (permalink / raw)
  To: openembedded-core
  Cc: bluca, luca.boccassi, matt.hoosier, richard.purdie, mark.jonas,
	Ricardo Simoes

From: Ricardo Simoes <ricardo.simoes@pt.bosch.com>

The recipe `volatile-binds` relies on the `mount-copybind` script
to create volatile mount points. In commit [1], the script was modified
to use OverlayFS as the primary mount strategy. If OverlayFS fails, it
falls back to an old-school bind mount.

To meet the requirements of OverlayFS, the script now unconditionally
creates a workdir. However, the newly created directory is left in
place in case the bind mount strategy is used.

Commit [2] introduced support for avoiding the OverlayFS strategy by
setting the `MOUNT_COPYBIND_AVOID_OVERLAYFS` environment variable.
However, the workdir is unconditionally created.

This patch series addresses both problems. Firstly, it only creates
the workdir if the `MOUNT_COPYBIND_AVOID_OVERLAYFS` variable is not
asserted. Secondly, it unconditionally attempts to remove the workdir
in case a bind mount is done.

[1] b4976f3cf8cd028f165100b67867adb862da4d7f
	volatile-binds: use overlayfs if available

[2] a8e7dca69054798b1c9843a0de889cef3e261c4f
	mount-copybind: add MOUNT_COPYBIND_AVOID_OVERLAYFS env var to
	skip OverlayFS

Ricardo Simoes (2):
  volatile-binds: Do not create workdir if OverlayFS is disabled
  volatile-binds: Remove workdir if OverlayFS fails

 meta/recipes-core/volatile-binds/files/mount-copybind | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] volatile-binds: Do not create workdir if OverlayFS is disabled
  2024-07-18  6:46 [PATCH 0/2] volatile-binds: Mitigate workdir cleanup issues mark.jonas
@ 2024-07-18  6:46 ` mark.jonas
  2024-07-18  6:46 ` [PATCH 2/2] volatile-binds: Remove workdir if OverlayFS fails mark.jonas
  1 sibling, 0 replies; 3+ messages in thread
From: mark.jonas @ 2024-07-18  6:46 UTC (permalink / raw)
  To: openembedded-core
  Cc: bluca, luca.boccassi, matt.hoosier, richard.purdie, mark.jonas,
	Ricardo Simoes

From: Ricardo Simoes <ricardo.simoes@pt.bosch.com>

When the mountpoint parameter is a directory, the mount-copybind will
first try to use OverlayFS. Because of that, it needs to create the
OverlayFS workdir (determined by the overlay_workdir).

But if the environment variable MOUNT_COPYBIND_AVOID_OVERLAYFS is set
to "1", the script uses bind mount. In that case, the overlay_workdir
is useless, leaving the spec parent directory in a dirty state.

This commit changes mount-copybind so that the overlay_workdir is only
created when MOUNT_COPYBIND_AVOID_OVERLAYFS is not set to 1.

Signed-off-by: Ricardo Simoes <ricardo.simoes@pt.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
---
 meta/recipes-core/volatile-binds/files/mount-copybind | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/volatile-binds/files/mount-copybind b/meta/recipes-core/volatile-binds/files/mount-copybind
index ddc4357615..da88d160ee 100755
--- a/meta/recipes-core/volatile-binds/files/mount-copybind
+++ b/meta/recipes-core/volatile-binds/files/mount-copybind
@@ -45,7 +45,9 @@ if [ -d "$mountpoint" ]; then
 
     # Fast version of calculating `dirname ${spec}`/.`basename ${spec}`-work
     overlay_workdir="${spec%/*}/.${spec##*/}-work"
-    mkdir "${overlay_workdir}"
+    if [ "$MOUNT_COPYBIND_AVOID_OVERLAYFS" != 1 ]; then
+        mkdir "${overlay_workdir}"
+    fi
 
     # Try to mount using overlay, which is must faster than copying files.
     # If that fails, fall back to slower copy.
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] volatile-binds: Remove workdir if OverlayFS fails
  2024-07-18  6:46 [PATCH 0/2] volatile-binds: Mitigate workdir cleanup issues mark.jonas
  2024-07-18  6:46 ` [PATCH 1/2] volatile-binds: Do not create workdir if OverlayFS is disabled mark.jonas
@ 2024-07-18  6:46 ` mark.jonas
  1 sibling, 0 replies; 3+ messages in thread
From: mark.jonas @ 2024-07-18  6:46 UTC (permalink / raw)
  To: openembedded-core
  Cc: bluca, luca.boccassi, matt.hoosier, richard.purdie, mark.jonas,
	Ricardo Simoes

From: Ricardo Simoes <ricardo.simoes@pt.bosch.com>

To fulfill OverlayFS workdir requirements, the mount-copybind script
creates a workdir. But if the mount operation fails for any reason,
the workdir is left there.

Then, subsequent runs of mount-copybind will again try to
create the directory and pollute system logs with failed mkdir error
messages.

This commit mitigates the problem by unconditionally removing workdir
if the OverlayFS is not used or fails to run.

Signed-off-by: Ricardo Simoes <ricardo.simoes@pt.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
---
 meta/recipes-core/volatile-binds/files/mount-copybind | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/recipes-core/volatile-binds/files/mount-copybind b/meta/recipes-core/volatile-binds/files/mount-copybind
index da88d160ee..4f373412be 100755
--- a/meta/recipes-core/volatile-binds/files/mount-copybind
+++ b/meta/recipes-core/volatile-binds/files/mount-copybind
@@ -57,6 +57,7 @@ if [ -d "$mountpoint" ]; then
         fi
     fi
     if [ "$MOUNT_COPYBIND_AVOID_OVERLAYFS" = 1 ] || ! mount -t overlay overlay -olowerdir="$mountpoint",upperdir="$spec",workdir="$overlay_workdir""$mountcontext" "$mountpoint" > /dev/null 2>&1; then
+        rm -rf "$overlay_workdir"
 
         if [ "$specdir_existed" != "yes" ]; then
             cp -aPR "$mountpoint"/. "$spec/"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-18  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-18  6:46 [PATCH 0/2] volatile-binds: Mitigate workdir cleanup issues mark.jonas
2024-07-18  6:46 ` [PATCH 1/2] volatile-binds: Do not create workdir if OverlayFS is disabled mark.jonas
2024-07-18  6:46 ` [PATCH 2/2] volatile-binds: Remove workdir if OverlayFS fails mark.jonas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox