[systemd-devel] How to stop systemd-udevd reading a device after dd

Andrei Borzenkov arvidjaar at gmail.com
Mon Nov 13 04:02:09 UTC 2017


24.10.2017 11:33, Lennart Poettering пишет:
> 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.
> 

How do you take exclusive lock on device that does not even exist yet
(like in case of dmsetup create)?



More information about the systemd-devel mailing list