tools/hotplug: Scan xenstore once when attaching shared images files
authorMike Latimer <mlatimer@suse.com>
Fri, 2 Oct 2015 14:09:32 +0000 (08:09 -0600)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 7 Oct 2015 11:23:51 +0000 (12:23 +0100)
commitd76add5b4bf37dd5083e61cc40734d913cd6553f
tree6ad2cc2147203140f623e2e1407d01bb26d484ea
parent3f9dfe68084a5e15cf8e5ea71e67e73f896e1101
tools/hotplug: Scan xenstore once when attaching shared images files

During the attachment of a loopback mounted image file, the mode of all
curent instances of this device already attached to other domains must be
checked. This requires finding all loopback devices pointing to the inode
of the shared image file, and then comparing the major and minor number of
these devices to the major and minor number of every vbd device found in the
xenstore database.

Prior to this patch, the entire xenstore database is walked for every instance
of every loopback device pointing to the same shared image file. This process
causes the block attachment process to becomes exponentially slower with every
additional attachment of a shared image.

Rather than scanning all of xenstore for every instance of a shared loopback
device, this patch creates a list of the major and minor numbers from all
matching loopback devices. After generating this list, Xenstore is walked
once, and major and minor numbers from every vbd are checked against the list.
If a match is found, the mode of that vbd is checked for compatibility with
the mode of the device being attached.

Signed-off-by: Mike Latimer <mlatimer@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/hotplug/Linux/block