summaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-10-08 04:28:04 -0400
committerJames Bottomley <JBottomley@Odin.com>2015-11-09 20:11:57 -0500
commit64d513ac31bd02a3c9b69ef04444f36c196f9a9d (patch)
tree240e1bb8a92f76b53a5cc3c00e528851a488ebf8 /include/scsi
parent720ba808e9ca276919f566bbe2b4e09c79f25faa (diff)
scsi: use host wide tags by default
This patch changes the !blk-mq path to the same defaults as the blk-mq I/O path by always enabling block tagging, and always using host wide tags. We've had blk-mq available for a few releases so bugs with this mode should have been ironed out, and this ensures we get better coverage of over tagging setup over different configs. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/scsi_host.h5
-rw-r--r--include/scsi/scsi_tcq.h95
2 files changed, 20 insertions, 80 deletions
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e113c757d555..ed527121031d 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -406,11 +406,6 @@ struct scsi_host_template {
406 int tag_alloc_policy; 406 int tag_alloc_policy;
407 407
408 /* 408 /*
409 * Let the block layer assigns tags to all commands.
410 */
411 unsigned use_blk_tags:1;
412
413 /*
414 * Track QUEUE_FULL events and reduce queue depth on demand. 409 * Track QUEUE_FULL events and reduce queue depth on demand.
415 */ 410 */
416 unsigned track_queue_depth:1; 411 unsigned track_queue_depth:1;
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index b27977e8aaed..4416b1026189 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -10,91 +10,36 @@
10 10
11 11
12#ifdef CONFIG_BLOCK 12#ifdef CONFIG_BLOCK
13static inline struct scsi_cmnd *scsi_mq_find_tag(struct Scsi_Host *shost,
14 int unique_tag)
15{
16 u16 hwq = blk_mq_unique_tag_to_hwq(unique_tag);
17 struct request *req = NULL;
18
19 if (hwq < shost->tag_set.nr_hw_queues)
20 req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
21 blk_mq_unique_tag_to_tag(unique_tag));
22 return req ? (struct scsi_cmnd *)req->special : NULL;
23}
24
25/**
26 * scsi_find_tag - find a tagged command by device
27 * @SDpnt: pointer to the ScSI device
28 * @tag: tag generated by blk_mq_unique_tag()
29 *
30 * Notes:
31 * Only works with tags allocated by the generic blk layer.
32 **/
33static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag)
34{
35 struct request *req;
36
37 if (tag != SCSI_NO_TAG) {
38 if (shost_use_blk_mq(sdev->host))
39 return scsi_mq_find_tag(sdev->host, tag);
40
41 req = blk_queue_find_tag(sdev->request_queue, tag);
42 return req ? (struct scsi_cmnd *)req->special : NULL;
43 }
44
45 /* single command, look in space */
46 return sdev->current_cmnd;
47}
48
49
50/**
51 * scsi_init_shared_tag_map - create a shared tag map
52 * @shost: the host to share the tag map among all devices
53 * @depth: the total depth of the map
54 */
55static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth)
56{
57 /*
58 * We always have a shared tag map around when using blk-mq.
59 */
60 if (shost_use_blk_mq(shost))
61 return 0;
62
63 /*
64 * If the shared tag map isn't already initialized, do it now.
65 * This saves callers from having to check ->bqt when setting up
66 * devices on the shared host (for libata)
67 */
68 if (!shost->bqt) {
69 shost->bqt = blk_init_tags(depth,
70 shost->hostt->tag_alloc_policy);
71 if (!shost->bqt)
72 return -ENOMEM;
73 }
74
75 return 0;
76}
77
78/** 13/**
79 * scsi_host_find_tag - find the tagged command by host 14 * scsi_host_find_tag - find the tagged command by host
80 * @shost: pointer to scsi_host 15 * @shost: pointer to scsi_host
81 * @tag: tag generated by blk_mq_unique_tag() 16 * @tag: tag
82 * 17 *
83 * Notes: 18 * Note: for devices using multiple hardware queues tag must have been
84 * Only works with tags allocated by the generic blk layer. 19 * generated by blk_mq_unique_tag().
85 **/ 20 **/
86static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost, 21static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
87 int tag) 22 int tag)
88{ 23{
89 struct request *req; 24 struct request *req = NULL;
90 25
91 if (tag != SCSI_NO_TAG) { 26 if (tag == SCSI_NO_TAG)
92 if (shost_use_blk_mq(shost)) 27 return NULL;
93 return scsi_mq_find_tag(shost, tag); 28
29 if (shost_use_blk_mq(shost)) {
30 u16 hwq = blk_mq_unique_tag_to_hwq(tag);
31
32 if (hwq < shost->tag_set.nr_hw_queues) {
33 req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
34 blk_mq_unique_tag_to_tag(tag));
35 }
36 } else {
94 req = blk_map_queue_find_tag(shost->bqt, tag); 37 req = blk_map_queue_find_tag(shost->bqt, tag);
95 return req ? (struct scsi_cmnd *)req->special : NULL;
96 } 38 }
97 return NULL; 39
40 if (!req)
41 return NULL;
42 return req->special;
98} 43}
99 44
100#endif /* CONFIG_BLOCK */ 45#endif /* CONFIG_BLOCK */