New partition on loop device doesn't appear in /dev anymore with kernel 5.17.0 and newer (repro script included)

From: Michael Schaller
Date: Fri Jun 03 2022 - 08:47:33 EST


Dear maintainer,

Since kernel 5.17.0 it appears that creating a partition on a loop
device doesn't automatically create the corresponding /dev/loop#p#
entry anymore. We rolled back to kernel 5.16.18, which doesn't have
this issue. I also tested kernel 5.18.1 and it is affected as well.

I've attached repro.sh, which is a Bash script that reproduces the
issue (tested on Debian testing). The script only requires standard
Linux tools (including GNU Parted). The script creates a raw disk
image file (sparse), associates the file with a loop device and
partitions the loop device so that it only contains an ESP. At this
point there should be a /dev/loop#p1 entry so that the following
mkfs.vfat can create the filesystem for the ESP. However on kernel
5.17.0 and newer /dev/loop#p1 isn't created and mkfs.vfat fails with
"No such file or directory". Furthermore on kernel 5.17.0 and newer we
see the following error in the kernel log: "I/O error, dev loop#,
sector 32640 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0"

I also did a kernel bisect against the vanilla stable kernels and that
revealed commit 1ebe2e5f9d68e94c524aba876f27b945669a7879 as the first
problematic commit. I've cc'ed the commit author as well.

This issue is also tracked on the Debian side with
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012298.

Best,

Michael Schaller
Site Reliability Engineer - Software Engineer
misch@xxxxxxxxxx

Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Attachment: repro.sh
Description: application/shellscript