Skip to contentSkip to conversation

(unknown)

PATCH In review Matthew Wilcox 2 participants 3 messages Aug 20, 2007 – Sep 23, 2007 SCSI

lore
Share & tools
lore
#0 lore raw

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.

drivers/scsi/scsi_scan.c +4 -1
index 309b224..a001ca1 100644
@@ -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);
 
#1 lore raw

PATCH 1/1 scsi_scan: Cope with kthread_run failing

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

Quoted 33 lines · 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.

drivers/scsi/scsi_scan.c +4 -2
index 309b224..a001ca1 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
"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."
#2 lore raw

Re: [PATCH] scsi_scan: Cope with kthread_run failing

Quoted 22 lines · Matthew Wilcox

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

Quoted 17 lines · 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.

drivers/scsi/scsi_scan.c +1 -0
index 309b224..a001ca1 100644
@@ -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;
 
Quoted 8 lines

drivers/scsi/scsi_scan.c void scsi_scan_host(struct Scsi_Host *shost) · line 1815

Quoted 8 lines
drivers/scsi/scsi_scan.c +2 -1
 	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