md: dm-init: Wait devices if it's not find on first adpet
Subsystems (2)
PATCH v3 1/1 md: dm-init: Wait devices if it's not find on first adpet
From: Michael Trimarchi <[email protected]>
The device driver can be deferrable and can be a race during the dm-init early. We need to wait all the probe are really finished in a loop as is done in do_mounts. This is was tested on kernel 5.4 but code seems was not changed since that time
003: imx8mq-usb-phy 381f0040.usb-phy: 381f0040.usb-phy supply vbus not found, using dummy regulator 003: imx8mq-usb-phy 382f0040.usb-phy: 382f0040.usb-phy supply vbus not found, using dummy regulator 003: imx-cpufreq-dt imx-cpufreq-dt: cpu speed grade 5 mkt segment 0 supported-hw 0x20 0x1 003: caam-dma caam-dma: caam dma support with 2 job rings
000: hctosys: unable to open rtc device (rtc0)
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
002: crng init done
003: of_cfs_init
003: of_cfs_init: OK
003: Waiting for root device /dev/dm-0...
001: mmc2: new HS400 Enhanced strobe MMC card at address 0001
001: mmcblk2: mmc2:0001 IB2916 14.6 GiB
001: mmcblk2boot0: mmc2:0001 IB2916 partition 1 4.00 MiB
001: mmcblk2boot1: mmc2:0001 IB2916 partition 2 4.00 MiB
001: mmcblk2rpmb: mmc2:0001 IB2916 partition 3 4.00 MiB, chardev (249:0)
001: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
001: VSD_3V3: disabling
with the patch
003: device-mapper: init: waiting for all devices to be available before creating mapped devices
000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: crng init done
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: table: 254:0: verity: Data device lookup failed
003: device-mapper: ioctl: error adding target to table
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
003: mmc2: new HS400 Enhanced strobe MMC card at address 0001
003: mmcblk2: mmc2:0001 DG4016 14.7 GiB
003: mmcblk2boot0: mmc2:0001 DG4016 partition 1 4.00 MiB
003: mmcblk2boot1: mmc2:0001 DG4016 partition 2 4.00 MiB
003: mmcblk2rpmb: mmc2:0001 DG4016 partition 3 4.00 MiB, chardev (249:0)
003: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: verity: sha256 using implementation "sha256-caam"
000: device-mapper: ioctl: dm-0 (rootfs) is ready
Wait loop is limited to 10 at the moment for our use case showed no more than 4 loops before successfully find data device.
---
Changes from v1:
- limit the loop to 10 iterations
- change variable names
- check only for -ENODEV failures
Changes from v2:
- use a limit in seconds (not in retry
number)
- add a parameter
- update docs
.../admin-guide/device-mapper/dm-init.rst | 13 +++++++++++ drivers/md/dm-init.c | 23 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)
Documentation/admin-guide/device-mapper/dm-init.rst +13 -0
@@ -123,3 +123,16 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +Delay for waiting deferred probes of block devices +================================================== + +Sometimes the late initcall starting the early creation of mapped +devices, starts too early. A loop waiting for probing of block +devices has been added; the default maximum delay is 1 second but +it can be set through the following kernel command:: + + dm-mod.delay=<seconds> + +This allows the procedure to retry the creation of a mapped device +after a short wait (5 msecs).
drivers/md/dm-init.c +21 -2
@@ -7,7 +7,9 @@* This file is released under the GPLv2. */ +#include <linux/async.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h>
@@ -18,8 +20,10 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_DEFAULT_MAX_PROBE_DELAY 1static char *create; +static int delay =DM_DEFAULT_MAX_PROBE_DELAY ;/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
@@ -267,6 +271,8 @@ static int __init dm_init_init(void)LIST_HEAD (devices);char *str;int r; +int loopcnt = delay *1000 /5 ; +bool devnotfound = false;if (!create)return 0 ;
@@ -275,6 +281,7 @@ static int __init dm_init_init(void)DMERR ("Argument is too big. Limit is %d" ,DM_MAX_STR_SIZE );return -EINVAL ; } +retry: str =kstrndup (create,DM_MAX_STR_SIZE ,GFP_KERNEL );if (!str)return -ENOMEM ;
@@ -287,13 +294,23 @@ static int __init dm_init_init(void)wait_for_device_probe ();list_for_each_entry (dev, &devices, list) { -if (dm_early_create (&dev->dmi, dev->table, - dev->target_args_array)) + r =dm_early_create (&dev->dmi, dev->table, dev->target_args_array); +if (r == -ENODEV ) { + devnotfound = true;break ; + } } + out:kfree (str);dm_setup_cleanup (&devices); +if (devnotfound && loopcnt) { +msleep (5 ); + devnotfound = false; + loopcnt--; + goto retry; + } +return r; }
@@ -301,3 +318,5 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); +module_param (delay, int,0 ); +MODULE_PARM_DESC (delay,"Max delay to wait for data/hash device probe in seconds" );
Signature · 1 line
2.30.2
Hi all
Quoted 8 lines · Fabio Aiuto
From: Michael Trimarchi <[email protected]>
The device driver can be deferrable and can be a race during the dm-init early. We need to wait all the probe are really finished in a loop as is done in
do_mounts. This is was tested on kernel 5.4 but code seems was not changed since that time
Any follow up?
Michael
Quoted 168 lines
003: imx8mq-usb-phy 381f0040.usb-phy: 381f0040.usb-phy supply vbus not found, using dummy regulator 003: imx8mq-usb-phy 382f0040.usb-phy: 382f0040.usb-phy supply vbus not found, using dummy regulator 003: imx-cpufreq-dt imx-cpufreq-dt: cpu speed grade 5 mkt segment 0 supported-hw
0x200x1003: caam-dma caam-dma: caam dma support with 2 job rings
000: hctosys: unable to open rtc device (rtc0)
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
002: crng init done
003:of_cfs_init
003:of_cfs_init: OK
003: Waiting for root device/dev/dm-0...
001: mmc2: new HS400 Enhanced strobe MMC card at address 0001
001: mmcblk2: mmc2:0001 IB2916 14.6 GiB
001: mmcblk2boot0: mmc2:0001 IB2916 partition 1 4.00 MiB
001: mmcblk2boot1: mmc2:0001 IB2916 partition 2 4.00 MiB
001: mmcblk2rpmb: mmc2:0001 IB2916 partition 3 4.00 MiB, chardev (249:0)
001: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
001:VSD_3V3: disablingwith the patch
003: device-mapper: init: waiting for all devices to be available before creating mapped devices
000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: crng init done
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: table: 254:0: verity: Data device lookup failed
003: device-mapper: ioctl: error adding target to table
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
003: mmc2: new HS400 Enhanced strobe MMC card at address 0001
003: mmcblk2: mmc2:0001 DG4016 14.7 GiB
003: mmcblk2boot0: mmc2:0001 DG4016 partition 1 4.00 MiB
003: mmcblk2boot1: mmc2:0001 DG4016 partition 2 4.00 MiB
003: mmcblk2rpmb: mmc2:0001 DG4016 partition 3 4.00 MiB, chardev (249:0)
003: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: verity: sha256 using implementation "sha256-caam"
000: device-mapper: ioctl: dm-0 (rootfs) is readyWait loop is limited to 10 at the moment for our use case showed no more than 4 loops before successfully find data device.
Signed-off-by Michael Trimarchi <[email protected]>Signed-off-by Fabio Aiuto <[email protected]>---
Changes from v1:
- limit the loop to 10 iterations
- change variable names
- check only for-ENODEVfailuresChanges from v2:
- use a limit in seconds (not in retry
number)
- add a parameter
- update docs.../admin-guide/device-mapper/dm-init.rst | 13 +++++++++++ drivers/md/dm-init.c | 23 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)Documentation/admin-guide/device-mapper/dm-init.rst +13
-0@@ -123,3 +123,16 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +Delay for waiting deferred probes of block devices +================================================== + +Sometimes the late initcall starting the early creation of mapped +devices, starts too early. A loop waiting for probing of block +devices has been added; the default maximum delay is 1 second but +it can be set through the following kernel command:: + + dm-mod.delay=<seconds> + +This allows the procedure to retry the creation of a mapped device +after a short wait (5 msecs).drivers/md/dm-init.c +21
-3@@ -7,7 +7,9 @@* This file is released under the GPLv2. */ +#include <linux/async.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h> @@ -18,8 +20,10 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_DEFAULT_MAX_PROBE_DELAY 1static char *create; +static int delay =DM_DEFAULT_MAX_PROBE_DELAY ;/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+] @@ -267,6 +271,8 @@ static int __init dm_init_init(void)LIST_HEAD (devices);char *str;int r; +int loopcnt = delay *1000 /5 ; +bool devnotfound = false;if (!create)return 0 ;@@ -275,6 +281,7 @@ static int __init dm_init_init(void)DMERR ("Argument is too big. Limit is %d" ,DM_MAX_STR_SIZE );return -EINVAL ; } +retry: str =kstrndup (create,DM_MAX_STR_SIZE ,GFP_KERNEL );if (!str)return -ENOMEM ;@@ -287,13 +294,23 @@ static int __init dm_init_init(void)wait_for_device_probe ();list_for_each_entry (dev, &devices, list) { -if (dm_early_create (&dev->dmi, dev->table, - dev->target_args_array)) + r =dm_early_create (&dev->dmi, dev->table, dev->target_args_array); +if (r == -ENODEV ) { + devnotfound = true;break ; + } } + out:kfree (str);dm_setup_cleanup (&devices); +if (devnotfound && loopcnt) { +msleep (5 ); + devnotfound = false; + loopcnt--; + goto retry; + } +return r; }@@ -301,3 +318,5 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); +module_param (delay, int,0 ); +MODULE_PARM_DESC (delay,"Max delay to wait for data/hash device probe in seconds" ); --2.30.2
I ran into this issue today. This patch fixes things, so
However, I think the implementation leaves a bit to be desired...
Quoted 31 lines · Fabio Aiuto
From: Michael Trimarchi <[email protected]>
The device driver can be deferrable and can be a race during the dm-init early. We need to wait all the probe are really finished in a loop as is done in
do_mounts. This is was tested on kernel 5.4 but code seems was not changed since that time003: imx8mq-usb-phy 381f0040.usb-phy: 381f0040.usb-phy supply vbus not found, using dummy regulator 003: imx8mq-usb-phy 382f0040.usb-phy: 382f0040.usb-phy supply vbus not found, using dummy regulator 003: imx-cpufreq-dt imx-cpufreq-dt: cpu speed grade 5 mkt segment 0 supported-hw
0x200x1003: caam-dma caam-dma: caam dma support with 2 job rings
000: hctosys: unable to open rtc device (rtc0)
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
002: crng init done
003:of_cfs_init
003:of_cfs_init: OK
003: Waiting for root device/dev/dm-0...
001: mmc2: new HS400 Enhanced strobe MMC card at address 0001
001: mmcblk2: mmc2:0001 IB2916 14.6 GiB
001: mmcblk2boot0: mmc2:0001 IB2916 partition 1 4.00 MiB
001: mmcblk2boot1: mmc2:0001 IB2916 partition 2 4.00 MiB
001: mmcblk2rpmb: mmc2:0001 IB2916 partition 3 4.00 MiB, chardev (249:0)
001: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
001:VSD_3V3: disablingwith the patch
003: device-mapper: init: waiting for all devices to be available before creating mapped devices
Quoted 15 lines
000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: crng init done
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: table: 254:0: verity: Data device lookup failed
003: device-mapper: ioctl: error adding target to table
003: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 002: device-mapper: table: 254:0: verity: Data device lookup failed
002: device-mapper: ioctl: error adding target to table
000: device-mapper: init: waiting for all devices to be available before creating mapped devices 000: device-mapper: table: 254:0: verity: Data device lookup failed
000: device-mapper: ioctl: error adding target to table
For example, we repeatedly print these errors, even though there is not really an error condition. Additionally, we still loop even if (e.g.) there is a syntax error in the dm-mod.create parameter. It also introduces similar problems to rootdelay, where you have to choose a suitable maximum value.
I would much rather see something closer to rootwait (as implemented in prepare_namespace). To do that, I think it is better to modify dm_get_device or dm_get_dev_t, which are closer to the source of the error. One issue is that these functions are not just called from dm_early_create, but also at runtime. So we can't just blindly start waiting for devices to show up if they don't exist and dm-mod.wait (or whatever) is missing. We could solve this by introducing a variable which is cleared at the end of dm_early_create. I think that solution is OK. We could also modify dm_early_create to pass a parameter to dm_table_add_target which indicates that the target is being created "early." However, I think this would be fairly disruptive to existing code.
--Sean
Quoted 127 lines
003: mmc2: new HS400 Enhanced strobe MMC card at address 0001
003: mmcblk2: mmc2:0001 DG4016 14.7 GiB
003: mmcblk2boot0: mmc2:0001 DG4016 partition 1 4.00 MiB
003: mmcblk2boot1: mmc2:0001 DG4016 partition 2 4.00 MiB
003: mmcblk2rpmb: mmc2:0001 DG4016 partition 3 4.00 MiB, chardev (249:0)
003: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
002: device-mapper: init: waiting for all devices to be available before creating mapped devices 003: device-mapper: verity: sha256 using implementation "sha256-caam"
000: device-mapper: ioctl: dm-0 (rootfs) is readyWait loop is limited to 10 at the moment for our use case showed no more than 4 loops before successfully find data device.
Signed-off-by Michael Trimarchi <[email protected]>Signed-off-by Fabio Aiuto <[email protected]>---
Changes from v1:
- limit the loop to 10 iterations
- change variable names
- check only for-ENODEVfailuresChanges from v2:
- use a limit in seconds (not in retry
number)
- add a parameter
- update docs.../admin-guide/device-mapper/dm-init.rst | 13 +++++++++++ drivers/md/dm-init.c | 23 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)Documentation/admin-guide/device-mapper/dm-init.rst +13
-0@@ -123,3 +123,16 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +Delay for waiting deferred probes of block devices +================================================== + +Sometimes the late initcall starting the early creation of mapped +devices, starts too early. A loop waiting for probing of block +devices has been added; the default maximum delay is 1 second but +it can be set through the following kernel command:: + + dm-mod.delay=<seconds> + +This allows the procedure to retry the creation of a mapped device +after a short wait (5 msecs).drivers/md/dm-init.c +21
-2@@ -7,7 +7,9 @@* This file is released under the GPLv2. */ +#include <linux/async.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h> @@ -18,8 +20,10 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_DEFAULT_MAX_PROBE_DELAY 1static char *create; +static int delay =DM_DEFAULT_MAX_PROBE_DELAY ;/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+] @@ -267,6 +271,8 @@ static int __init dm_init_init(void)LIST_HEAD (devices);char *str;int r; +int loopcnt = delay *1000 /5 ; +bool devnotfound = false;if (!create)return 0 ;@@ -275,6 +281,7 @@ static int __init dm_init_init(void)DMERR ("Argument is too big. Limit is %d" ,DM_MAX_STR_SIZE );return -EINVAL ; } +retry: str =kstrndup (create,DM_MAX_STR_SIZE ,GFP_KERNEL );if (!str)return -ENOMEM ;@@ -287,13 +294,23 @@ static int __init dm_init_init(void)wait_for_device_probe ();list_for_each_entry (dev, &devices, list) { -if (dm_early_create (&dev->dmi, dev->table, - dev->target_args_array)) + r =dm_early_create (&dev->dmi, dev->table, dev->target_args_array); +if (r == -ENODEV ) { + devnotfound = true;break ; + } } + out:kfree (str);dm_setup_cleanup (&devices); +if (devnotfound && loopcnt) { +msleep (5 ); + devnotfound = false; + loopcnt--; + goto retry; + } +return r; }@@ -301,3 +318,5 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); +module_param (delay, int,0 ); +MODULE_PARM_DESC (delay,"Max delay to wait for data/hash device probe in seconds" );
Hi Sean
Quoted 15 lines · Sean Anderson
I ran into this issue today. This patch fixes things, so
Tested-by Sean Anderson <[email protected]>However, I think the implementation leaves a bit to be desired...
Quoted 7 lines · Fabio Aiuto
From: Michael Trimarchi <[email protected]>
The device driver can be deferrable and can be a race during the dm-init early. We need to wait all the probe are really finished in a loop as is done in
do_mounts. This is was tested on kernel 5.4 but code seems was not changed since that time
Ok, I know, I was waiting for some feedback. I will try to rework
Michael
Quoted 203 lines
Quoted 1 line
003: imx8mq-usb-phy 381f0040.usb-phy: 381f0040.usb-phy supply vbus not
found, using dummy regulator
Quoted 1 line
003: imx8mq-usb-phy 382f0040.usb-phy: 382f0040.usb-phy supply vbus not
found, using dummy regulator
Quoted 1 line
003: imx-cpufreq-dt imx-cpufreq-dt: cpu speed grade 5 mkt segment 0
supported-hw
0x200x1Quoted 3 lines
003: caam-dma caam-dma: caam dma support with 2 job rings 000: hctosys: unable to open rtc device (rtc0)
000: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 14 lines
002: device-mapper: table: 254:0: verity: Data device lookup failed 002: device-mapper: ioctl: error adding target to table
002: crng init done
003:of_cfs_init
003:of_cfs_init: OK
003: Waiting for root device/dev/dm-0...
001: mmc2: new HS400 Enhanced strobe MMC card at address 0001 001: mmcblk2: mmc2:0001 IB2916 14.6 GiB
001: mmcblk2boot0: mmc2:0001 IB2916 partition 1 4.00 MiB 001: mmcblk2boot1: mmc2:0001 IB2916 partition 2 4.00 MiB 001: mmcblk2rpmb: mmc2:0001 IB2916 partition 3 4.00 MiB, chardev (249:0) 001: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
001:VSD_3V3: disablingQuoted 3 lines
with the patch
003: device-mapper: init: waiting for all devices to be available before
creating mapped devices
Quoted 5 lines
000: device-mapper: table: 254:0: verity: Data device lookup failed 000: device-mapper: ioctl: error adding target to table
002: crng init done
003: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 3 lines
003: device-mapper: table: 254:0: verity: Data device lookup failed 003: device-mapper: ioctl: error adding target to table
003: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 3 lines
000: device-mapper: table: 254:0: verity: Data device lookup failed 000: device-mapper: ioctl: error adding target to table
002: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 3 lines
002: device-mapper: table: 254:0: verity: Data device lookup failed 002: device-mapper: ioctl: error adding target to table
000: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 2 lines
000: device-mapper: table: 254:0: verity: Data device lookup failed 000: device-mapper: ioctl: error adding target to table
For example, we repeatedly print these errors, even though there is not really an error condition. Additionally, we still loop even if (e.g.) there is a syntax error in the dm-mod.create parameter. It also introduces similar problems to rootdelay, where you have to choose a suitable maximum value.
I would much rather see something closer to rootwait (as implemented in
prepare_namespace). To do that, I think it is better to modifydm_get_deviceordm_get_dev_t, which are closer to the source of the error. One issue is that these functions are not just called fromdm_early_create, but also at runtime. So we can't just blindly start waiting for devices to show up if they don't exist and dm-mod.wait (or whatever) is missing. We could solve this by introducing a variable which is cleared at the end ofdm_early_create. I think that solution is OK. We could also modifydm_early_createto pass a parameter todm_table_add_targetwhich indicates that the target is being created "early." However, I think this would be fairly disruptive to existing code.--Sean
Quoted 7 lines
003: mmc2: new HS400 Enhanced strobe MMC card at address 0001 003: mmcblk2: mmc2:0001 DG4016 14.7 GiB
003: mmcblk2boot0: mmc2:0001 DG4016 partition 1 4.00 MiB 003: mmcblk2boot1: mmc2:0001 DG4016 partition 2 4.00 MiB 003: mmcblk2rpmb: mmc2:0001 DG4016 partition 3 4.00 MiB, chardev (249:0) 003: mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
002: device-mapper: init: waiting for all devices to be available beforecreating mapped devices
Quoted 20 lines
003: device-mapper: verity: sha256 using implementation "sha256-caam" 000: device-mapper: ioctl: dm-0 (rootfs) is ready
Wait loop is limited to 10 at the moment for our use case showed no more than 4 loops before successfully find data device.
Signed-off-by Michael Trimarchi <[email protected]>Signed-off-by Fabio Aiuto <[email protected]>---
Changes from v1:
- limit the loop to 10 iterations
- change variable names
- check only for-ENODEVfailuresChanges from v2:
- use a limit in seconds (not in retry
number)
- add a parameter
- update docsReview
Quoted 5 lines
.../admin-guide/device-mapper/dm-init.rst | 13 +++++++++++ drivers/md/dm-init.c | 23 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/Documentation/admin-guide/device-mapper/dm-init.rstQuoted 35 lines
index
e5242ff17e9b..5c2f2bf1db03100644Documentation/admin-guide/device-mapper/dm-init.rst +13
-0@@ -123,3 +123,16 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +Delay for waiting deferred probes of block devices +================================================== + +Sometimes the late initcall starting the early creation of mapped +devices, starts too early. A loop waiting for probing of block +devices has been added; the default maximum delay is 1 second but +it can be set through the following kernel command:: + + dm-mod.delay=<seconds> + +This allows the procedure to retry the creation of a mapped device +after a short wait (5 msecs).drivers/md/dm-init.c +2
-0@@ -7,7 +7,9 @@* This file is released under the GPLv2. */ +#include <linux/async.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h> drivers/md/dm-init.c line 29
Quoted 10 lines
drivers/md/dm-init.c +2
-0@@ -18,8 +20,10 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_DEFAULT_MAX_PROBE_DELAY 1static char *create; +static int delay =DM_DEFAULT_MAX_PROBE_DELAY ;/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
Quoted 18 lines
drivers/md/dm-init.c +3
-0@@ -267,6 +271,8 @@ static int __init dm_init_init(void)LIST_HEAD (devices);char *str;int r; +int loopcnt = delay *1000 /5 ; +bool devnotfound = false;if (!create)return 0 ;@@ -275,6 +281,7 @@ static int __init dm_init_init(void)DMERR ("Argument is too big. Limit is %d" ,DM_MAX_STR_SIZE );return -EINVAL ; } +retry: str =kstrndup (create,DM_MAX_STR_SIZE ,GFP_KERNEL );if (!str)return -ENOMEM ;drivers/md/dm-init.c static int __init dm_init_init(void) · line 297
Quoted 6 lines
drivers/md/dm-init.c +1
-2@@ -287,13 +294,23 @@ static int __init dm_init_init(void)wait_for_device_probe ();list_for_each_entry (dev, &devices, list) { -if (dm_early_create (&dev->dmi, dev->table, - dev->target_args_array)) + r = dm_early_create(&dev->dmi, dev->table,
dev->target_args_array);Quoted 20 lines
drivers/md/dm-init.c +11
-0+if (r == -ENODEV ) { + devnotfound = true;break ; + } } + out:kfree (str);dm_setup_cleanup (&devices); +if (devnotfound && loopcnt) { +msleep (5 ); + devnotfound = false; + loopcnt--; + goto retry; + } +return r; }drivers/md/dm-init.c late_initcall(dm_init_init); · line 322
Quoted 5 lines
drivers/md/dm-init.c +2
-0@@ -301,3 +318,5 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); +module_param (delay, int,0 ); +MODULE_PARM_DESC(delay, "Max delay to wait for data/hash device probein seconds");
Quoted 1 line
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel