From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6631790376260730880 X-Received: by 2002:a1c:860f:: with SMTP id i15mr219932wmd.24.1544181528251; Fri, 07 Dec 2018 03:18:48 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:94a6:: with SMTP id 35ls297798wrr.15.gmail; Fri, 07 Dec 2018 03:18:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/UFOVdZdkzo4L5pyBunYTYqWwhFZXW8Hho+3hGvHI9ilFTyxjmmar3jPekFgOT0s0GuP1J7 X-Received: by 2002:adf:dd08:: with SMTP id a8mr132483wrm.13.1544181527827; Fri, 07 Dec 2018 03:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544181527; cv=none; d=google.com; s=arc-20160816; b=pKuyQ4BG5m0UBjdkYN6g44XhtH6f519R1LM9Z7nnReNsmJia87ilspp3dhUnYbwWxA xCVZtaMlkhoZsW69ct7h5N0bfUYKrQWIivLD9mFE8jSQNeyK8KzXywWWGlBr6/gyYEY8 q8dBi6m8BtgbmJsd3N1pmKFZWGOPL5vuCEIOCP9EYZy96zoK/Fq2B9w5Or8ScJ62fRqw JGlhHu03/WskqteeV5rqEZ6jNtZPXwoZHDOgJJaJ/SZCLJ0FW/RX3+daciHVzzJG033b qFI7A4AC2Hhhq985HVR77yPtEKk2u23vGVNndnl17FjlvGci7Zy/TzKFpiPtNjsx5nRT p24g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:cc:to :subject; bh=bydSIynGaZth/2sy5TSWePmmYxX6QTx+2eQwV9EW0E8=; b=GMBDvXrvP9lDwxVh+/IFlNITqe4o2aavTo7G1RKoxiBZlKKzA03bbFWzM4Uw1riP80 yrOJe5c/UTKsp/X3/eeUvrGxECJbn7O0FdTjnMWiPiwwGw4IlEJ0YGUvOINN0AyKA3LQ TRnFV3hVI2smIPOG8T8Ogo+Npq7iYuf3Hm1UjVMiRUdi/OENa2MY83Ws+W5eooO4SbXY BPhUgO3reyzDBzbBuETAyFv3zM5ufXTmD4pUh/nL81PWqtVua0ibcwOoymLqxzO6eSYn KE2rIwC3PVnDV0LKfOIFyf81C37ir8xOUiqJ3604pperrIUqOU++y13r8K8rSuGtTROl /v6A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id k39si128027wre.2.2018.12.07.03.18.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 03:18:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.180] (nat-ppp-217.71.235.199-satnet-spb.ru [217.71.235.199] (may be forged)) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id wB7BIigS003977 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Fri, 7 Dec 2018 12:18:46 +0100 Subject: Re: [PATCH] wic-img: Fix bind mounting To: Jan Kiszka , isar-users Cc: Henning Schild , Cedric Hombourger References: From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: <2c2a8362-185d-5009-c1ad-716b3cd88749@ilbers.de> Date: Fri, 7 Dec 2018 14:18:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TUID: sJA2XLn5tgN2 Hi Jan, On 12/6/18 2:17 PM, Jan Kiszka wrote: > On 06.12.18 10:44, Maxim Yu. Osipov wrote: >> Just to doublecheck: What is your patch queue for that? >> > > Just updated jan/queue on github.com/siemens/isar. It's not the best > ordering of patches, this fix should probably come earlier, but the top > is what I tested successfully also in a stretch VM. I'm convinced that this patch fixes these two issues. CI passes OK on my stretch laptop. It fails on isar-build.org by evident reason (CI runs in stretch chroot on jessie host - the host's kernel 3.16 has troubles with 'mount --rbind'). We are now upgrading the host system. When applying to the 'next' I may rearrange the ordering of patches in more logical path git log --oneline: c46ad1b isar-image: Make do_rootfs normal shell function 05d0fc4 isar-events: Improve umount handler 93c4795 ci: Make partial rebuild test non-destructive 4ca0bff ci: Wait for bitbake worker to finish before deleting artifacts 698fb56 Remove redundant recursive umounts bbc61fb wic-img: Fix bind mounting 9cf29e6 isar-bootstrap: Fix and cleanup bind mounting b354026 isar-image: umount base-apt when doing offline build e965c0d gitlab-ci: Switch to ci_build.sh is it OK? Maxim. > Jan > >> On 12/6/18 11:13 AM, Jan Kiszka wrote: >>> >>> This addresses two issues of the current code: >>> >>>   - we must make the bind mount of STAGING_DIR private because it will >>>     otherwise pick up bind mounts done underneath it in the various >>>     rootfs used by parallel targets >>> >>>   - locking was missing to make check and mount atomic, just like we do >>>     inside buildchroot_do_mounts >>> >>> Signed-off-by: Jan Kiszka >>> --- >>> >>> My theory on what went wrong /wrt rbind-mounted /sys and /dev: As the >>> bind-mounting of STAGING_DIR of a wic target (qemu-amd64) eventually >>> started to contain shared(!) bind-mounts of parallel targets (qemu- >>> armhf, qemu-arm64), and all those stick to the end, isar_handler started >>> to umount their now also shared /dev and /sys mounts. And that >>> destroyed the host mounts. >>> >>> Lesson to be recalled: never paper over issues that were not yet fully >>> understood. They may point to sleeping problems that will only bite you >>> again later. >>> >>>   meta/classes/wic-img.bbclass | 13 ++++++++----- >>>   1 file changed, 8 insertions(+), 5 deletions(-) >>> >>> diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass >>> index 225463e..76602d8 100644 >>> --- a/meta/classes/wic-img.bbclass >>> +++ b/meta/classes/wic-img.bbclass >>> @@ -87,11 +87,14 @@ do_build[stamp-extra-info] = >>> "${DISTRO}-${DISTRO_ARCH}" >>>   do_wic_image() { >>>       buildchroot_do_mounts >>> -    for dir in ${BBLAYERS} ${STAGING_DIR} ${ISARROOT}/scripts; do >>> -    sudo mkdir -p ${BUILDCHROOT_DIR}/$dir >>> -        mountpoint ${BUILDCHROOT_DIR}/$dir >/dev/null 2>&1 \ >>> -        || sudo mount --bind $dir ${BUILDCHROOT_DIR}/$dir >>> -    done >>> +    sudo flock ${MOUNT_LOCKFILE} -c ' \ >>> +        for dir in ${BBLAYERS} ${STAGING_DIR} ${ISARROOT}/scripts; do >>> +            mkdir -p ${BUILDCHROOT_DIR}/$dir >>> +            if ! mountpoint ${BUILDCHROOT_DIR}/$dir >/dev/null 2>&1; >>> then >>> +                mount --bind --make-private $dir >>> ${BUILDCHROOT_DIR}/$dir >>> +            fi >>> +        done >>> +        ' >>>       export FAKEROOTCMD=${FAKEROOTCMD} >>>       export BUILDDIR=${BUILDDIR} >>>       export MTOOLS_SKIP_CHECK=1 >>> >> >> > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov