Skip to content

RFC Fix API breakage in libblkid

[email protected] util-linux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Revert "libblkid: add debug message for private DM device skip"libblkid/src/probe.c+1 -40 replies
2/2Revert "libblkid: check for private DM device before open"libblkid/src/probe.c+1 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/2] Fix API breakage in libblkid

From: Carlos Maiolino <[email protected]>

Patch d05a84b22e54 ("libblkid: check for private DM device before open") broke blkid_new_probe_from_filename() API.

Before the patch users were able, via the low-level API, to open and create blkid probes via the device's filename even from private device-mapper devices.

This change broke Stratis project and xfsprogs.
xfsprogs uses blkid_new_probe_from_filename() to gather topology information from the device, and the above mentioned change now prevents it to be done on device-mapper private devices, as Stratis does by attempting to initialize a XFS filesystem on it.

Quoting the patch description:

"
blkid_new_probe_from_filename() opens the device before calling blkid_probe_set_device(), which checks sysfs_devno_is_dm_private() and sets BLKID_FL_NOSCAN_DEV. But the open() itself bumps the kernel open count, so a concurrent DM_DEVICE_REMOVE ioctl sees EBUSY even though blkid never actually probes the device.
"

I don't think the last statement here is correct. blkid_probe_set_device() marks the probe as BLKID_FL_NOSCAN_DEV, but it does not error out, so, for low-level API calls, we simply ended up with a probe with BLKID_FL_NOSCAN_DEV set. But the call succeeded and we ended up with a probe to use and query device's information.

As far as I understood it, the patch aimed to close a possible race window when issuing a DM_DEVICE_REMOVE ioctl() to the same device being probed by blkid_new_probe_from_filename().

Regarding the race window which this patch, at least for the low-level API users, this seems to be something that should be dealt in the user's side, not within the library. But I didn't dig into the details of the aforementioned race.

Please take the above with a grain of salt though, we've been using libblkid for ages, but I never actually looked into the implementation until today, so, hopefully I did get the details right.

As for xfsprogs, I have a patch which 'fixes' it replacing blkid_new_probe_from_filename() by blkid_probe_set_device(), but this is just taping over the root cause, which is the API breakage.

Carlos Maiolino (2):
Revert "libblkid: add debug message for private DM device skip" Revert "libblkid: check for private DM device before open"

 libblkid/src/probe.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
Signature · 1 line
2.53.0