From: Matthew Dillon Date: Sun, 18 Mar 2018 19:26:17 +0000 (-0700) Subject: dm - synchronize disk info before returning X-Git-Tag: v5.3.0~57 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/8a5197dde90812c26b015b39b499a424148e6029 dm - synchronize disk info before returning * DM now issues a disk_config(NULL) after setting up the disk info in order to wait for the probe to complete, otherwise callers may race trying to open() the disk device before it is actually ready. * Fixes cryptsetup luksOpen errors which occur due to probe races, typically when used in a VM or qemu. Reported-by: Aaron LI --- diff --git a/sys/dev/disk/dm/device-mapper.c b/sys/dev/disk/dm/device-mapper.c index 6a15d99226..c51ce9948f 100644 --- a/sys/dev/disk/dm/device-mapper.c +++ b/sys/dev/disk/dm/device-mapper.c @@ -584,7 +584,12 @@ dmsetdiskinfo(struct disk *disk, dm_table_head_t *head) info.d_secpercyl = info.d_secpertrack * info.d_nheads; info.d_ncylinders = dmp_size / info.d_secpercyl; + /* + * The probe is asynchronous so call disk_config() to + * wait for it to complete. + */ disk_setdiskinfo(disk, &info); + disk_config(NULL); } /*