diff options
| author | Shaohua Li <shli@fb.com> | 2015-01-15 20:32:25 -0500 |
|---|---|---|
| committer | Jens Axboe <axboe@fb.com> | 2015-01-23 16:15:46 -0500 |
| commit | ee1b6f7aff94019c09e73837054979063f722046 (patch) | |
| tree | 79c7b943d7c6d62fec1874afd2c50964de054aa0 /include | |
| parent | bb5c3cdda37aad22996d6da2addd58cadc0436c0 (diff) | |
block: support different tag allocation policy
The libata tag allocation is using a round-robin policy. Next patch will
make libata use block generic tag allocation, so let's add a policy to
tag allocation.
Currently two policies: FIFO (default) and round-robin.
Cc: Jens Axboe <axboe@fb.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/blkdev.h | 8 | ||||
| -rw-r--r-- | include/scsi/scsi_host.h | 3 | ||||
| -rw-r--r-- | include/scsi/scsi_tcq.h | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 4c4b732d7556..6f388fd1c11c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -272,7 +272,11 @@ struct blk_queue_tag { | |||
| 272 | int max_depth; /* what we will send to device */ | 272 | int max_depth; /* what we will send to device */ |
| 273 | int real_max_depth; /* what the array can hold */ | 273 | int real_max_depth; /* what the array can hold */ |
| 274 | atomic_t refcnt; /* map can be shared */ | 274 | atomic_t refcnt; /* map can be shared */ |
| 275 | int alloc_policy; /* tag allocation policy */ | ||
| 276 | int next_tag; /* next tag */ | ||
| 275 | }; | 277 | }; |
| 278 | #define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */ | ||
| 279 | #define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */ | ||
| 276 | 280 | ||
| 277 | #define BLK_SCSI_MAX_CMDS (256) | 281 | #define BLK_SCSI_MAX_CMDS (256) |
| 278 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) | 282 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) |
| @@ -1139,11 +1143,11 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) | |||
| 1139 | extern int blk_queue_start_tag(struct request_queue *, struct request *); | 1143 | extern int blk_queue_start_tag(struct request_queue *, struct request *); |
| 1140 | extern struct request *blk_queue_find_tag(struct request_queue *, int); | 1144 | extern struct request *blk_queue_find_tag(struct request_queue *, int); |
| 1141 | extern void blk_queue_end_tag(struct request_queue *, struct request *); | 1145 | extern void blk_queue_end_tag(struct request_queue *, struct request *); |
| 1142 | extern int blk_queue_init_tags(struct request_queue *, int, struct blk_queue_tag *); | 1146 | extern int blk_queue_init_tags(struct request_queue *, int, struct blk_queue_tag *, int); |
| 1143 | extern void blk_queue_free_tags(struct request_queue *); | 1147 | extern void blk_queue_free_tags(struct request_queue *); |
| 1144 | extern int blk_queue_resize_tags(struct request_queue *, int); | 1148 | extern int blk_queue_resize_tags(struct request_queue *, int); |
| 1145 | extern void blk_queue_invalidate_tags(struct request_queue *); | 1149 | extern void blk_queue_invalidate_tags(struct request_queue *); |
| 1146 | extern struct blk_queue_tag *blk_init_tags(int); | 1150 | extern struct blk_queue_tag *blk_init_tags(int, int); |
| 1147 | extern void blk_free_tags(struct blk_queue_tag *); | 1151 | extern void blk_free_tags(struct blk_queue_tag *); |
| 1148 | 1152 | ||
| 1149 | static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, | 1153 | static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, |
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 019e66858ce6..e113c757d555 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
| @@ -402,6 +402,9 @@ struct scsi_host_template { | |||
| 402 | */ | 402 | */ |
| 403 | unsigned char present; | 403 | unsigned char present; |
| 404 | 404 | ||
| 405 | /* If use block layer to manage tags, this is tag allocation policy */ | ||
| 406 | int tag_alloc_policy; | ||
| 407 | |||
| 405 | /* | 408 | /* |
| 406 | * Let the block layer assigns tags to all commands. | 409 | * Let the block layer assigns tags to all commands. |
| 407 | */ | 410 | */ |
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index 9708b28bd2aa..b27977e8aaed 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h | |||
| @@ -66,7 +66,8 @@ static inline int scsi_init_shared_tag_map(struct Scsi_Host *shost, int depth) | |||
| 66 | * devices on the shared host (for libata) | 66 | * devices on the shared host (for libata) |
| 67 | */ | 67 | */ |
| 68 | if (!shost->bqt) { | 68 | if (!shost->bqt) { |
| 69 | shost->bqt = blk_init_tags(depth); | 69 | shost->bqt = blk_init_tags(depth, |
| 70 | shost->hostt->tag_alloc_policy); | ||
| 70 | if (!shost->bqt) | 71 | if (!shost->bqt) |
| 71 | return -ENOMEM; | 72 | return -ENOMEM; |
| 72 | } | 73 | } |
