summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/partition.py
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-01-19 16:26:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-20 22:46:18 +0000
commit36575a949399953f98fc1cfda4a3dcb5a295b02c (patch)
tree54377cbf928c456b68554e7f0351595caaf262a3 /scripts/lib/wic/partition.py
parentf85a4a1462bc2105f7c62f2b09c1d092c7677ada (diff)
downloadpoky-36575a949399953f98fc1cfda4a3dcb5a295b02c.tar.gz
wic: Copy rootfs dir if fstab needs updating
By default, wic updates the /etc/fstab in the rootfs to include details of additional partitions described in the selected wks file. If this modification is performed in place, other tasks which create an image file from the rootfs directory (e.g. do_image_tar and do_image_ext4) will pick up the modified fstab file which would not be appropriate for those images as they do not include the additional partitions described in the wks file. wic does undo modifications to the fstab file once it has finished creating the filesystem image, however this leaves open a race condition if one of the other tasks reads the contents of the fstab file from the rootfs directory between the point where wic modifies the fstab file and the point where wic restores the files original content. This could be solved by adding a lockfile for tasks which use the rootfs directory to ensure that no other such task is reading the rootfs directory while do_image_wic is running. This would serialize several do_image_* tasks and result in slower builds, especially for large images. Another drawback of this solution is that it is hard to selectively optimise - adding lockfiles to do_image_* tasks would result in these tasks always being serialized even if no fstab modification will take place. An alternative solution is to copy the rootfs directory when fstab needs to be modified. The code to do this in wic already exists as it is needed when including or excluding content in the rootfs. This still results in an impact on build times but the copy uses hardlinks if possible (so little data is actually copied) and we can make selective optimisations to improve things. The rootfs copy will only take place if fstab modification is required (or if it was already needed to include or exclude rootfs content). We can also follow up with further optimisations after this commit. So this second solution is chosen. Fixes [Yocto #13994] (From OE-Core rev: ce682a73b7447652f898ce1d1d0416a456df5416) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r--scripts/lib/wic/partition.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 286c7867cb..f59eceb23d 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -54,6 +54,7 @@ class Partition():
54 self.uuid = args.uuid 54 self.uuid = args.uuid
55 self.fsuuid = args.fsuuid 55 self.fsuuid = args.fsuuid
56 self.type = args.type 56 self.type = args.type
57 self.updated_fstab_path = None
57 58
58 self.lineno = lineno 59 self.lineno = lineno
59 self.source_file = "" 60 self.source_file = ""
@@ -118,11 +119,13 @@ class Partition():
118 return self.fixed_size if self.fixed_size else self.size 119 return self.fixed_size if self.fixed_size else self.size
119 120
120 def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, 121 def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir,
121 bootimg_dir, kernel_dir, native_sysroot): 122 bootimg_dir, kernel_dir, native_sysroot, updated_fstab_path):
122 """ 123 """
123 Prepare content for individual partitions, depending on 124 Prepare content for individual partitions, depending on
124 partition command parameters. 125 partition command parameters.
125 """ 126 """
127 self.updated_fstab_path = updated_fstab_path
128
126 if not self.source: 129 if not self.source:
127 if not self.size and not self.fixed_size: 130 if not self.size and not self.fixed_size:
128 raise WicError("The %s partition has a size of zero. Please " 131 raise WicError("The %s partition has a size of zero. Please "