linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (unknown), 
@ 2007-08-20 15:18 Matthew Wilcox
  2007-08-20 15:20 ` [PATCH] scsi_scan: Cope with kthread_run failing Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2007-08-20 15:18 UTC (permalink / raw)
  To: linux-scsi; +Cc: Matthew Wilcox

If kthread_run failed, we would fail to scan the host, and leak the
allocated async_scan_data.  Since using a separate thread is just an
optimisation, do the scan synchronously if we fail to spawn a thread.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 309b224..a001ca1 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1799,6 +1799,7 @@ static int do_scan_async(void *_data)
  **/
 void scsi_scan_host(struct Scsi_Host *shost)
 {
+	struct task_struct *p;
 	struct async_scan_data *data;
 
 	if (strncmp(scsi_scan_type, "none", 4) == 0)
@@ -1810,7 +1811,9 @@ void scsi_scan_host(struct Scsi_Host *shost)
 		return;
 	}
 
-	kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
+	p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
+	if (IS_ERR(p))
+		do_scan_async(data);
 }
 EXPORT_SYMBOL(scsi_scan_host);
 

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

* [PATCH] scsi_scan: Cope with kthread_run failing
  2007-08-20 15:18 (unknown), Matthew Wilcox
@ 2007-08-20 15:20 ` Matthew Wilcox
  2007-09-23 14:17   ` James Bottomley
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2007-08-20 15:20 UTC (permalink / raw)
  To: linux-scsi


Oops.  I fail to drive git-send-email properly again.
James, when you're committing this, please use the
Subject: [PATCH] scsi_scan: Cope with kthread_run failing

On Mon, Aug 20, 2007 at 09:18:48AM -0600, Matthew Wilcox wrote:
> If kthread_run failed, we would fail to scan the host, and leak the
> allocated async_scan_data.  Since using a separate thread is just an
> optimisation, do the scan synchronously if we fail to spawn a thread.
> 
> Signed-off-by: Matthew Wilcox <matthew@wil.cx>
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 309b224..a001ca1 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1799,6 +1799,7 @@ static int do_scan_async(void *_data)
>   **/
>  void scsi_scan_host(struct Scsi_Host *shost)
>  {
> +	struct task_struct *p;
>  	struct async_scan_data *data;
>  
>  	if (strncmp(scsi_scan_type, "none", 4) == 0)
> @@ -1810,7 +1811,9 @@ void scsi_scan_host(struct Scsi_Host *shost)
>  		return;
>  	}
>  
> -	kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
> +	p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
> +	if (IS_ERR(p))
> +		do_scan_async(data);
>  }
>  EXPORT_SYMBOL(scsi_scan_host);
>  
> -
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH] scsi_scan: Cope with kthread_run failing
  2007-08-20 15:20 ` [PATCH] scsi_scan: Cope with kthread_run failing Matthew Wilcox
@ 2007-09-23 14:17   ` James Bottomley
  0 siblings, 0 replies; 3+ messages in thread
From: James Bottomley @ 2007-09-23 14:17 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-scsi

On Mon, 2007-08-20 at 09:20 -0600, Matthew Wilcox wrote:
> Oops.  I fail to drive git-send-email properly again.
> James, when you're committing this, please use the
> Subject: [PATCH] scsi_scan: Cope with kthread_run failing
> 
> On Mon, Aug 20, 2007 at 09:18:48AM -0600, Matthew Wilcox wrote:
> > If kthread_run failed, we would fail to scan the host, and leak the
> > allocated async_scan_data.  Since using a separate thread is just an
> > optimisation, do the scan synchronously if we fail to spawn a thread.
> > 
> > Signed-off-by: Matthew Wilcox <matthew@wil.cx>
> > 
> > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> > index 309b224..a001ca1 100644
> > --- a/drivers/scsi/scsi_scan.c
> > +++ b/drivers/scsi/scsi_scan.c
> > @@ -1799,6 +1799,7 @@ static int do_scan_async(void *_data)
> >   **/
> >  void scsi_scan_host(struct Scsi_Host *shost)
> >  {
> > +	struct task_struct *p;
> >  	struct async_scan_data *data;
> >  
> >  	if (strncmp(scsi_scan_type, "none", 4) == 0)
> > @@ -1810,7 +1811,9 @@ void scsi_scan_host(struct Scsi_Host *shost)
> >  		return;
> >  	}
> >  
> > -	kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
> > +	p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
> > +	if (IS_ERR(p))

I fixed this one up in situ, but for future reference, an error
condition that's so unlikely we weren't even checking it before needs
an 

if (unlikely(IS_ERR(p)))

to get the compiler to do the right thing if it can.

James



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

end of thread, other threads:[~2007-09-23 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-20 15:18 (unknown), Matthew Wilcox
2007-08-20 15:20 ` [PATCH] scsi_scan: Cope with kthread_run failing Matthew Wilcox
2007-09-23 14:17   ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).