aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-11 11:41:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-11 11:41:17 -0400
commit23d4ed53b7342bf5999b3ea227d9f69e75e5a625 (patch)
tree86229fb558235c2f742b35c0c66d5d98003f5f6e /block
parente413a19a8ef49ae3b76310bb569dabe66b22f5a3 (diff)
parenta2d445d440003f2d70ee4cd4970ea82ace616fee (diff)
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "Final small batch of fixes to be included before -rc1. Some general cleanups in here as well, but some of the blk-mq fixes we need for the NVMe conversion and/or scsi-mq. The pull request contains: - Support for not merging across a specified "chunk size", if set by the driver. Some NVMe devices perform poorly for IO that crosses such a chunk, so we need to support it generically as part of request merging avoid having to do complicated split logic. From me. - Bump max tag depth to 10Ki tags. Some scsi devices have a huge shared tag space. Before we failed with EINVAL if a too large tag depth was specified, now we truncate it and pass back the actual value. From me. - Various blk-mq rq init fixes from me and others. - A fix for enter on a dying queue for blk-mq from Keith. This is needed to prevent oopsing on hot device removal. - Fixup for blk-mq timer addition from Ming Lei. - Small round of performance fixes for mtip32xx from Sam Bradshaw. - Minor stack leak fix from Rickard Strandqvist. - Two __init annotations from Fabian Frederick" * 'for-linus' of git://git.kernel.dk/linux-block: block: add __init to blkcg_policy_register block: add __init to elv_register block: ensure that bio_add_page() always accepts a page for an empty bio blk-mq: add timer in blk_mq_start_request blk-mq: always initialize request->start_time block: blk-exec.c: Cleaning up local variable address returnd mtip32xx: minor performance enhancements blk-mq: ->timeout should be cleared in blk_mq_rq_ctx_init() blk-mq: don't allow queue entering for a dying queue blk-mq: bump max tag depth to 10K tags block: add blk_rq_set_block_pc() block: add notion of a chunk size for request merging
Diffstat (limited to 'block')
-rw-r--r--block/bio.c8
-rw-r--r--block/blk-cgroup.c2
-rw-r--r--block/blk-cgroup.h4
-rw-r--r--block/blk-core.c18
-rw-r--r--block/blk-exec.c5
-rw-r--r--block/blk-mq.c43
-rw-r--r--block/blk-settings.c21
-rw-r--r--block/bsg.c3
-rw-r--r--block/elevator.c2
-rw-r--r--block/scsi_ioctl.c6
10 files changed, 81 insertions, 31 deletions
diff --git a/block/bio.c b/block/bio.c
index 1ba33657160f..8c2e55e39a1b 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -849,7 +849,13 @@ int bio_add_page(struct bio *bio, struct page *page, unsigned int len,
849 unsigned int offset) 849 unsigned int offset)
850{ 850{
851 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 851 struct request_queue *q = bdev_get_queue(bio->bi_bdev);
852 return __bio_add_page(q, bio, page, len, offset, queue_max_sectors(q)); 852 unsigned int max_sectors;
853
854 max_sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
855 if ((max_sectors < (len >> 9)) && !bio->bi_iter.bi_size)
856 max_sectors = len >> 9;
857
858 return __bio_add_page(q, bio, page, len, offset, max_sectors);
853} 859}
854EXPORT_SYMBOL(bio_add_page); 860EXPORT_SYMBOL(bio_add_page);
855 861
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 9f5bce33e6fe..069bc202ffe3 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1093,7 +1093,7 @@ EXPORT_SYMBOL_GPL(blkcg_deactivate_policy);
1093 * Register @pol with blkcg core. Might sleep and @pol may be modified on 1093 * Register @pol with blkcg core. Might sleep and @pol may be modified on
1094 * successful registration. Returns 0 on success and -errno on failure. 1094 * successful registration. Returns 0 on success and -errno on failure.
1095 */ 1095 */
1096int blkcg_policy_register(struct blkcg_policy *pol) 1096int __init blkcg_policy_register(struct blkcg_policy *pol)
1097{ 1097{
1098 int i, ret; 1098 int i, ret;
1099 1099
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index d692b29c083a..cbb7f943f78a 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -145,7 +145,7 @@ void blkcg_drain_queue(struct request_queue *q);
145void blkcg_exit_queue(struct request_queue *q); 145void blkcg_exit_queue(struct request_queue *q);
146 146
147/* Blkio controller policy registration */ 147/* Blkio controller policy registration */
148int blkcg_policy_register(struct blkcg_policy *pol); 148int __init blkcg_policy_register(struct blkcg_policy *pol);
149void blkcg_policy_unregister(struct blkcg_policy *pol); 149void blkcg_policy_unregister(struct blkcg_policy *pol);
150int blkcg_activate_policy(struct request_queue *q, 150int blkcg_activate_policy(struct request_queue *q,
151 const struct blkcg_policy *pol); 151 const struct blkcg_policy *pol);
@@ -580,7 +580,7 @@ static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { ret
580static inline int blkcg_init_queue(struct request_queue *q) { return 0; } 580static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
581static inline void blkcg_drain_queue(struct request_queue *q) { } 581static inline void blkcg_drain_queue(struct request_queue *q) { }
582static inline void blkcg_exit_queue(struct request_queue *q) { } 582static inline void blkcg_exit_queue(struct request_queue *q) { }
583static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; } 583static inline int __init blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
584static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { } 584static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
585static inline int blkcg_activate_policy(struct request_queue *q, 585static inline int blkcg_activate_policy(struct request_queue *q,
586 const struct blkcg_policy *pol) { return 0; } 586 const struct blkcg_policy *pol) { return 0; }
diff --git a/block/blk-core.c b/block/blk-core.c
index 40d654861c33..9aca8c71e70b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1218,6 +1218,8 @@ struct request *blk_make_request(struct request_queue *q, struct bio *bio,
1218 if (unlikely(!rq)) 1218 if (unlikely(!rq))
1219 return ERR_PTR(-ENOMEM); 1219 return ERR_PTR(-ENOMEM);
1220 1220
1221 blk_rq_set_block_pc(rq);
1222
1221 for_each_bio(bio) { 1223 for_each_bio(bio) {
1222 struct bio *bounce_bio = bio; 1224 struct bio *bounce_bio = bio;
1223 int ret; 1225 int ret;
@@ -1235,6 +1237,22 @@ struct request *blk_make_request(struct request_queue *q, struct bio *bio,
1235EXPORT_SYMBOL(blk_make_request); 1237EXPORT_SYMBOL(blk_make_request);
1236 1238
1237/** 1239/**
1240 * blk_rq_set_block_pc - initialize a requeest to type BLOCK_PC
1241 * @rq: request to be initialized
1242 *
1243 */
1244void blk_rq_set_block_pc(struct request *rq)
1245{
1246 rq->cmd_type = REQ_TYPE_BLOCK_PC;
1247 rq->__data_len = 0;
1248 rq->__sector = (sector_t) -1;
1249 rq->bio = rq->biotail = NULL;
1250 memset(rq->__cmd, 0, sizeof(rq->__cmd));
1251 rq->cmd = rq->__cmd;
1252}
1253EXPORT_SYMBOL(blk_rq_set_block_pc);
1254
1255/**
1238 * blk_requeue_request - put a request back on queue 1256 * blk_requeue_request - put a request back on queue
1239 * @q: request queue where request should be inserted 1257 * @q: request queue where request should be inserted
1240 * @rq: request to be inserted 1258 * @rq: request to be inserted
diff --git a/block/blk-exec.c b/block/blk-exec.c
index dbf4502b1d67..f4d27b12c90b 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -132,6 +132,11 @@ int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,
132 if (rq->errors) 132 if (rq->errors)
133 err = -EIO; 133 err = -EIO;
134 134
135 if (rq->sense == sense) {
136 rq->sense = NULL;
137 rq->sense_len = 0;
138 }
139
135 return err; 140 return err;
136} 141}
137EXPORT_SYMBOL(blk_execute_rq); 142EXPORT_SYMBOL(blk_execute_rq);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4e4cd6208052..e11f5f8e0313 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -82,8 +82,10 @@ static int blk_mq_queue_enter(struct request_queue *q)
82 82
83 __percpu_counter_add(&q->mq_usage_counter, 1, 1000000); 83 __percpu_counter_add(&q->mq_usage_counter, 1, 1000000);
84 smp_wmb(); 84 smp_wmb();
85 /* we have problems to freeze the queue if it's initializing */ 85
86 if (!blk_queue_bypass(q) || !blk_queue_init_done(q)) 86 /* we have problems freezing the queue if it's initializing */
87 if (!blk_queue_dying(q) &&
88 (!blk_queue_bypass(q) || !blk_queue_init_done(q)))
87 return 0; 89 return 0;
88 90
89 __percpu_counter_add(&q->mq_usage_counter, -1, 1000000); 91 __percpu_counter_add(&q->mq_usage_counter, -1, 1000000);
@@ -183,6 +185,7 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
183 RB_CLEAR_NODE(&rq->rb_node); 185 RB_CLEAR_NODE(&rq->rb_node);
184 rq->rq_disk = NULL; 186 rq->rq_disk = NULL;
185 rq->part = NULL; 187 rq->part = NULL;
188 rq->start_time = jiffies;
186#ifdef CONFIG_BLK_CGROUP 189#ifdef CONFIG_BLK_CGROUP
187 rq->rl = NULL; 190 rq->rl = NULL;
188 set_start_time_ns(rq); 191 set_start_time_ns(rq);
@@ -202,6 +205,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
202 rq->sense = NULL; 205 rq->sense = NULL;
203 206
204 INIT_LIST_HEAD(&rq->timeout_list); 207 INIT_LIST_HEAD(&rq->timeout_list);
208 rq->timeout = 0;
209
205 rq->end_io = NULL; 210 rq->end_io = NULL;
206 rq->end_io_data = NULL; 211 rq->end_io_data = NULL;
207 rq->next_rq = NULL; 212 rq->next_rq = NULL;
@@ -406,16 +411,7 @@ static void blk_mq_start_request(struct request *rq, bool last)
406 if (unlikely(blk_bidi_rq(rq))) 411 if (unlikely(blk_bidi_rq(rq)))
407 rq->next_rq->resid_len = blk_rq_bytes(rq->next_rq); 412 rq->next_rq->resid_len = blk_rq_bytes(rq->next_rq);
408 413
409 /* 414 blk_add_timer(rq);
410 * Just mark start time and set the started bit. Due to memory
411 * ordering, we know we'll see the correct deadline as long as
412 * REQ_ATOMIC_STARTED is seen. Use the default queue timeout,
413 * unless one has been set in the request.
414 */
415 if (!rq->timeout)
416 rq->deadline = jiffies + q->rq_timeout;
417 else
418 rq->deadline = jiffies + rq->timeout;
419 415
420 /* 416 /*
421 * Mark us as started and clear complete. Complete might have been 417 * Mark us as started and clear complete. Complete might have been
@@ -967,11 +963,6 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx,
967 list_add_tail(&rq->queuelist, &ctx->rq_list); 963 list_add_tail(&rq->queuelist, &ctx->rq_list);
968 964
969 blk_mq_hctx_mark_pending(hctx, ctx); 965 blk_mq_hctx_mark_pending(hctx, ctx);
970
971 /*
972 * We do this early, to ensure we are on the right CPU.
973 */
974 blk_add_timer(rq);
975} 966}
976 967
977void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, 968void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue,
@@ -1100,10 +1091,8 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
1100{ 1091{
1101 init_request_from_bio(rq, bio); 1092 init_request_from_bio(rq, bio);
1102 1093
1103 if (blk_do_io_stat(rq)) { 1094 if (blk_do_io_stat(rq))
1104 rq->start_time = jiffies;
1105 blk_account_io_start(rq, 1); 1095 blk_account_io_start(rq, 1);
1106 }
1107} 1096}
1108 1097
1109static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx, 1098static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
@@ -1216,7 +1205,6 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
1216 1205
1217 blk_mq_bio_to_request(rq, bio); 1206 blk_mq_bio_to_request(rq, bio);
1218 blk_mq_start_request(rq, true); 1207 blk_mq_start_request(rq, true);
1219 blk_add_timer(rq);
1220 1208
1221 /* 1209 /*
1222 * For OK queue, we are done. For error, kill it. Any other 1210 * For OK queue, we are done. For error, kill it. Any other
@@ -1967,13 +1955,19 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
1967 return NOTIFY_OK; 1955 return NOTIFY_OK;
1968} 1956}
1969 1957
1958/*
1959 * Alloc a tag set to be associated with one or more request queues.
1960 * May fail with EINVAL for various error conditions. May adjust the
1961 * requested depth down, if if it too large. In that case, the set
1962 * value will be stored in set->queue_depth.
1963 */
1970int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) 1964int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
1971{ 1965{
1972 int i; 1966 int i;
1973 1967
1974 if (!set->nr_hw_queues) 1968 if (!set->nr_hw_queues)
1975 return -EINVAL; 1969 return -EINVAL;
1976 if (!set->queue_depth || set->queue_depth > BLK_MQ_MAX_DEPTH) 1970 if (!set->queue_depth)
1977 return -EINVAL; 1971 return -EINVAL;
1978 if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN) 1972 if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
1979 return -EINVAL; 1973 return -EINVAL;
@@ -1981,6 +1975,11 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
1981 if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue) 1975 if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue)
1982 return -EINVAL; 1976 return -EINVAL;
1983 1977
1978 if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
1979 pr_info("blk-mq: reduced tag depth to %u\n",
1980 BLK_MQ_MAX_DEPTH);
1981 set->queue_depth = BLK_MQ_MAX_DEPTH;
1982 }
1984 1983
1985 set->tags = kmalloc_node(set->nr_hw_queues * 1984 set->tags = kmalloc_node(set->nr_hw_queues *
1986 sizeof(struct blk_mq_tags *), 1985 sizeof(struct blk_mq_tags *),
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 5d21239bc859..f1a1795a5683 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -113,6 +113,7 @@ void blk_set_default_limits(struct queue_limits *lim)
113 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK; 113 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
114 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE; 114 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
115 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS; 115 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
116 lim->chunk_sectors = 0;
116 lim->max_write_same_sectors = 0; 117 lim->max_write_same_sectors = 0;
117 lim->max_discard_sectors = 0; 118 lim->max_discard_sectors = 0;
118 lim->discard_granularity = 0; 119 lim->discard_granularity = 0;
@@ -277,6 +278,26 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto
277EXPORT_SYMBOL(blk_queue_max_hw_sectors); 278EXPORT_SYMBOL(blk_queue_max_hw_sectors);
278 279
279/** 280/**
281 * blk_queue_chunk_sectors - set size of the chunk for this queue
282 * @q: the request queue for the device
283 * @chunk_sectors: chunk sectors in the usual 512b unit
284 *
285 * Description:
286 * If a driver doesn't want IOs to cross a given chunk size, it can set
287 * this limit and prevent merging across chunks. Note that the chunk size
288 * must currently be a power-of-2 in sectors. Also note that the block
289 * layer must accept a page worth of data at any offset. So if the
290 * crossing of chunks is a hard limitation in the driver, it must still be
291 * prepared to split single page bios.
292 **/
293void blk_queue_chunk_sectors(struct request_queue *q, unsigned int chunk_sectors)
294{
295 BUG_ON(!is_power_of_2(chunk_sectors));
296 q->limits.chunk_sectors = chunk_sectors;
297}
298EXPORT_SYMBOL(blk_queue_chunk_sectors);
299
300/**
280 * blk_queue_max_discard_sectors - set max sectors for a single discard 301 * blk_queue_max_discard_sectors - set max sectors for a single discard
281 * @q: the request queue for the device 302 * @q: the request queue for the device
282 * @max_discard_sectors: maximum number of sectors to discard 303 * @max_discard_sectors: maximum number of sectors to discard
diff --git a/block/bsg.c b/block/bsg.c
index e5214c148096..ff46addde5d8 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -196,7 +196,6 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
196 * fill in request structure 196 * fill in request structure
197 */ 197 */
198 rq->cmd_len = hdr->request_len; 198 rq->cmd_len = hdr->request_len;
199 rq->cmd_type = REQ_TYPE_BLOCK_PC;
200 199
201 rq->timeout = msecs_to_jiffies(hdr->timeout); 200 rq->timeout = msecs_to_jiffies(hdr->timeout);
202 if (!rq->timeout) 201 if (!rq->timeout)
@@ -273,6 +272,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
273 rq = blk_get_request(q, rw, GFP_KERNEL); 272 rq = blk_get_request(q, rw, GFP_KERNEL);
274 if (!rq) 273 if (!rq)
275 return ERR_PTR(-ENOMEM); 274 return ERR_PTR(-ENOMEM);
275 blk_rq_set_block_pc(rq);
276
276 ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm); 277 ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm);
277 if (ret) 278 if (ret)
278 goto out; 279 goto out;
diff --git a/block/elevator.c b/block/elevator.c
index 1e01b66a0b92..f35edddfe9b5 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -845,7 +845,7 @@ void elv_unregister_queue(struct request_queue *q)
845} 845}
846EXPORT_SYMBOL(elv_unregister_queue); 846EXPORT_SYMBOL(elv_unregister_queue);
847 847
848int elv_register(struct elevator_type *e) 848int __init elv_register(struct elevator_type *e)
849{ 849{
850 char *def = ""; 850 char *def = "";
851 851
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 9c28a5b38042..14695c6221c8 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -229,7 +229,6 @@ static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
229 * fill in request structure 229 * fill in request structure
230 */ 230 */
231 rq->cmd_len = hdr->cmd_len; 231 rq->cmd_len = hdr->cmd_len;
232 rq->cmd_type = REQ_TYPE_BLOCK_PC;
233 232
234 rq->timeout = msecs_to_jiffies(hdr->timeout); 233 rq->timeout = msecs_to_jiffies(hdr->timeout);
235 if (!rq->timeout) 234 if (!rq->timeout)
@@ -311,6 +310,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
311 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); 310 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL);
312 if (!rq) 311 if (!rq)
313 return -ENOMEM; 312 return -ENOMEM;
313 blk_rq_set_block_pc(rq);
314 314
315 if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { 315 if (blk_fill_sghdr_rq(q, rq, hdr, mode)) {
316 blk_put_request(rq); 316 blk_put_request(rq);
@@ -491,7 +491,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
491 memset(sense, 0, sizeof(sense)); 491 memset(sense, 0, sizeof(sense));
492 rq->sense = sense; 492 rq->sense = sense;
493 rq->sense_len = 0; 493 rq->sense_len = 0;
494 rq->cmd_type = REQ_TYPE_BLOCK_PC; 494 blk_rq_set_block_pc(rq);
495 495
496 blk_execute_rq(q, disk, rq, 0); 496 blk_execute_rq(q, disk, rq, 0);
497 497
@@ -524,7 +524,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
524 int err; 524 int err;
525 525
526 rq = blk_get_request(q, WRITE, __GFP_WAIT); 526 rq = blk_get_request(q, WRITE, __GFP_WAIT);
527 rq->cmd_type = REQ_TYPE_BLOCK_PC; 527 blk_rq_set_block_pc(rq);
528 rq->timeout = BLK_DEFAULT_SG_TIMEOUT; 528 rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
529 rq->cmd[0] = cmd; 529 rq->cmd[0] = cmd;
530 rq->cmd[4] = data; 530 rq->cmd[4] = data;