aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-11-03 06:47:47 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-12 05:19:40 -0500
commit125c99bc8b6b108d251169a86324a7ed3c6f3cce (patch)
tree58c721993e8b2be80e2993ea864529923c904b29
parenta62182f338b39a22035531c6afc0a8d2928b1df2 (diff)
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>
-rw-r--r--Documentation/block/biodoc.txt4
-rw-r--r--block/blk-core.c4
-rw-r--r--drivers/scsi/53c700.c6
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c2
-rw-r--r--drivers/scsi/scsi_lib.c13
-rw-r--r--drivers/usb/storage/uas.c2
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/scsi/scsi_cmnd.h4
-rw-r--r--include/scsi/scsi_tcq.h6
9 files changed, 22 insertions, 20 deletions
diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
index 2101e718670d..6b972b287795 100644
--- a/Documentation/block/biodoc.txt
+++ b/Documentation/block/biodoc.txt
@@ -827,10 +827,6 @@ but in the event of any barrier requests in the tag queue we need to ensure
827that requests are restarted in the order they were queue. This may happen 827that requests are restarted in the order they were queue. This may happen
828if the driver needs to use blk_queue_invalidate_tags(). 828if the driver needs to use blk_queue_invalidate_tags().
829 829
830Tagging also defines a new request flag, REQ_QUEUED. This is set whenever
831a request is currently tagged. You should not use this flag directly,
832blk_rq_tagged(rq) is the portable way to do so.
833
8343.3 I/O Submission 8303.3 I/O Submission
835 831
836The routine submit_bio() is used to submit a single io. Higher level i/o 832The routine submit_bio() is used to submit a single io. Higher level i/o
diff --git a/block/blk-core.c b/block/blk-core.c
index 0421b53e6431..2e7424b42947 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1266,7 +1266,7 @@ void blk_requeue_request(struct request_queue *q, struct request *rq)
1266 blk_clear_rq_complete(rq); 1266 blk_clear_rq_complete(rq);
1267 trace_block_rq_requeue(q, rq); 1267 trace_block_rq_requeue(q, rq);
1268 1268
1269 if (blk_rq_tagged(rq)) 1269 if (rq->cmd_flags & REQ_QUEUED)
1270 blk_queue_end_tag(q, rq); 1270 blk_queue_end_tag(q, rq);
1271 1271
1272 BUG_ON(blk_queued_rq(rq)); 1272 BUG_ON(blk_queued_rq(rq));
@@ -2554,7 +2554,7 @@ EXPORT_SYMBOL_GPL(blk_unprep_request);
2554 */ 2554 */
2555void blk_finish_request(struct request *req, int error) 2555void blk_finish_request(struct request *req, int error)
2556{ 2556{
2557 if (blk_rq_tagged(req)) 2557 if (req->cmd_flags & REQ_QUEUED)
2558 blk_queue_end_tag(req->q, req); 2558 blk_queue_end_tag(req->q, req);
2559 2559
2560 BUG_ON(blk_queued_rq(req)); 2560 BUG_ON(blk_queued_rq(req));
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 474cc6dc98e2..5143d3213e86 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -1767,7 +1767,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
1767 */ 1767 */
1768 if(NCR_700_get_depth(SCp->device) != 0 1768 if(NCR_700_get_depth(SCp->device) != 0
1769 && (!(hostdata->tag_negotiated & (1<<scmd_id(SCp))) 1769 && (!(hostdata->tag_negotiated & (1<<scmd_id(SCp)))
1770 || !blk_rq_tagged(SCp->request))) { 1770 || !(SCp->flags & SCMD_TAGGED))) {
1771 CDEBUG(KERN_ERR, SCp, "has non zero depth %d\n", 1771 CDEBUG(KERN_ERR, SCp, "has non zero depth %d\n",
1772 NCR_700_get_depth(SCp->device)); 1772 NCR_700_get_depth(SCp->device));
1773 return SCSI_MLQUEUE_DEVICE_BUSY; 1773 return SCSI_MLQUEUE_DEVICE_BUSY;
@@ -1795,7 +1795,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
1795 printk("53c700: scsi%d, command ", SCp->device->host->host_no); 1795 printk("53c700: scsi%d, command ", SCp->device->host->host_no);
1796 scsi_print_command(SCp); 1796 scsi_print_command(SCp);
1797#endif 1797#endif
1798 if(blk_rq_tagged(SCp->request) 1798 if ((SCp->flags & SCMD_TAGGED)
1799 && (hostdata->tag_negotiated &(1<<scmd_id(SCp))) == 0 1799 && (hostdata->tag_negotiated &(1<<scmd_id(SCp))) == 0
1800 && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_START_TAG_NEGOTIATION) { 1800 && NCR_700_get_tag_neg_state(SCp->device) == NCR_700_START_TAG_NEGOTIATION) {
1801 scmd_printk(KERN_ERR, SCp, "Enabling Tag Command Queuing\n"); 1801 scmd_printk(KERN_ERR, SCp, "Enabling Tag Command Queuing\n");
@@ -1809,7 +1809,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
1809 * 1809 *
1810 * FIXME: This will royally screw up on multiple LUN devices 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 && (hostdata->tag_negotiated &(1<<scmd_id(SCp)))) { 1813 && (hostdata->tag_negotiated &(1<<scmd_id(SCp)))) {
1814 scmd_printk(KERN_INFO, SCp, "Disabling Tag Command Queuing\n"); 1814 scmd_printk(KERN_INFO, SCp, "Disabling Tag Command Queuing\n");
1815 hostdata->tag_negotiated &= ~(1<<scmd_id(SCp)); 1815 hostdata->tag_negotiated &= ~(1<<scmd_id(SCp));
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d2c9bf39033d..63bae7c65c9f 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1447,7 +1447,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
1447 * we are storing a full busy target *lun* 1447 * we are storing a full busy target *lun*
1448 * table in SCB space. 1448 * table in SCB space.
1449 */ 1449 */
1450 if (!blk_rq_tagged(cmd->request) 1450 if (!(cmd->flags & SCMD_TAGGED)
1451 && (ahc->features & AHC_SCB_BTT) == 0) { 1451 && (ahc->features & AHC_SCB_BTT) == 0) {
1452 int target_offset; 1452 int target_offset;
1453 1453
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 38f8c85957b6..994eb083fff9 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1740,7 +1740,7 @@ static void scsi_request_fn(struct request_queue *q)
1740 * we add the dev to the starved list so it eventually gets 1740 * we add the dev to the starved list so it eventually gets
1741 * a run when a tag is freed. 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 spin_lock_irq(shost->host_lock); 1744 spin_lock_irq(shost->host_lock);
1745 if (list_empty(&sdev->starved_entry)) 1745 if (list_empty(&sdev->starved_entry))
1746 list_add_tail(&sdev->starved_entry, 1746 list_add_tail(&sdev->starved_entry,
@@ -1754,6 +1754,11 @@ static void scsi_request_fn(struct request_queue *q)
1754 1754
1755 if (!scsi_host_queue_ready(q, shost, sdev)) 1755 if (!scsi_host_queue_ready(q, shost, sdev))
1756 goto host_not_ready; 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 * Finally, initialize any error handling parameters, and set up 1764 * Finally, initialize any error handling parameters, and set up
@@ -1908,10 +1913,10 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req,
1908 blk_mq_start_request(req); 1913 blk_mq_start_request(req);
1909 } 1914 }
1910 1915
1911 if (blk_queue_tagged(q)) 1916 if (sdev->simple_tags)
1912 req->cmd_flags |= REQ_QUEUED; 1917 cmd->flags |= SCMD_TAGGED;
1913 else 1918 else
1914 req->cmd_flags &= ~REQ_QUEUED; 1919 cmd->flags &= ~SCMD_TAGGED;
1915 1920
1916 scsi_init_cmd_errh(cmd); 1921 scsi_init_cmd_errh(cmd);
1917 cmd->scsi_done = scsi_mq_done; 1922 cmd->scsi_done = scsi_mq_done;
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 89b24349269e..b38bc1318a60 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -181,7 +181,7 @@ static int uas_get_tag(struct scsi_cmnd *cmnd)
181{ 181{
182 int tag; 182 int tag;
183 183
184 if (blk_rq_tagged(cmnd->request)) 184 if (cmnd->flags & SCMD_TAGGED)
185 tag = cmnd->request->tag + 2; 185 tag = cmnd->request->tag + 2;
186 else 186 else
187 tag = 1; 187 tag = 1;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index aac0f9ea952a..6d76b8b4aa2b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1136,7 +1136,6 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk)
1136/* 1136/*
1137 * tag stuff 1137 * tag stuff
1138 */ 1138 */
1139#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
1140extern int blk_queue_start_tag(struct request_queue *, struct request *); 1139extern int blk_queue_start_tag(struct request_queue *, struct request *);
1141extern struct request *blk_queue_find_tag(struct request_queue *, int); 1140extern struct request *blk_queue_find_tag(struct request_queue *, int);
1142extern void blk_queue_end_tag(struct request_queue *, struct request *); 1141extern void blk_queue_end_tag(struct request_queue *, struct request *);
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 522a5f27f553..e119142e565e 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -53,6 +53,9 @@ struct scsi_pointer {
53 volatile int phase; 53 volatile int phase;
54}; 54};
55 55
56/* for scmd->flags */
57#define SCMD_TAGGED (1 << 0)
58
56struct scsi_cmnd { 59struct scsi_cmnd {
57 struct scsi_device *device; 60 struct scsi_device *device;
58 struct list_head list; /* scsi_cmnd participates in queue lists */ 61 struct list_head list; /* scsi_cmnd participates in queue lists */
@@ -132,6 +135,7 @@ struct scsi_cmnd {
132 * to be at an address < 16Mb). */ 135 * to be at an address < 16Mb). */
133 136
134 int result; /* Status code from lower level driver */ 137 int result; /* Status code from lower level driver */
138 int flags; /* Command flags */
135 139
136 unsigned char tag; /* SCSI-II queued command tag */ 140 unsigned char tag; /* SCSI-II queued command tag */
137}; 141};
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index 1712dab6e00e..032df74b66d7 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -101,11 +101,9 @@ static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
101 **/ 101 **/
102static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) 102static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg)
103{ 103{
104 struct request *req = cmd->request; 104 if (cmd->flags & SCMD_TAGGED) {
105
106 if (blk_rq_tagged(req)) {
107 *msg++ = MSG_SIMPLE_TAG; 105 *msg++ = MSG_SIMPLE_TAG;
108 *msg++ = req->tag; 106 *msg++ = cmd->request->tag;
109 return 2; 107 return 2;
110 } 108 }
111 109