[systemd-devel] How to stop systemd-udevd reading a device after dd
Lennart Poettering
lennart at poettering.net
Tue Oct 24 08:33:15 UTC 2017
On Fr, 13.10.17 01:01, Akira Hayakawa (ruby.wktk at gmail.com) wrote:
> I have a device /dev/sdb1 and let's trace the block request by blktrace
>
> $ sudo blktrace -d /dev/sdb1
>
> When I write 4KB using dd
> $ sudo dd if=/dev/zero of=/dev/sdb1 oflag=direct bs=4k count=1
>
> The block trace (after blkparsed) is write request as expected
> 8,17 2 2 0.000003171 5930 Q WS 2048 + 8 [dd]
>
> followed by a unexpected read from systemd-udevd
> 8,17 7 2 0.001755563 5931 Q R 2048 + 8 [systemd-udevd]
>
> My first question is what is: this read request?
>
> And I want to stop the read request because it makes it difficult to test kernel code.
> So the second question is: how can I stop the read request?
If you want exclusive access to a block device and don't want udev to
step in, then simply take a BSD file lock on it (i.e. flock(2)), and
udev won't probe it.
This is not particularly well documented (one could say: not at all),
but it's the official way really, and very UNIXish I'd claim.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list