Improve workaround for do_image_wic race condition 84/25884/3
authorPaul Barker <pbarker@konsulko.com>
Mon, 11 Jan 2021 17:25:18 +0000 (17:25 +0000)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 12 Jan 2021 15:40:31 +0000 (15:40 +0000)
This change ensures that no other do_image_* task can be running and
reading the rootfs directory at the same time as do_image_wic is
modifying the /etc/fstab file in the rootfs directory. It can be
removed when the more efficient but more complex fix is accepted
and backported upstream in poky.

Further details are given in the new image_types_wic_workaround.bbclass
file.

This allows us to remove the previous workaround of running wic with the
`--no-fstab-update` argument and so the fstab file in wic images will
now include all partitions.

Bug-AGL: SPEC-3621

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Change-Id: Ibdbed7164c8684f50e917b5c877508d8c968d73b
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/25884
Tested-by: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
ci-image-build: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
ci-image-boot-test: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
meta-agl-core/classes/image_types_wic_workaround.bbclass [new file with mode: 0644]
meta-agl-core/conf/distro/poky-agl.conf

diff --git a/meta-agl-core/classes/image_types_wic_workaround.bbclass b/meta-agl-core/classes/image_types_wic_workaround.bbclass
new file mode 100644 (file)
index 0000000..a6ea058
--- /dev/null
@@ -0,0 +1,32 @@
+# This is a workaround for the race condition between do_image_wic and other
+# do_image_* tasks. It ensures that no other do_image_* task can be running and
+# reading the rootfs directory at the same time as do_image_wic is modifying
+# the /etc/fstab file in the rootfs directory.
+#
+# A much better fix has been submitted upstream [1], but we can't carry those
+# modifications to `scripts/lib/wic` from poky easily in meta-agl. So instead
+# we have this workaround until the upstream fix is accepted and backported.
+#
+# Serializing the image functions as done here impacts build speed but it's
+# better to be slow and correct than to be fast and wrong.
+#
+# [1]: https://lists.openembedded.org/g/openembedded-core/topic/patch_5_6_wic_copy_rootfs/79592787,
+#      https://lists.openembedded.org/g/openembedded-core/topic/patch_6_6_wic_optimise/79592788
+#      and related patches.
+#
+# Bug-AGL: SPEC-3621
+
+def get_workaround_wic_typedeps(d):
+    if d.getVar('USING_WIC'):
+        fstypes = d.getVar('IMAGE_FSTYPES').split()
+        basetypes = set()
+        for fs in fstypes:
+            # Add the basetype to our set of basetypes in use
+            t = fs.split('.')[0]
+            if t != "wic":
+                basetypes.add(t)
+        return ' '.join(basetypes)
+    else:
+        return ''
+
+IMAGE_TYPEDEP_wic += "${@get_workaround_wic_typedeps(d)}"
index 6d25af9..f2b6221 100644 (file)
@@ -203,6 +203,4 @@ BBMASK += "meta-security/recipes-kernel/linux/linux-%_5.%.bbappend"
 # do_image_tar and do_image_ext4 can run in parallel
 # This needs to be fixed upstream:
 # See https://bugzilla.yoctoproject.org/show_bug.cgi?id=13994
-# For convenience restricted to ext4 and tar image types.
-AGL_FORBID_FSTAB_UPDATE ?= "${@bb.utils.contains_any('IMAGE_FSTYPES', 'ext4 ext4.xz tar tar.gz tar.bz2 tar.xz', '--no-fstab-update', '', d)}"
-WIC_CREATE_EXTRA_ARGS_append = " ${AGL_FORBID_FSTAB_UPDATE}"
+INHERIT += "image_types_wic_workaround"