Skip to contentSkip to conversation

boot-directdisk: Fix race condition with bootimg

PATCH In review Jonathan Liu 1 participant 2 messages May 1, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot-directdisk: Fix race condition with bootimg

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.

---
 meta/classes/boot-directdisk.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/boot-directdisk.bbclass +1 -1
index d265485..fcbee8a 100644
@@ -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"
Signature · 1 line
1.8.2.1
#1 lore raw

meta/classes/boot-directdisk.bbclass python do_bootdirectdisk() { · line 100

Quoted 11 lines · Jonathan Liu
meta/classes/boot-directdisk.bbclass +1 -1
index d265485..fcbee8a 100644
@@ -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