linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: [PATCH] Correct tag initialisation for commands
Date: Fri, 19 Oct 2007 15:23:35 +0200	[thread overview]
Message-ID: <4718AFD7.5000203@suse.de> (raw)

Hi all,

currently the initialisation of scmd->tag seems to be wrong.
We have this lines from scsi_lib.c:scsi_get_cmd_from_req():

	/* pull a tag out of the request if we have one */
	cmd->tag = req->tag;

which are supposed to fill the tag value for a given command.
However, the function is called from the ->prep_fn callback,
invoked from elv_next_request() in scsi_request_fn().

In scsi_request_fn() we have:

	req = elv_next_request(q);
	if (!req || !scsi_dev_queue_ready(q, sdev))
		break;

	if (unlikely(!scsi_device_online(sdev))) {
		sdev_printk(KERN_ERR, sdev,
			    "rejecting I/O to offline device\n");
		scsi_kill_request(req, q);
		continue;
	}

	/*
	 * Remove the request from the request list.
	 */
	if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
		blkdev_dequeue_request(req);

ie the value of rq->tag is filled _after it has been copied
to scmd->tag.

A proposed patch would be:

--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1055,8 +1055,6 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
 		cmd = req->special;
 	}
 
-	/* pull a tag out of the request if we have one */
-	cmd->tag = req->tag;
 	cmd->request = req;
 
 	return cmd;
@@ -1445,6 +1443,9 @@ static void scsi_request_fn(struct request_queue *q)
 			blk_dump_rq_flags(req, "foo");
 			BUG();
 		}
+		/* pull a tag out of the request if we have one */
+		cmd->tag = req->tag;
+
 		spin_lock(shost->host_lock);
 
 		if (!scsi_host_queue_ready(q, shost, sdev))

Comments?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
-
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

             reply	other threads:[~2007-10-19 13:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-19 13:23 Hannes Reinecke [this message]
2007-10-19 17:57 ` [PATCH] Correct tag initialisation for commands Mike Christie
2007-10-19 17:59   ` Mike Christie
2007-10-25 11:40   ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4718AFD7.5000203@suse.de \
    --to=hare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).