udev: add locking on block device processing

xenstored does handle concurrent writes very harshly - it aborts the
whole transaction if any other write happened the same time. For udev
(which process all the events almost at once) it means hundreds of
retries and in some times even exceed udev timeout (60s or so).
To prevent this problem, add locking to allow only one such event being
processed at once. It looks like it should slow down the system startup,
but actually it does otherwise.
This commit is contained in:
Marek Marczykowski-Górecki 2014-01-13 05:01:56 +01:00
parent e2c481516e
commit b51435c903

View File

@ -10,8 +10,8 @@ ENV{MAJOR}=="202", GOTO="qubes_block_end"
ENV{MAJOR}=="253", GOTO="qubes_block_end"
IMPORT{db}="QUBES_EXPOSED"
ACTION=="add", IMPORT{program}="/usr/libexec/qubes/udev-block-add-change"
ACTION=="change", IMPORT{program}="/usr/libexec/qubes/udev-block-add-change"
ACTION=="add", IMPORT{program}="/usr/bin/flock /var/run/qubes-udev.lock -c /usr/libexec/qubes/udev-block-add-change"
ACTION=="change", IMPORT{program}="/usr/bin/flock /var/run/qubes-udev.lock -c /usr/libexec/qubes/udev-block-add-change"
ACTION=="remove", RUN+="/usr/libexec/qubes/udev-block-remove"
LABEL="qubes_block_end"