Skip to contentSkip to conversation

scsi: Fix qemu boot hang problem

PATCH In review Guenter Roeck 7 participants 11 messages Aug 10, 2014 – Aug 19, 2014 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: Fix qemu boot hang problem

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:
- if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+ if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))

		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
 drivers/scsi/scsi_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
index 9c44392..ce62e87 100644
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
 	blk_requeue_request(q, req);
 	atomic_dec(&sdev->device_busy);
 out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
 		blk_delay_queue(q, SCSI_QUEUE_DELAY);
 }
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 39 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
  drivers/scsi/scsi_lib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +0 -0
index 9c44392..ce62e87 100644

drivers/scsi/scsi_lib.c static void scsi_request_fn(struct request_queue *q) · line 1780

Quoted 8 lines
drivers/scsi/scsi_lib.c +1 -1
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
  	blk_requeue_request(q, req);
  	atomic_dec(&sdev->device_busy);
  out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
  		blk_delay_queue(q, SCSI_QUEUE_DELAY);
  }
 

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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
Acked-by on v1 1/1
#2 lore raw
In reply to Guenter Roeck
Quoted 39 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
  drivers/scsi/scsi_lib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +0 -0
index 9c44392..ce62e87 100644

drivers/scsi/scsi_lib.c static void scsi_request_fn(struct request_queue *q) · line 1780

Quoted 8 lines
drivers/scsi/scsi_lib.c +1 -1
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
  	blk_requeue_request(q, req);
  	atomic_dec(&sdev->device_busy);
  out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
  		blk_delay_queue(q, SCSI_QUEUE_DELAY);
  }
 

That's a no-brainer obvious fix!

Signature · 1 line
Jens Axboe
Reviewed-by
#3 lore raw

Should we wrap the sdev->device_busy read and test in a new scsi_device_busy(), so as to preserve the old polarity?

Quoted 65 lines · Jens Axboe
Quoted 42 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) &&

!scsi_device_blocked(sdev))

		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)',
meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
  drivers/scsi/scsi_lib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +0 -0
index 9c44392..ce62e87 100644

drivers/scsi/scsi_lib.c static void scsi_request_fn(struct request_queue · line 1780

Quoted 8 lines
drivers/scsi/scsi_lib.c +1 -1
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue
 *q)
  	blk_requeue_request(q, req);
  	atomic_dec(&sdev->device_busy);
  out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
  		blk_delay_queue(q, SCSI_QUEUE_DELAY);
  }

That's a no-brainer obvious fix!

--
Jens Axboe

--
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

#4 lore raw
Quoted 3 lines · Venkatesh Srinivas

Should we wrap the sdev->device_busy read and test in a new scsi_device_busy(), so as to preserve the old polarity?

I don't see a difference in polarity, or at least replacing '== 0' with '!' is not a reverse in polarity for me. Anyway, I don't really care if or how this is wrapped, as long as it is getting fixed.

Thanks,
Guenter

#5 lore raw
In reply to Guenter Roeck

ping ... the problem fixed by this patch still affects the upstream kernel (v3.16-11383-gc9d2642) as well as -next (20140815).

Guenter

Quoted 47 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
  drivers/scsi/scsi_lib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
index 9c44392..ce62e87 100644
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
  	blk_requeue_request(q, req);
  	atomic_dec(&sdev->device_busy);
  out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
  		blk_delay_queue(q, SCSI_QUEUE_DELAY);
  }
 
#6 lore raw
Quoted 2 lines · Guenter Roeck

ping ... the problem fixed by this patch still affects the upstream kernel (v3.16-11383-gc9d2642) as well as -next (20140815).

James, could you upstream this one in time for -rc1?

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#9 lore raw
In reply to Guenter Roeck
Quoted 38 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
  drivers/scsi/scsi_lib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +0 -0
index 9c44392..ce62e87 100644

drivers/scsi/scsi_lib.c static void scsi_request_fn(struct request_queue *q) · line 1779

Quoted 7 lines
drivers/scsi/scsi_lib.c +1 -1
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
  	blk_requeue_request(q, req);
  	atomic_dec(&sdev->device_busy);
  out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
  		blk_delay_queue(q, SCSI_QUEUE_DELAY);
  }

Good catch!

#7 lore raw
In reply to Jens Axboe
Quoted 5 lines · Jens Axboe
Quoted 2 lines · Guenter Roeck

ping ... the problem fixed by this patch still affects the upstream kernel (v3.16-11383-gc9d2642) as well as -next (20140815).

James, could you upstream this one in time for -rc1?

It's in the core-for-3.17 updates I sent to James yesterday, just needs to be forwarded..

#8 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Jens Axboe
Quoted 2 lines · Guenter Roeck

ping ... the problem fixed by this patch still affects the upstream kernel (v3.16-11383-gc9d2642) as well as -next (20140815).

James, could you upstream this one in time for -rc1?

It's in the core-for-3.17 updates I sent to James yesterday, just needs to be forwarded..

Great, thanks a lot!

Guenter

#10 lore raw
In reply to Guenter Roeck

James, can you please send this on ASAP? Sitting for oever a week on a boot regression that comes with a patch isn't reasonable.

Quoted 53 lines · Guenter Roeck

The latest kernel fails to boot qemu arm images when using scsi for disk access. Boot gets stuck after the following messages.

brd: module loaded
sym53c8xx 0000:00:0c.0: enabling device (0100 -> 0103)
sym0: <895a> rev 0x0 at pci 0000:00:0c.0 irq 93
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym0: SCSI BUS has been reset.
scsi host0: sym-2.2.3

Bisect points to commit 71e75c97f97a ("scsi: convert device_busy to atomic_t"). Code inspection shows the following suspicious change in scsi_request_fn.

out_delay:

(quoted diff) +1 -1
-       if (sdev->device_busy == 0 && !scsi_device_blocked(sdev))
+       if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
	}

'sdev->device_busy == 0' was replaced with 'atomic_read(&sdev->device_busy)', meaning the logic was reversed. Changing this expression to '!atomic_read(&sdev->device_busy)' fixes the problem.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Webb Scales <[email protected]>
Cc Jens Axboe <[email protected]>
---
 drivers/scsi/scsi_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
index 9c44392..ce62e87 100644
@@ -1774,7 +1774,7 @@ static void scsi_request_fn(struct request_queue *q)
 	blk_requeue_request(q, req);
 	atomic_dec(&sdev->device_busy);
 out_delay:
-	if (atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
+	if (!atomic_read(&sdev->device_busy) && !scsi_device_blocked(sdev))
 		blk_delay_queue(q, SCSI_QUEUE_DELAY);
 }
 
Signature · 6 lines
1.9.1

--
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

---end quoted text---