dm init: add dm-mod.waitfor to wait for asynchronously probed block devices
Subsystems (2)
PATCH 1/1 dm init: add dm-mod.waitfor to wait for asynchronously probed block devices
Just calling wait_for_device_probe() is not enough to ensure that asynchronously probed block devices are available (E.G. mmc, usb, ..), so add a "dm-mod.waitfor=<device1>[,..,<deviceN>]" parameter to get dm-init to explicitly wait for specific block devices before initializing the tables with logic similar to the rootwait logic in init/do_mounts.c.
E.G. with dm-verity on mmc with dm-mod.waitfor="PARTLABEL=hash-a,PARTLABEL=root-a"
[ 0.671671] device-mapper: init: waiting for all devices to be available before creating mapped devices [ 0.671679] device-mapper: init: waiting for PARTLABEL=hash-a [ 0.710695] mmc0: new HS200 MMC card at address 0001 [ 0.711158] mmcblk0: mmc0:0001 004GA0 3.69 GiB [ 0.715954] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB [ 0.722085] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB [ 0.728093] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev (249:0) [ 0.738274] mmcblk0: p1 p2 p3 p4 p5 p6 p7 [ 0.751282] device-mapper: init: waiting for PARTLABEL=root-a [ 0.751306] device-mapper: init: all devices available [ 0.751683] device-mapper: verity: sha256 using implementation "sha256-generic" [ 0.759344] device-mapper: ioctl: dm-0 (vroot) is ready [ 0.766540] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.
--- .../admin-guide/device-mapper/dm-init.rst | 9 ++++++++ drivers/md/dm-init.c | 23 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)
Documentation/admin-guide/device-mapper/dm-init.rst +9 -0
@@ -123,3 +123,12 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +For setups using device-mapper on top of asynchronously probed block +devices (MMC, USB, ..), it may be necessary to tell dm-init to +explicitly wait for them to become available before setting up the +device-mapper tables. This can be done with the "dm-init.waitfor=" +module parameter, which takes a list of devices to wait for:: + + dm-init.waitfor=<device1>[,..,<deviceN>] +
drivers/md/dm-init.c +22 -1
@@ -8,6 +8,7 @@*/ #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h>
@@ -18,12 +19,17 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_MAX_WAITFOR 256static char *create; +static char *waitfor[DM_MAX_WAITFOR ]; +/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+] * Table format: <start_sector> <num_sectors> <target_type> <target_args> +* Block devices to wait for to become available before setting up tables: +* dm-mod.waitfor=<device1>[,..,<deviceN>] * * See Documentation/admin-guide/device-mapper/dm-init.rst for dm-mod.create="..." format * details.
@@ -266,7 +272,7 @@ static int __init dm_init_init(void)struct dm_device *dev;LIST_HEAD (devices);char *str; -int r; +int i, r;if (!create)return 0 ;
@@ -286,6 +292,18 @@ static int __init dm_init_init(void)DMINFO ("waiting for all devices to be available before creating mapped devices" );wait_for_device_probe (); +for (i =0 ; i <ARRAY_SIZE (waitfor); i++) { +if (waitfor[i]) { +DMINFO ("waiting for %s" , waitfor[i]); + +while (!dm_get_dev_t (waitfor[i])) +msleep (20 ); + } + } + +if (waitfor[0 ]) +DMINFO ("all devices available" ); +list_for_each_entry (dev, &devices, list) {if (dm_early_create (&dev->dmi, dev->table, dev->target_args_array))
@@ -301,3 +319,6 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); + +module_param_array (waitfor, charp,NULL ,0 ); +MODULE_PARM_DESC (waitfor,"Devices to wait for before setting up tables" );
Signature · 6 lines
2.30.2 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 38 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Just calling
wait_for_device_probe()is not enough to ensure that asynchronously probed block devices are available (E.G. mmc, usb, ..), so add a "dm-mod.waitfor=<device1>[,..,<deviceN>]" parameter to get dm-init to explicitly wait for specific block devices before initializing the tables with logic similar to the rootwait logic ininit/do_mounts.c.E.G. with dm-verity on mmc with dm-mod.waitfor="PARTLABEL=hash-a,PARTLABEL=root-a"
[ 0.671671] device-mapper: init: waiting for all devices to be available before creating mapped devices [ 0.671679] device-mapper: init: waiting for PARTLABEL=hash-a [ 0.710695] mmc0: new HS200 MMC card at address 0001 [ 0.711158] mmcblk0: mmc0:0001 004GA0 3.69 GiB [ 0.715954] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB [ 0.722085] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB [ 0.728093] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev (249:0) [ 0.738274] mmcblk0: p1 p2 p3 p4 p5 p6 p7 [ 0.751282] device-mapper: init: waiting for PARTLABEL=root-a [ 0.751306] device-mapper: init: all devices available [ 0.751683] device-mapper: verity: sha256 using implementation "sha256-generic" [ 0.759344] device-mapper: ioctl: dm-0 (vroot) is ready [ 0.766540] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.Signed-off-by Peter Korsgaard <[email protected]>--- .../admin-guide/device-mapper/dm-init.rst | 9 ++++++++ drivers/md/dm-init.c | 23 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-)Documentation/admin-guide/device-mapper/dm-init.rst +0
-0@@ -123,3 +123,12 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd
Documentation/admin-guide/device-mapper/dm-init.rst Other examples (per target): · line 134
Quoted 10 lines
Documentation/admin-guide/device-mapper/dm-init.rst +9
-051934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +For setups using device-mapper on top of asynchronously probed block +devices (MMC, USB, ..), it may be necessary to tell dm-init to +explicitly wait for them to become available before setting up the +device-mapper tables. This can be done with the "dm-init.waitfor=" +module parameter, which takes a list of devices to wait for:: + + dm-init.waitfor=<device1>[,..,<deviceN>] +
Ups, the trailing newline should be dropped. Can you do this when applying or do you want me to resend?
Signature · 6 lines
Bye, Peter Korsgaard -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel