[Bug 2045797] [NEW] use losetup -P instead of kpartx which is racy

Steve Langasek 2045797 at bugs.launchpad.net
Wed Dec 6 18:58:10 UTC 2023


Public bug reported:

[ Impact ]

livefs builds on slow architectures (in particular, riscv64) hit a race
with a high degree of frequency when setting up partition maps for the
loop-mounted disk image, resulting in a build failure because the
partition devices are not available when they need to be.

This race is because 'kpartx -a' invokes kernel APIs that set up the
partition mappings asynchronously, returning when the kernel devices
exist but not blocking waiting on udev to create the device files under
/dev.

In contrast, the newer 'losetup -P' ("--partscan") invokes a syscall
that directly sets up the partitions in the kernel as part of the
loopback device setup and also creates the device nodes on devtmpfs
before returning.

This code has landed in mantic where it has reduced the rate of riscv64
image build failures.

[ Test Plan ]

Unfortunately, since this code landed in mantic, it appears the kernel
may have regressed and made losetup -P itself racy (LP: #2045586).  Also
since it was racy in the first place, a successful build or set of
builds would not be evidence that this issue was fixed.  So the test
plan is restricted to verifying that the autopkgtests pass, and
verifying after publication to -updates that daily images are still
building.

[ Where problems could occur ]

Getting this working in mantic required changes to launchpad's setup of
the build containers wrt /dev mounting.  In the unlikely event that the
behavior of jammy differed from that of mantic within the build
containers, this could cause all jammy livefs builds to fail until
resolved.

** Affects: livecd-rootfs (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to livecd-rootfs in Ubuntu.
https://bugs.launchpad.net/bugs/2045797

Title:
  use losetup -P instead of kpartx which is racy

Status in livecd-rootfs package in Ubuntu:
  New

Bug description:
  [ Impact ]

  livefs builds on slow architectures (in particular, riscv64) hit a
  race with a high degree of frequency when setting up partition maps
  for the loop-mounted disk image, resulting in a build failure because
  the partition devices are not available when they need to be.

  This race is because 'kpartx -a' invokes kernel APIs that set up the
  partition mappings asynchronously, returning when the kernel devices
  exist but not blocking waiting on udev to create the device files
  under /dev.

  In contrast, the newer 'losetup -P' ("--partscan") invokes a syscall
  that directly sets up the partitions in the kernel as part of the
  loopback device setup and also creates the device nodes on devtmpfs
  before returning.

  This code has landed in mantic where it has reduced the rate of
  riscv64 image build failures.

  [ Test Plan ]

  Unfortunately, since this code landed in mantic, it appears the kernel
  may have regressed and made losetup -P itself racy (LP: #2045586).
  Also since it was racy in the first place, a successful build or set
  of builds would not be evidence that this issue was fixed.  So the
  test plan is restricted to verifying that the autopkgtests pass, and
  verifying after publication to -updates that daily images are still
  building.

  [ Where problems could occur ]

  Getting this working in mantic required changes to launchpad's setup
  of the build containers wrt /dev mounting.  In the unlikely event that
  the behavior of jammy differed from that of mantic within the build
  containers, this could cause all jammy livefs builds to fail until
  resolved.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/livecd-rootfs/+bug/2045797/+subscriptions




More information about the foundations-bugs mailing list