diff mbox

[1/5] initdev:kernel: Asynchronously-discovered device synchronization, v5

Message ID 20090505234725.5ab247db@linux-lm
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Ming Lei May 5, 2009, 3:47 p.m. UTC
On Mon, 4 May 2009 11:07:52 -0400 (EDT)
Alan Stern <stern@rowland.harvard.edu> wrote:

> On Mon, 4 May 2009, Arjan van de Ven wrote:
> 
> > > > for normal device probing we already have infrastructure
> > > > though... wait_for_device_probe, driver_probe_done and
> > > > friends... (the scsi scanning thread is being converted to the
> > > > async infrastructure btw)
> > > > 
> > > > do we need to invent more ?
> > > 
> > > I suppose the usb-storage scanning thread could also be converted
> > > to the async infrastructure, although I haven't heard of anybody
> > > working on it.
> > > 
> > > But the USB hub driver's thread (khubd) cannot be converted.  It
> > > is central to the discovery of USB-based block devices.  How
> > > would you handle that?
> > 
> > take a ref in the driver_probe_done() sense, and release it when you
> > know you're done probing....
> > 
> > at that point all existing infrastructure will just work.
> 
> Isn't there still something missing?  The wait_for_device_probe()  
> routine would wait until all attached devices had been probed.  But
> why should prepare_namespace() have to wait that long?  Wouldn't it be
> better to wait only until the root device has been registered?

Yes, maybe David should merge the following patch into the patch
No.5(initdev:kernel: USB and SCSI block init device notification, v3).

Right?

Comments

Ming Lei May 5, 2009, 3:53 p.m. UTC | #1
2009/5/5 Ming Lei <tom.leiming@gmail.com>:
> On Mon, 4 May 2009 11:07:52 -0400 (EDT)
> Alan Stern <stern@rowland.harvard.edu> wrote:
>
>> On Mon, 4 May 2009, Arjan van de Ven wrote:
>>
>> > > > for normal device probing we already have infrastructure
>> > > > though... wait_for_device_probe, driver_probe_done and
>> > > > friends... (the scsi scanning thread is being converted to the
>> > > > async infrastructure btw)
>> > > >
>> > > > do we need to invent more ?
>> > >
>> > > I suppose the usb-storage scanning thread could also be converted
>> > > to the async infrastructure, although I haven't heard of anybody
>> > > working on it.
>> > >
>> > > But the USB hub driver's thread (khubd) cannot be converted.  It
>> > > is central to the discovery of USB-based block devices.  How
>> > > would you handle that?
>> >
>> > take a ref in the driver_probe_done() sense, and release it when you
>> > know you're done probing....
>> >
>> > at that point all existing infrastructure will just work.
>>
>> Isn't there still something missing?  The wait_for_device_probe()
>> routine would wait until all attached devices had been probed.  But
>> why should prepare_namespace() have to wait that long?  Wouldn't it be
>> better to wait only until the root device has been registered?
>
> Yes, maybe David should merge the following patch into the patch
> No.5(initdev:kernel: USB and SCSI block init device notification, v3).
>
> Right?

Also need all block device drivers use initdev_*, much work to do,:-)

