Speed up udev-block-add-change by not using xenstore

xenstore-ls is incredibly slow, while reading sysfs is much faster
pull/24/head mm_4d08ff40
qubesuser 7 years ago
parent 19cb61a0ed
commit 4d08ff40a9

@ -49,21 +49,20 @@ refresh_another() {
env -i PATH=$PATH $launch_env $0
}
# communicate with xenstored through socket in dom0
# trying to access xenstore before xenstored is started, hang forever (in
# non-killable state), so better fail ('-s' in VM if /proc/xen isn't mounted
# yet) than hang dom0 boot
if [ ! -r /proc/xen/capabilities ] || grep -q control_d /proc/xen/capabilities; then
XENSTORE_LS="xenstore-ls -s"
else
XENSTORE_LS="xenstore-ls"
fi
is_attached() {
dev_hex=$(stat -c %t:%T /dev/$(basename $1))
if [ -z "$dev_hex" -o "$dev_hex" = "0:0" ]; then
return 1
fi
$XENSTORE_LS backend/vbd | grep -q "physical-device = \"$dev_hex\""
# looking at sysfs is much faster than looking at xenstore
# this code requires no subprocesses and doesn't hit argument length limitations
for i in /sys/bus/xen-backend/drivers/vbd/vbd-*/physical_device; do
read i_dev_hex < "$i"
if test "$i_dev_hex" == "$dev_hex"; then
return 0
fi
done
return 1
}
# update info about parent devices, if any:

Loading…
Cancel
Save