Skip to contentSkip to conversation

scsi: Double completion on retry

PATCH In review Hannes Reinecke 1 participant 2 messages May 2, 2013 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: Double completion on retry

When blk_end_request() returns 'false' in scsi_end_request the request is invalid after blk_end_request_all(). So we must not return the then stale request pointer. Doing so will result in a potential double completion.
And we should be calling scsi_release_buffers() before blk_end_request_all().

Cc Mike Christie <[email protected]>
Cc Tejun Heo <[email protected]>
drivers/scsi/scsi_lib.c +4 -2
index c31187d..8dba66b 100644
@@ -581,9 +581,11 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
 	 */
 	if (blk_end_request(req, error, bytes)) {
 		/* kill remainder if no retrys */
-		if (error && scsi_noretry_cmd(cmd))
+		if (error && scsi_noretry_cmd(cmd)) {
+			scsi_release_buffers(cmd);
 			blk_end_request_all(req, error);
-		else {
+			cmd = NULL;
+		} else {
 			if (requeue) {
 				/*
 				 * Bleah.  Leftovers again.  Stick the
#1 lore raw
Quoted 20 lines · Hannes Reinecke

When blk_end_request() returns 'false' in scsi_end_request the request is invalid after blk_end_request_all(). So we must not return the then stale request pointer. Doing so will result in a potential double completion.
And we should be calling scsi_release_buffers() before blk_end_request_all().

Cc Mike Christie <[email protected]>
Cc Tejun Heo <[email protected]>
drivers/scsi/scsi_lib.c +0 -0
index c31187d..8dba66b 100644
@@ -581,9 +581,11 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
 	 */
 	if (blk_end_request(req, error, bytes)) {
 		/* kill remainder if no retrys */

drivers/scsi/scsi_lib.c static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error, · line 591

Quoted 10 lines
drivers/scsi/scsi_lib.c +4 -2
-		if (error && scsi_noretry_cmd(cmd))
+		if (error && scsi_noretry_cmd(cmd)) {
+			scsi_release_buffers(cmd);
 			blk_end_request_all(req, error);
-		else {
+			cmd = NULL;
+		} else {
 			if (requeue) {
 				/*
 				 * Bleah.  Leftovers again.  Stick the

Bah, forget it. Patch is wrong.

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