>
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index dd7ee5f..22fd773 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -358,6 +358,12 @@ void __init mount_root(void)
>  #endif
>  }
>
> +static int root_dev_done()
> +{
> +       return !!(ROOT_DEV = name_to_dev_t(saved_root_name));
> +}
> +
> +
>  /*
>  * Prepare the namespace - decide what/where to mount, load ramdisks,
> etc. */
> @@ -398,12 +404,12 @@ void __init prepare_namespace(void)
>                goto out;
>
>        /* wait for any asynchronous scanning to complete */
> -       if ((ROOT_DEV == 0) && root_wait) {
> +       if (ROOT_DEV == 0 && root_wait) {
>                printk(KERN_INFO "Waiting for root device %s...\n",
>                        saved_root_name);
> -               while (driver_probe_done() != 0 ||
> -                       (ROOT_DEV = name_to_dev_t(saved_root_name)) ==
> 0)
> -                       msleep(100);
> +               do {
> +                       initdev_wait(BOOTDEV_BLOCK, root_dev_done);
> +               } while (!ROOT_DEV);
>                async_synchronize_full();
>        }
>
>
>
>
> --
> Lei Ming
>
David VomLehn June 5, 2009, 5:58 p.m. UTC | #2
On Tue, May 05, 2009 at 11:47:25AM -0400, Ming Lei wrote:
> On Mon, 4 May 2009 11:07:52 -0400 (EDT)
> Alan Stern <stern@rowland.harvard.edu> wrote:
> 
> > On Mon, 4 May 2009, Arjan van de Ven wrote:
...
> > Isn't there still something missing?  The wait_for_device_probe()  
> > routine would wait until all attached devices had been probed.  But
> > why should prepare_namespace() have to wait that long?  Wouldn't it be
> > better to wait only until the root device has been registered?
> 
> Yes, maybe David should merge the following patch into the patch
> No.5(initdev:kernel: USB and SCSI block init device notification, v3).
> 
> Right?
> 
> diff --git a/init/do_mounts.c b/init/do_mounts.c
> index dd7ee5f..22fd773 100644
> --- a/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -358,6 +358,12 @@ void __init mount_root(void)
>  #endif
>  }
>  
> +static int root_dev_done()
> +{
> +	return !!(ROOT_DEV = name_to_dev_t(saved_root_name));
> +}
> +
> +
>  /*
>   * Prepare the namespace - decide what/where to mount, load ramdisks,
> etc. */
> @@ -398,12 +404,12 @@ void __init prepare_namespace(void)
>  		goto out;
>  
>  	/* wait for any asynchronous scanning to complete */
> -	if ((ROOT_DEV == 0) && root_wait) {
> +	if (ROOT_DEV == 0 && root_wait) {
>  		printk(KERN_INFO "Waiting for root device %s...\n",
>  			saved_root_name);
> -		while (driver_probe_done() != 0 ||
> -			(ROOT_DEV = name_to_dev_t(saved_root_name)) ==
> 0)
> -			msleep(100);
> +		do {
> +			initdev_wait(BOOTDEV_BLOCK, root_dev_done);
> +		} while (!ROOT_DEV);
>  		async_synchronize_full();
>  	}

I have something very similar. I'm not completely comfortable with discarding
the rootwait flag, though it should be very rarely used once the initdev
infrastructure is in place.

> Lei Ming

David VomLehn
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David VomLehn June 5, 2009, 6 p.m. UTC | #3
On Tue, May 05, 2009 at 11:53:38AM -0400, Ming Lei wrote:
> 2009/5/5 Ming Lei <tom.leiming@gmail.com>:

> Also need all block device drivers use initdev_*, much work to do,:-)

Not directly. All interesting block devices funnel through just a few functions
to make the block device usable. I think I have the right place for the
initdev_registered() call, but I definitely need feedback on this.

> Lei Ming

David VomLehn
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/init/do_mounts.c b/init/do_mounts.c
index dd7ee5f..22fd773 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -358,6 +358,12 @@  void __init mount_root(void)
 #endif
 }
 
+static int root_dev_done()
+{
+	return !!(ROOT_DEV = name_to_dev_t(saved_root_name));
+}
+
+
 /*
  * Prepare the namespace - decide what/where to mount, load ramdisks,
etc. */
@@ -398,12 +404,12 @@  void __init prepare_namespace(void)
 		goto out;
 
 	/* wait for any asynchronous scanning to complete */
-	if ((ROOT_DEV == 0) && root_wait) {
+	if (ROOT_DEV == 0 && root_wait) {
 		printk(KERN_INFO "Waiting for root device %s...\n",
 			saved_root_name);
-		while (driver_probe_done() != 0 ||
-			(ROOT_DEV = name_to_dev_t(saved_root_name)) ==
0)
-			msleep(100);
+		do {
+			initdev_wait(BOOTDEV_BLOCK, root_dev_done);
+		} while (!ROOT_DEV);
 		async_synchronize_full();
 	}