public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: Felix Moessbauer <felix.moessbauer@siemens.com>
Cc: <isar-users@googlegroups.com>, <jan.kiszka@siemens.com>
Subject: Re: [PATCH 4/4] split rootfs finalization and unmounting into two tasks
Date: Wed, 22 Sep 2021 17:23:45 +0200	[thread overview]
Message-ID: <20210922172345.62839267@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <20210922092754.3649703-5-felix.moessbauer@siemens.com>

That split is nice. But i would try and run it always after in a catch
block, not in another task.
That way it will become more robust while not having to touch the
task-chain ... which is not nice for layers that hook in "low".

I would not hold this one back for a series of "improved mounting" ...
divide and conquer! If it fixes an issue it is valid, only if you have
the time to do a full "mount rework" i would hold it back.

Henning

Am Wed, 22 Sep 2021 11:27:54 +0200
schrieb Felix Moessbauer <felix.moessbauer@siemens.com>:

> This patch separates the unmounting logic from do_rootfs_finalize
> to inject tasks in between. By that, the do_wic_image tasks can
> use the mount-points and finally everything is unmounted correctly.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  meta/classes/image.bbclass   | 49
> +++++++++++++++++++++++++----------- meta/classes/wic-img.bbclass |
> 4 +-- 2 files changed, 36 insertions(+), 17 deletions(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 1f39690..988f0d7 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -190,21 +190,6 @@ do_rootfs_finalize() {
>              find "${ROOTFSDIR}/usr/bin" \
>                  -maxdepth 1 -name 'qemu-*-static' -type f -delete
>  
> -        mountpoint -q '${ROOTFSDIR}/isar-apt' && \
> -            umount -l ${ROOTFSDIR}/isar-apt
> -        rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
> -
> -        mountpoint -q '${ROOTFSDIR}/base-apt' && \
> -            umount -l ${ROOTFSDIR}/base-apt
> -        rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
> -
> -        mountpoint -q '${ROOTFSDIR}/dev' && \
> -            umount -l ${ROOTFSDIR}/dev
> -        mountpoint -q '${ROOTFSDIR}/proc' && \
> -            umount -l ${ROOTFSDIR}/proc
> -        mountpoint -q '${ROOTFSDIR}/sys' && \
> -            umount -l ${ROOTFSDIR}/sys
> -
>          rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
>  
>          rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
> @@ -219,5 +204,39 @@ EOSUDO
>  }
>  addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
>  
> +do_rootfs_unmount() {
> +    sudo -s <<'EOSUDO'
> +        ret=0
> +        if mountpoint -q '${ROOTFSDIR}/isar-apt'; then
> +            umount -vl ${ROOTFSDIR}/isar-apt || ret=1
> +        fi
> +        if test -d ${ROOTFSDIR}/isar-apt; then
> +            rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
> || ret=1
> +        fi
> +
> +        if mountpoint -q ${ROOTFSDIR}/base-apt; then
> +            umount -vl ${ROOTFSDIR}/base-apt || ret=1
> +        fi
> +        if test -d ${ROOTFSDIR}/base-apt; then
> +            rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
> || ret=1
> +        fi
> +
> +        if mountpoint -q ${ROOTFSDIR}/dev; then
> +            umount -vl ${ROOTFSDIR}/dev || ret=1
> +        fi
> +        if mountpoint -q ${ROOTFSDIR}/proc; then
> +            umount -vl ${ROOTFSDIR}/proc || ret=1
> +        fi
> +        if mountpoint -q '${ROOTFSDIR}/sys'; then
> +            umount -vl ${ROOTFSDIR}/sys || ret=1
> +        fi
> +
> +        if [$ret -ne 0]; then
> +            bbwarn "could not unmount all mountpoints"
> +        fi
> +EOSUDO
> +}
> +addtask rootfs_unmount before do_build after do_rootfs_finalize
> +
>  # Last so that the image type can overwrite tasks if needed
>  inherit ${IMAGE_TYPE}
> diff --git a/meta/classes/wic-img.bbclass
> b/meta/classes/wic-img.bbclass index 573537c..0f5932b 100644
> --- a/meta/classes/wic-img.bbclass
> +++ b/meta/classes/wic-img.bbclass
> @@ -142,12 +142,12 @@ python do_wic_image() {
>      bb.build.exec_func("wic_do_mounts", d)
>      try:
>          bb.build.exec_func("generate_wic_image", d)
> -        bb.build.exec_func("check_for_wic_warnings", d)
>      finally:
>          bb.build.exec_func("wic_undo_mounts", d)
>          bb.utils.unlockfile(lock)
> +    bb.build.exec_func("check_for_wic_warnings", d)
>  }
> -addtask wic_image before do_image after do_image_tools
> do_rootfs_finalize +addtask wic_image before do_image
> do_rootfs_unmount after do_image_tools 
>  wic_do_mounts() {
>      buildchroot_do_mounts


      reply	other threads:[~2021-09-22 15:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  9:27 [PATCH 0/4] Fix sporadic failures in do_wic_image Felix Moessbauer
2021-09-22  9:27 ` [PATCH 1/4] fix typo in do_rootfs_finalize Felix Moessbauer
2021-09-22 15:02   ` Henning Schild
2021-09-22  9:27 ` [PATCH 2/4] execute do_wic_image under a lock to ensure mountpoints remain mounted Felix Moessbauer
2021-09-22 15:04   ` Henning Schild
2021-09-22  9:27 ` [PATCH 3/4] fix race by serialize rootfs_finalize and do_wic_image Felix Moessbauer
2021-09-22 15:15   ` Henning Schild
2021-09-23  8:39     ` Moessbauer, Felix
2021-09-22  9:27 ` [PATCH 4/4] split rootfs finalization and unmounting into two tasks Felix Moessbauer
2021-09-22 15:23   ` Henning Schild [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210922172345.62839267@md1za8fc.ad001.siemens.net \
    --to=henning.schild@siemens.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox