Patchwork boot-directdisk: Fix race condition with bootimg

login
register
mail settings
Submitter Jonathan Liu
Date May 1, 2013, 2:22 p.m.
Message ID <1367418158-28751-1-git-send-email-net147@gmail.com>
Download mbox | patch
Permalink /patch/49217/
State Not Applicable, archived
Headers show

Comments

Jonathan Liu - May 1, 2013, 2:22 p.m.
If "vmdk" is added to IMAGE_FSTYPES when building core-image-minimal,
there is a race condition where the bootdirectdisk and bootimg tasks
may execute concurrently. The bootdirectdisk task is copying the
contents of ${HDDDIR} into ${HDDIMG} but at the same time, the bootimg
task is writing to ${HDDDIR}/rootfs.img.

This race condition can result in one of the following errors:
- An hdddirect image is created with an incomplete rootfs.img
  (the bootimg task may not have finished writing to rootfs.img yet).
  This would result in an invalid operation error when /init in initrd
  tries to loopback mount rootfs.img to /rootfs.
- A "Disk full" error is generated in the bootdirectdisk task
  because it calculates the number of blocks for the image before
  rootfs.img is written but by the time is gets to copying the contents
  of ${HDDDIR} into ${HDDIMG}, the writing of ${HDDDIR}/rootfs.img by
  the bootimg task results in the size of ${HDDDIR} exceeding the
  initially calculated number of blocks for the image.

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 meta/classes/boot-directdisk.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Jonathan Liu - May 1, 2013, 3:22 p.m.
On 2/05/2013 12:22 AM, Jonathan Liu wrote:
> diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass
> index d265485..fcbee8a 100644
> --- a/meta/classes/boot-directdisk.bbclass
> +++ b/meta/classes/boot-directdisk.bbclass
> @@ -96,5 +96,5 @@ python do_bootdirectdisk() {
>       bb.build.exec_func('build_boot_dd', d)
>   }
>   
> -addtask bootdirectdisk before do_build
> +addtask bootdirectdisk after do_bootimg before do_build
>   do_bootdirectdisk[nostamp] = "1"
The strange thing is, it seems the generated .hdddirect has two copies 
of the root filesystem - one in rootfs.img in the fat partition, and one 
as an ext3 partition.
So maybe there is another conflict with bootimg that needs to be considered.

Regards,
Jonathan

Patch

diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass
index d265485..fcbee8a 100644
--- a/meta/classes/boot-directdisk.bbclass
+++ b/meta/classes/boot-directdisk.bbclass
@@ -96,5 +96,5 @@  python do_bootdirectdisk() {
     bb.build.exec_func('build_boot_dd', d)
 }
 
-addtask bootdirectdisk before do_build
+addtask bootdirectdisk after do_bootimg before do_build
 do_bootdirectdisk[nostamp] = "1"