All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: add module parameter bdev_wait
@ 2021-10-22  6:47 ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-22  6:47 UTC (permalink / raw)
  To: agk, snitzer, dm-devel
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	tequila.yuang, yj.chiang, mark-pk.tsai

dm_early_create() fail if the target block device not found in
the late init stage.
The block device is created in mmc_rescan() which kernel do
it async by queue it into system_freezable_wq.
Add module param bdev_wait to support waiting the block device
ready before dm_early_create() like prepare_namespace() does.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 drivers/md/dm-init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index b0c45c6ebe0b..a3d24cafa4f4 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -8,11 +8,13 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/device-mapper.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/moduleparam.h>
+#include <linux/mount.h>
 
 #define DM_MSG_PREFIX "init"
 #define DM_MAX_DEVICES 256
@@ -20,6 +22,7 @@
 #define DM_MAX_STR_SIZE 4096
 
 static char *create;
+static char *bdev_wait;
 
 /*
  * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
@@ -286,6 +289,12 @@ static int __init dm_init_init(void)
 	DMINFO("waiting for all devices to be available before creating mapped devices");
 	wait_for_device_probe();
 
+	if (bdev_wait) {
+		DMINFO("Waiting for block device %s...", bdev_wait);
+		while (!name_to_dev_t(bdev_wait))
+			msleep(5);
+	}
+
 	list_for_each_entry(dev, &devices, list) {
 		if (dm_early_create(&dev->dmi, dev->table,
 				    dev->target_args_array))
@@ -301,3 +310,5 @@ late_initcall(dm_init_init);
 
 module_param(create, charp, 0);
 MODULE_PARM_DESC(create, "Create a mapped device in early boot");
+module_param(bdev_wait, charp, 0);
+MODULE_PARM_DESC(bdev_wait, "Wait until the block device ready before dm_early_create");
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] dm: add module parameter bdev_wait
@ 2021-10-22  6:47 ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-22  6:47 UTC (permalink / raw)
  To: agk, snitzer, dm-devel
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	tequila.yuang, yj.chiang, mark-pk.tsai

dm_early_create() fail if the target block device not found in
the late init stage.
The block device is created in mmc_rescan() which kernel do
it async by queue it into system_freezable_wq.
Add module param bdev_wait to support waiting the block device
ready before dm_early_create() like prepare_namespace() does.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 drivers/md/dm-init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index b0c45c6ebe0b..a3d24cafa4f4 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -8,11 +8,13 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/device-mapper.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/moduleparam.h>
+#include <linux/mount.h>
 
 #define DM_MSG_PREFIX "init"
 #define DM_MAX_DEVICES 256
@@ -20,6 +22,7 @@
 #define DM_MAX_STR_SIZE 4096
 
 static char *create;
+static char *bdev_wait;
 
 /*
  * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
@@ -286,6 +289,12 @@ static int __init dm_init_init(void)
 	DMINFO("waiting for all devices to be available before creating mapped devices");
 	wait_for_device_probe();
 
+	if (bdev_wait) {
+		DMINFO("Waiting for block device %s...", bdev_wait);
+		while (!name_to_dev_t(bdev_wait))
+			msleep(5);
+	}
+
 	list_for_each_entry(dev, &devices, list) {
 		if (dm_early_create(&dev->dmi, dev->table,
 				    dev->target_args_array))
@@ -301,3 +310,5 @@ late_initcall(dm_init_init);
 
 module_param(create, charp, 0);
 MODULE_PARM_DESC(create, "Create a mapped device in early boot");
+module_param(bdev_wait, charp, 0);
+MODULE_PARM_DESC(bdev_wait, "Wait until the block device ready before dm_early_create");
-- 
2.18.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] dm: add module parameter bdev_wait
@ 2021-10-22  6:47 ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-22  6:47 UTC (permalink / raw)
  To: agk, snitzer, dm-devel
  Cc: matthias.bgg, linux-kernel, linux-arm-kernel, linux-mediatek,
	tequila.yuang, yj.chiang, mark-pk.tsai

dm_early_create() fail if the target block device not found in
the late init stage.
The block device is created in mmc_rescan() which kernel do
it async by queue it into system_freezable_wq.
Add module param bdev_wait to support waiting the block device
ready before dm_early_create() like prepare_namespace() does.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 drivers/md/dm-init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index b0c45c6ebe0b..a3d24cafa4f4 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -8,11 +8,13 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/device-mapper.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/moduleparam.h>
+#include <linux/mount.h>
 
 #define DM_MSG_PREFIX "init"
 #define DM_MAX_DEVICES 256
@@ -20,6 +22,7 @@
 #define DM_MAX_STR_SIZE 4096
 
 static char *create;
+static char *bdev_wait;
 
 /*
  * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
@@ -286,6 +289,12 @@ static int __init dm_init_init(void)
 	DMINFO("waiting for all devices to be available before creating mapped devices");
 	wait_for_device_probe();
 
+	if (bdev_wait) {
+		DMINFO("Waiting for block device %s...", bdev_wait);
+		while (!name_to_dev_t(bdev_wait))
+			msleep(5);
+	}
+
 	list_for_each_entry(dev, &devices, list) {
 		if (dm_early_create(&dev->dmi, dev->table,
 				    dev->target_args_array))
@@ -301,3 +310,5 @@ late_initcall(dm_init_init);
 
 module_param(create, charp, 0);
 MODULE_PARM_DESC(create, "Create a mapped device in early boot");
+module_param(bdev_wait, charp, 0);
+MODULE_PARM_DESC(bdev_wait, "Wait until the block device ready before dm_early_create");
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [dm-devel] [PATCH] dm: add module parameter bdev_wait
@ 2021-10-22  6:47 ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-22  6:47 UTC (permalink / raw)
  To: agk, snitzer, dm-devel
  Cc: tequila.yuang, yj.chiang, linux-kernel, linux-mediatek,
	mark-pk.tsai, matthias.bgg, linux-arm-kernel

dm_early_create() fail if the target block device not found in
the late init stage.
The block device is created in mmc_rescan() which kernel do
it async by queue it into system_freezable_wq.
Add module param bdev_wait to support waiting the block device
ready before dm_early_create() like prepare_namespace() does.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
---
 drivers/md/dm-init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index b0c45c6ebe0b..a3d24cafa4f4 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -8,11 +8,13 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/device-mapper.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/moduleparam.h>
+#include <linux/mount.h>
 
 #define DM_MSG_PREFIX "init"
 #define DM_MAX_DEVICES 256
@@ -20,6 +22,7 @@
 #define DM_MAX_STR_SIZE 4096
 
 static char *create;
+static char *bdev_wait;
 
 /*
  * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
@@ -286,6 +289,12 @@ static int __init dm_init_init(void)
 	DMINFO("waiting for all devices to be available before creating mapped devices");
 	wait_for_device_probe();
 
+	if (bdev_wait) {
+		DMINFO("Waiting for block device %s...", bdev_wait);
+		while (!name_to_dev_t(bdev_wait))
+			msleep(5);
+	}
+
 	list_for_each_entry(dev, &devices, list) {
 		if (dm_early_create(&dev->dmi, dev->table,
 				    dev->target_args_array))
@@ -301,3 +310,5 @@ late_initcall(dm_init_init);
 
 module_param(create, charp, 0);
 MODULE_PARM_DESC(create, "Create a mapped device in early boot");
+module_param(bdev_wait, charp, 0);
+MODULE_PARM_DESC(bdev_wait, "Wait until the block device ready before dm_early_create");
-- 
2.18.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
  2021-10-22  6:47 ` Mark-PK Tsai
  (?)
  (?)
@ 2021-10-27  6:55   ` Christoph Hellwig
  -1 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2021-10-27  6:55 UTC (permalink / raw)
  To: Mark-PK Tsai
  Cc: agk, snitzer, dm-devel, matthias.bgg, linux-kernel,
	linux-arm-kernel, linux-mediatek, tequila.yuang, yj.chiang

On Fri, Oct 22, 2021 at 02:47:47PM +0800, Mark-PK Tsai wrote:
> dm_early_create() fail if the target block device not found in
> the late init stage.
> The block device is created in mmc_rescan() which kernel do
> it async by queue it into system_freezable_wq.
> Add module param bdev_wait to support waiting the block device
> ready before dm_early_create() like prepare_namespace() does.

This adds a busy loop.  There is a reason why we usually set up
stacking drivers from userspace, in that we have a working event
system there.  So the answer is not to add further hacks to the
in-kernel DM setup hack, but to stop using it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
@ 2021-10-27  6:55   ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2021-10-27  6:55 UTC (permalink / raw)
  To: Mark-PK Tsai
  Cc: agk, snitzer, dm-devel, matthias.bgg, linux-kernel,
	linux-arm-kernel, linux-mediatek, tequila.yuang, yj.chiang

On Fri, Oct 22, 2021 at 02:47:47PM +0800, Mark-PK Tsai wrote:
> dm_early_create() fail if the target block device not found in
> the late init stage.
> The block device is created in mmc_rescan() which kernel do
> it async by queue it into system_freezable_wq.
> Add module param bdev_wait to support waiting the block device
> ready before dm_early_create() like prepare_namespace() does.

This adds a busy loop.  There is a reason why we usually set up
stacking drivers from userspace, in that we have a working event
system there.  So the answer is not to add further hacks to the
in-kernel DM setup hack, but to stop using it.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
@ 2021-10-27  6:55   ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2021-10-27  6:55 UTC (permalink / raw)
  To: Mark-PK Tsai
  Cc: agk, snitzer, dm-devel, matthias.bgg, linux-kernel,
	linux-arm-kernel, linux-mediatek, tequila.yuang, yj.chiang

On Fri, Oct 22, 2021 at 02:47:47PM +0800, Mark-PK Tsai wrote:
> dm_early_create() fail if the target block device not found in
> the late init stage.
> The block device is created in mmc_rescan() which kernel do
> it async by queue it into system_freezable_wq.
> Add module param bdev_wait to support waiting the block device
> ready before dm_early_create() like prepare_namespace() does.

This adds a busy loop.  There is a reason why we usually set up
stacking drivers from userspace, in that we have a working event
system there.  So the answer is not to add further hacks to the
in-kernel DM setup hack, but to stop using it.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dm-devel] [PATCH] dm: add module parameter bdev_wait
@ 2021-10-27  6:55   ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2021-10-27  6:55 UTC (permalink / raw)
  To: Mark-PK Tsai
  Cc: tequila.yuang, snitzer, yj.chiang, linux-kernel, dm-devel,
	linux-mediatek, agk, matthias.bgg, linux-arm-kernel

On Fri, Oct 22, 2021 at 02:47:47PM +0800, Mark-PK Tsai wrote:
> dm_early_create() fail if the target block device not found in
> the late init stage.
> The block device is created in mmc_rescan() which kernel do
> it async by queue it into system_freezable_wq.
> Add module param bdev_wait to support waiting the block device
> ready before dm_early_create() like prepare_namespace() does.

This adds a busy loop.  There is a reason why we usually set up
stacking drivers from userspace, in that we have a working event
system there.  So the answer is not to add further hacks to the
in-kernel DM setup hack, but to stop using it.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
  2021-10-27  6:55   ` Christoph Hellwig
  (?)
  (?)
@ 2021-10-28  5:49     ` Mark-PK Tsai
  -1 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-28  5:49 UTC (permalink / raw)
  To: hch
  Cc: agk, dm-devel, linux-arm-kernel, linux-kernel, linux-mediatek,
	mark-pk.tsai, matthias.bgg, snitzer, tequila.huang, yj.chiang

> > dm_early_create() fail if the target block device not found in
> > the late init stage.
> > The block device is created in mmc_rescan() which kernel do
> > it async by queue it into system_freezable_wq.
> > Add module param bdev_wait to support waiting the block device
> > ready before dm_early_create() like prepare_namespace() does.
>
> This adds a busy loop.  There is a reason why we usually set up
> stacking drivers from userspace, in that we have a working event
> system there.  So the answer is not to add further hacks to the
> in-kernel DM setup hack, but to stop using it.

Thanks for your kind reply.
But We want to use DM target as root device without adding an initramfs.
Is there any other way to do so?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
@ 2021-10-28  5:49     ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-28  5:49 UTC (permalink / raw)
  To: hch
  Cc: agk, dm-devel, linux-arm-kernel, linux-kernel, linux-mediatek,
	mark-pk.tsai, matthias.bgg, snitzer, tequila.huang, yj.chiang

> > dm_early_create() fail if the target block device not found in
> > the late init stage.
> > The block device is created in mmc_rescan() which kernel do
> > it async by queue it into system_freezable_wq.
> > Add module param bdev_wait to support waiting the block device
> > ready before dm_early_create() like prepare_namespace() does.
>
> This adds a busy loop.  There is a reason why we usually set up
> stacking drivers from userspace, in that we have a working event
> system there.  So the answer is not to add further hacks to the
> in-kernel DM setup hack, but to stop using it.

Thanks for your kind reply.
But We want to use DM target as root device without adding an initramfs.
Is there any other way to do so?

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] dm: add module parameter bdev_wait
@ 2021-10-28  5:49     ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-28  5:49 UTC (permalink / raw)
  To: hch
  Cc: agk, dm-devel, linux-arm-kernel, linux-kernel, linux-mediatek,
	mark-pk.tsai, matthias.bgg, snitzer, tequila.huang, yj.chiang

> > dm_early_create() fail if the target block device not found in
> > the late init stage.
> > The block device is created in mmc_rescan() which kernel do
> > it async by queue it into system_freezable_wq.
> > Add module param bdev_wait to support waiting the block device
> > ready before dm_early_create() like prepare_namespace() does.
>
> This adds a busy loop.  There is a reason why we usually set up
> stacking drivers from userspace, in that we have a working event
> system there.  So the answer is not to add further hacks to the
> in-kernel DM setup hack, but to stop using it.

Thanks for your kind reply.
But We want to use DM target as root device without adding an initramfs.
Is there any other way to do so?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dm-devel] [PATCH] dm: add module parameter bdev_wait
@ 2021-10-28  5:49     ` Mark-PK Tsai
  0 siblings, 0 replies; 12+ messages in thread
From: Mark-PK Tsai @ 2021-10-28  5:49 UTC (permalink / raw)
  To: hch
  Cc: tequila.huang, agk, snitzer, yj.chiang, linux-kernel, dm-devel,
	linux-mediatek, linux-arm-kernel, matthias.bgg, mark-pk.tsai

> > dm_early_create() fail if the target block device not found in
> > the late init stage.
> > The block device is created in mmc_rescan() which kernel do
> > it async by queue it into system_freezable_wq.
> > Add module param bdev_wait to support waiting the block device
> > ready before dm_early_create() like prepare_namespace() does.
>
> This adds a busy loop.  There is a reason why we usually set up
> stacking drivers from userspace, in that we have a working event
> system there.  So the answer is not to add further hacks to the
> in-kernel DM setup hack, but to stop using it.

Thanks for your kind reply.
But We want to use DM target as root device without adding an initramfs.
Is there any other way to do so?

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-10-29 11:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22  6:47 [PATCH] dm: add module parameter bdev_wait Mark-PK Tsai
2021-10-22  6:47 ` [dm-devel] " Mark-PK Tsai
2021-10-22  6:47 ` Mark-PK Tsai
2021-10-22  6:47 ` Mark-PK Tsai
2021-10-27  6:55 ` Christoph Hellwig
2021-10-27  6:55   ` [dm-devel] " Christoph Hellwig
2021-10-27  6:55   ` Christoph Hellwig
2021-10-27  6:55   ` Christoph Hellwig
2021-10-28  5:49   ` Mark-PK Tsai
2021-10-28  5:49     ` [dm-devel] " Mark-PK Tsai
2021-10-28  5:49     ` Mark-PK Tsai
2021-10-28  5:49     ` Mark-PK Tsai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.