public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* Race-free block device opening
@ 2022-04-26 18:12 Demi Marie Obenour
  2022-04-26 18:35 ` Greg Kroah-Hartman
  2022-04-27 13:29 ` James Bottomley
  0 siblings, 2 replies; 6+ messages in thread
From: Demi Marie Obenour @ 2022-04-26 18:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Linux Kernel Mailing List, Linux Block Mailing List,
	Linux Filesystem Mailing List

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

Right now, opening block devices in a race-free way is incredibly hard.
The only reasonable approach I know of is sd_device_new_from_path() +
sd_device_open(), and is only available in systemd git main.  It also
requires waiting on systemd-udev to have processed udev rules, which can
be a bottleneck.  There are better approaches in various special cases,
such as using device-mapper ioctls to check that the device one has
opened still has the name and/or UUID one expects.  However, none of
them works for a plain call to open(2).

A much better approach would be for udev to point its symlinks at
"/dev/disk/by-diskseq/$DISKSEQ" for non-partition disk devices, or at
"/dev/disk/by-diskseq/${DISKSEQ}p${PARTITION}" for partitions.  A
filesystem would then be mounted at "/dev/disk/by-diskseq" that provides
for race-free opening of these paths.  This could be implemented in
userspace using FUSE, either with difficulty using the current kernel
API, or easily and efficiently using a new kernel API for opening a
block device by diskseq + partition.  However, I think this should be
handled by the Linux kernel itself.

What would be necessary to get this into the kernel?  I would like to
implement this, but I don’t have the time to do so anytime soon.  Is
anyone else interested in taking this on?  I suspect the kernel code
needed to implement this would be quite a bit smaller than the FUSE
implementation.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-07 11:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-26 18:12 Race-free block device opening Demi Marie Obenour
2022-04-26 18:35 ` Greg Kroah-Hartman
2022-04-26 21:31   ` Demi Marie Obenour
2022-04-26 22:07     ` Demi Marie Obenour
2022-04-27 13:29 ` James Bottomley
2022-05-07 11:35   ` Demi Marie Obenour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox