Commit 125c99bc8b6b108d251169a86324a7ed3c6f3cce

Authored by Christoph Hellwig
1 parent a62182f338

scsi: add new scsi-command flag for tagged commands

Currently scsi piggy backs on the block layer to define the concept
of a tagged command.  But we want to be able to have block-level host-wide
tags assigned even for untagged commands like the initial INQUIRY, so add
a new SCSI-level flag for commands that are tagged at the scsi level, so
that even commands without that set can have tags assigned to them.  Note
that this alredy is the case for the blk-mq code path, and this just lets
the old path catch up with it.

We also set this flag based upon sdev->simple_tags instead of the block
queue flag, so that it is entirely independent of the block layer tagging,
and thus always correct even if a driver doesn't use block level tagging
yet.

Also remove the old blk_rq_tagged; it was only used by SCSI drivers, and
removing it forces them to look for the proper replacement.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>

Showing 9 changed files with 22 additions and 20 deletions Side-by-side Diff

Documentation/block/biodoc.txt
... ... @@ -827,10 +827,6 @@
827 827 that requests are restarted in the order they were queue. This may happen
828 828 if the driver needs to use blk_queue_invalidate_tags().
829 829  
830   -Tagging also defines a new request flag, REQ_QUEUED. This is set whenever
831   -a request is currently tagged. You should not use this flag directly,
832   -blk_rq_tagged(rq) is the portable way to do so.
833   -
834 830 3.3 I/O Submission
835 831  
836 832 The routine submit_bio() is used to submit a single io. Higher level i/o
... ... @@ -1266,7 +1266,7 @@
1266 1266 blk_clear_rq_complete(rq);
1267 1267 trace_block_rq_requeue(q, rq);
1268 1268  
1269   - if (blk_rq_tagged(rq))
  1269 + if (rq->cmd_flags & REQ_QUEUED)
1270 1270 blk_queue_end_tag(q, rq);
1271 1271  
1272 1272 BUG_ON(blk_queued_rq(rq));
... ... @@ -2554,7 +2554,7 @@
2554 2554 */
2555 2555 void blk_finish_request(struct request *req, int error)
2556 2556 {
2557   - if (blk_rq_tagged(req))
  2557 + if (req->cmd_flags & REQ_QUEUED)
2558 2558 blk_queue_end_tag(req->q, req);
2559 2559  
2560 2560 BUG_ON(blk_queued_rq(req));
drivers/scsi/53c700.c
... ... @@ -1767,7 +1767,7 @@
1767 1767 */
1768 1768 if(NCR_700_get_depth(SCp->device) != 0
1769 1769 && (!(hostdata->tag_negotiated & (1<<scmd_id(SCp)))
1770   - || !blk_rq_tagged(SCp->request))) {
  1770 + || !(SCp->flags & SCMD_TAGGED))) {
1771 1771 CDEBUG(KERN_ERR, SCp, "has non zero depth %d\n",
1772 1772 NCR_700_get_depth(SCp->device));
1773 1773 return SCSI_MLQUEUE_DEVICE_BUSY;
... ... @@ -1795,7 +1795,7 @@
1795 1795 printk("53c700: scsi%d, command ", SCp->device->host->host_no);
1796 1796 scsi_print_command(SCp);
1797 1797 #endif
1798   - if(blk_rq_tagged(SCp->request)
  1798 + if ((SCp->flags & SCMD_TAGGED)
1799 1799 && (hostdata->tag_negotiated &(1<<scmd_id(SCp))) == 0
1800 1800 && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_START_TAG_NEGOTIATION) {
1801 1801 scmd_printk(KERN_ERR, SCp, "Enabling Tag Command Queuing\n");
... ... @@ -1809,7 +1809,7 @@
1809 1809 *
1810 1810 * FIXME: This will royally screw up on multiple LUN devices
1811 1811 * */
1812   - if(!blk_rq_tagged(SCp->request)
  1812 + if (!(SCp->flags & SCMD_TAGGED)
1813 1813 && (hostdata->tag_negotiated &(1<<scmd_id(SCp)))) {
1814 1814 scmd_printk(KERN_INFO, SCp, "Disabling Tag Command Queuing\n");
1815 1815 hostdata->tag_negotiated &= ~(1<<scmd_id(SCp));
drivers/scsi/aic7xxx/aic7xxx_osm.c
... ... @@ -1447,7 +1447,7 @@
1447 1447 * we are storing a full busy target *lun*
1448 1448 * table in SCB space.
1449 1449 */
1450   - if (!blk_rq_tagged(cmd->request)
  1450 + if (!(cmd->flags & SCMD_TAGGED)
1451 1451 && (ahc->features & AHC_SCB_BTT) == 0) {
1452 1452 int target_offset;
1453 1453  
drivers/scsi/scsi_lib.c
... ... @@ -1740,7 +1740,7 @@
1740 1740 * we add the dev to the starved list so it eventually gets
1741 1741 * a run when a tag is freed.
1742 1742 */
1743   - if (blk_queue_tagged(q) && !blk_rq_tagged(req)) {
  1743 + if (blk_queue_tagged(q) && !(req->cmd_flags & REQ_QUEUED)) {
1744 1744 spin_lock_irq(shost->host_lock);
1745 1745 if (list_empty(&sdev->starved_entry))
1746 1746 list_add_tail(&sdev->starved_entry,
... ... @@ -1754,6 +1754,11 @@
1754 1754  
1755 1755 if (!scsi_host_queue_ready(q, shost, sdev))
1756 1756 goto host_not_ready;
  1757 +
  1758 + if (sdev->simple_tags)
  1759 + cmd->flags |= SCMD_TAGGED;
  1760 + else
  1761 + cmd->flags &= ~SCMD_TAGGED;
1757 1762  
1758 1763 /*
1759 1764 * Finally, initialize any error handling parameters, and set up
1760 1765  
... ... @@ -1908,10 +1913,10 @@
1908 1913 blk_mq_start_request(req);
1909 1914 }
1910 1915  
1911   - if (blk_queue_tagged(q))
1912   - req->cmd_flags |= REQ_QUEUED;
  1916 + if (sdev->simple_tags)
  1917 + cmd->flags |= SCMD_TAGGED;
1913 1918 else
1914   - req->cmd_flags &= ~REQ_QUEUED;
  1919 + cmd->flags &= ~SCMD_TAGGED;
1915 1920  
1916 1921 scsi_init_cmd_errh(cmd);
1917 1922 cmd->scsi_done = scsi_mq_done;
drivers/usb/storage/uas.c
... ... @@ -181,7 +181,7 @@
181 181 {
182 182 int tag;
183 183  
184   - if (blk_rq_tagged(cmnd->request))
  184 + if (cmnd->flags & SCMD_TAGGED)
185 185 tag = cmnd->request->tag + 2;
186 186 else
187 187 tag = 1;
include/linux/blkdev.h
... ... @@ -1136,7 +1136,6 @@
1136 1136 /*
1137 1137 * tag stuff
1138 1138 */
1139   -#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
1140 1139 extern int blk_queue_start_tag(struct request_queue *, struct request *);
1141 1140 extern struct request *blk_queue_find_tag(struct request_queue *, int);
1142 1141 extern void blk_queue_end_tag(struct request_queue *, struct request *);
include/scsi/scsi_cmnd.h
... ... @@ -53,6 +53,9 @@
53 53 volatile int phase;
54 54 };
55 55  
  56 +/* for scmd->flags */
  57 +#define SCMD_TAGGED (1 << 0)
  58 +
56 59 struct scsi_cmnd {
57 60 struct scsi_device *device;
58 61 struct list_head list; /* scsi_cmnd participates in queue lists */
... ... @@ -132,6 +135,7 @@
132 135 * to be at an address < 16Mb). */
133 136  
134 137 int result; /* Status code from lower level driver */
  138 + int flags; /* Command flags */
135 139  
136 140 unsigned char tag; /* SCSI-II queued command tag */
137 141 };
include/scsi/scsi_tcq.h
... ... @@ -101,11 +101,9 @@
101 101 **/
102 102 static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg)
103 103 {
104   - struct request *req = cmd->request;
105   -
106   - if (blk_rq_tagged(req)) {
  104 + if (cmd->flags & SCMD_TAGGED) {
107 105 *msg++ = MSG_SIMPLE_TAG;
108   - *msg++ = req->tag;
  106 + *msg++ = cmd->request->tag;
109 107 return 2;
110 108 }
111 109