aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-19 18:03:34 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-19 18:03:34 -0500
commit7c24d9f3b27b198c3c4dfc8327a25fb077a96219 (patch)
treef4fd5e1cb119c71b0d3b0d7e104e02eedf539aaa
parent99e38df892234aa985185fc776647bad6f9bd7a7 (diff)
parented8a9d2c816e0b0a2c5a605505e0f09ae9010dd6 (diff)
Merge branch 'for-4.5/core' of git://git.kernel.dk/linux-block
Pull core block updates from Jens Axboe: "We don't have a lot of core changes this time around, it's mostly in drivers, which will come in a subsequent pull. The cores changes include: - blk-mq - Prep patch from Christoph, changing blk_mq_alloc_request() to take flags instead of just using gfp_t for sleep/nosleep. - Doc patch from me, clarifying the difference between legacy and blk-mq for timer usage. - Fixes from Raghavendra for memory-less numa nodes, and a reuse of CPU masks. - Cleanup from Geliang Tang, using offset_in_page() instead of open coding it. - From Ilya, rename request_queue slab to it reflects what it holds, and a fix for proper use of bdgrab/put. - A real fix for the split across stripe boundaries from Keith. We yanked a broken version of this from 4.4-rc final, this one works. - From Mike Krinkin, emit a trace message when we split. - From Wei Tang, two small cleanups, not explicitly clearing memory that is already cleared" * 'for-4.5/core' of git://git.kernel.dk/linux-block: block: use bd{grab,put}() instead of open-coding block: split bios to max possible length block: add call to split trace point blk-mq: Avoid memoryless numa node encoded in hctx numa_node blk-mq: Reuse hardware context cpumask for tags blk-mq: add a flags parameter to blk_mq_alloc_request Revert "blk-flush: Queue through IO scheduler when flush not required" block: clarify blk_add_timer() use case for blk-mq bio: use offset_in_page macro block: do not initialise statics to 0 or NULL block: do not initialise globals to 0 or NULL block: rename request_queue slab cache
-rw-r--r--block/bio.c4
-rw-r--r--block/blk-core.c15
-rw-r--r--block/blk-merge.c22
-rw-r--r--block/blk-mq-cpumap.c2
-rw-r--r--block/blk-mq-tag.c11
-rw-r--r--block/blk-mq.c31
-rw-r--r--block/blk-mq.h11
-rw-r--r--block/blk-timeout.c6
-rw-r--r--block/genhd.c2
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c2
-rw-r--r--drivers/block/null_blk.c2
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/nvme/host/lightnvm.c2
-rw-r--r--drivers/nvme/host/pci.c11
-rw-r--r--fs/block_dev.c10
-rw-r--r--include/linux/blk-mq.h8
-rw-r--r--include/linux/blkdev.h2
17 files changed, 79 insertions, 64 deletions
diff --git a/block/bio.c b/block/bio.c
index 4f184d938942..dbabd48b1934 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1125,7 +1125,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
1125 int i, ret; 1125 int i, ret;
1126 int nr_pages = 0; 1126 int nr_pages = 0;
1127 unsigned int len = iter->count; 1127 unsigned int len = iter->count;
1128 unsigned int offset = map_data ? map_data->offset & ~PAGE_MASK : 0; 1128 unsigned int offset = map_data ? offset_in_page(map_data->offset) : 0;
1129 1129
1130 for (i = 0; i < iter->nr_segs; i++) { 1130 for (i = 0; i < iter->nr_segs; i++) {
1131 unsigned long uaddr; 1131 unsigned long uaddr;
@@ -1304,7 +1304,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1304 goto out_unmap; 1304 goto out_unmap;
1305 } 1305 }
1306 1306
1307 offset = uaddr & ~PAGE_MASK; 1307 offset = offset_in_page(uaddr);
1308 for (j = cur_page; j < page_limit; j++) { 1308 for (j = cur_page; j < page_limit; j++) {
1309 unsigned int bytes = PAGE_SIZE - offset; 1309 unsigned int bytes = PAGE_SIZE - offset;
1310 1310
diff --git a/block/blk-core.c b/block/blk-core.c
index 33e2f62d5062..476244d59309 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -51,7 +51,7 @@ DEFINE_IDA(blk_queue_ida);
51/* 51/*
52 * For the allocated request tables 52 * For the allocated request tables
53 */ 53 */
54struct kmem_cache *request_cachep = NULL; 54struct kmem_cache *request_cachep;
55 55
56/* 56/*
57 * For queue allocation 57 * For queue allocation
@@ -646,7 +646,7 @@ struct request_queue *blk_alloc_queue(gfp_t gfp_mask)
646} 646}
647EXPORT_SYMBOL(blk_alloc_queue); 647EXPORT_SYMBOL(blk_alloc_queue);
648 648
649int blk_queue_enter(struct request_queue *q, gfp_t gfp) 649int blk_queue_enter(struct request_queue *q, bool nowait)
650{ 650{
651 while (true) { 651 while (true) {
652 int ret; 652 int ret;
@@ -654,7 +654,7 @@ int blk_queue_enter(struct request_queue *q, gfp_t gfp)
654 if (percpu_ref_tryget_live(&q->q_usage_counter)) 654 if (percpu_ref_tryget_live(&q->q_usage_counter))
655 return 0; 655 return 0;
656 656
657 if (!gfpflags_allow_blocking(gfp)) 657 if (nowait)
658 return -EBUSY; 658 return -EBUSY;
659 659
660 ret = wait_event_interruptible(q->mq_freeze_wq, 660 ret = wait_event_interruptible(q->mq_freeze_wq,
@@ -1292,7 +1292,9 @@ static struct request *blk_old_get_request(struct request_queue *q, int rw,
1292struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask) 1292struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask)
1293{ 1293{
1294 if (q->mq_ops) 1294 if (q->mq_ops)
1295 return blk_mq_alloc_request(q, rw, gfp_mask, false); 1295 return blk_mq_alloc_request(q, rw,
1296 (gfp_mask & __GFP_DIRECT_RECLAIM) ?
1297 0 : BLK_MQ_REQ_NOWAIT);
1296 else 1298 else
1297 return blk_old_get_request(q, rw, gfp_mask); 1299 return blk_old_get_request(q, rw, gfp_mask);
1298} 1300}
@@ -2060,8 +2062,7 @@ blk_qc_t generic_make_request(struct bio *bio)
2060 do { 2062 do {
2061 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 2063 struct request_queue *q = bdev_get_queue(bio->bi_bdev);
2062 2064
2063 if (likely(blk_queue_enter(q, __GFP_DIRECT_RECLAIM) == 0)) { 2065 if (likely(blk_queue_enter(q, false) == 0)) {
2064
2065 ret = q->make_request_fn(q, bio); 2066 ret = q->make_request_fn(q, bio);
2066 2067
2067 blk_queue_exit(q); 2068 blk_queue_exit(q);
@@ -3534,7 +3535,7 @@ int __init blk_dev_init(void)
3534 request_cachep = kmem_cache_create("blkdev_requests", 3535 request_cachep = kmem_cache_create("blkdev_requests",
3535 sizeof(struct request), 0, SLAB_PANIC, NULL); 3536 sizeof(struct request), 0, SLAB_PANIC, NULL);
3536 3537
3537 blk_requestq_cachep = kmem_cache_create("blkdev_queue", 3538 blk_requestq_cachep = kmem_cache_create("request_queue",
3538 sizeof(struct request_queue), 0, SLAB_PANIC, NULL); 3539 sizeof(struct request_queue), 0, SLAB_PANIC, NULL);
3539 3540
3540 return 0; 3541 return 0;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index e01405a3e8b3..1699df5b0493 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -7,6 +7,8 @@
7#include <linux/blkdev.h> 7#include <linux/blkdev.h>
8#include <linux/scatterlist.h> 8#include <linux/scatterlist.h>
9 9
10#include <trace/events/block.h>
11
10#include "blk.h" 12#include "blk.h"
11 13
12static struct bio *blk_bio_discard_split(struct request_queue *q, 14static struct bio *blk_bio_discard_split(struct request_queue *q,
@@ -81,9 +83,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
81 struct bio *new = NULL; 83 struct bio *new = NULL;
82 84
83 bio_for_each_segment(bv, bio, iter) { 85 bio_for_each_segment(bv, bio, iter) {
84 if (sectors + (bv.bv_len >> 9) > queue_max_sectors(q))
85 goto split;
86
87 /* 86 /*
88 * If the queue doesn't support SG gaps and adding this 87 * If the queue doesn't support SG gaps and adding this
89 * offset would create a gap, disallow it. 88 * offset would create a gap, disallow it.
@@ -91,6 +90,22 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
91 if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset)) 90 if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset))
92 goto split; 91 goto split;
93 92
93 if (sectors + (bv.bv_len >> 9) >
94 blk_max_size_offset(q, bio->bi_iter.bi_sector)) {
95 /*
96 * Consider this a new segment if we're splitting in
97 * the middle of this vector.
98 */
99 if (nsegs < queue_max_segments(q) &&
100 sectors < blk_max_size_offset(q,
101 bio->bi_iter.bi_sector)) {
102 nsegs++;
103 sectors = blk_max_size_offset(q,
104 bio->bi_iter.bi_sector);
105 }
106 goto split;
107 }
108
94 if (bvprvp && blk_queue_cluster(q)) { 109 if (bvprvp && blk_queue_cluster(q)) {
95 if (seg_size + bv.bv_len > queue_max_segment_size(q)) 110 if (seg_size + bv.bv_len > queue_max_segment_size(q))
96 goto new_segment; 111 goto new_segment;
@@ -162,6 +177,7 @@ void blk_queue_split(struct request_queue *q, struct bio **bio,
162 split->bi_rw |= REQ_NOMERGE; 177 split->bi_rw |= REQ_NOMERGE;
163 178
164 bio_chain(split, *bio); 179 bio_chain(split, *bio);
180 trace_block_split(q, split, (*bio)->bi_iter.bi_sector);
165 generic_make_request(*bio); 181 generic_make_request(*bio);
166 *bio = split; 182 *bio = split;
167 } 183 }
diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
index 8764c241e5bb..d0634bcf322f 100644
--- a/block/blk-mq-cpumap.c
+++ b/block/blk-mq-cpumap.c
@@ -113,7 +113,7 @@ int blk_mq_hw_queue_to_node(unsigned int *mq_map, unsigned int index)
113 113
114 for_each_possible_cpu(i) { 114 for_each_possible_cpu(i) {
115 if (index == mq_map[i]) 115 if (index == mq_map[i])
116 return cpu_to_node(i); 116 return local_memory_node(cpu_to_node(i));
117 } 117 }
118 118
119 return NUMA_NO_NODE; 119 return NUMA_NO_NODE;
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index a07ca3488d96..abdbb47405cb 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -268,7 +268,7 @@ static int bt_get(struct blk_mq_alloc_data *data,
268 if (tag != -1) 268 if (tag != -1)
269 return tag; 269 return tag;
270 270
271 if (!gfpflags_allow_blocking(data->gfp)) 271 if (data->flags & BLK_MQ_REQ_NOWAIT)
272 return -1; 272 return -1;
273 273
274 bs = bt_wait_ptr(bt, hctx); 274 bs = bt_wait_ptr(bt, hctx);
@@ -303,7 +303,7 @@ static int bt_get(struct blk_mq_alloc_data *data,
303 data->ctx = blk_mq_get_ctx(data->q); 303 data->ctx = blk_mq_get_ctx(data->q);
304 data->hctx = data->q->mq_ops->map_queue(data->q, 304 data->hctx = data->q->mq_ops->map_queue(data->q,
305 data->ctx->cpu); 305 data->ctx->cpu);
306 if (data->reserved) { 306 if (data->flags & BLK_MQ_REQ_RESERVED) {
307 bt = &data->hctx->tags->breserved_tags; 307 bt = &data->hctx->tags->breserved_tags;
308 } else { 308 } else {
309 last_tag = &data->ctx->last_tag; 309 last_tag = &data->ctx->last_tag;
@@ -349,10 +349,9 @@ static unsigned int __blk_mq_get_reserved_tag(struct blk_mq_alloc_data *data)
349 349
350unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) 350unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)
351{ 351{
352 if (!data->reserved) 352 if (data->flags & BLK_MQ_REQ_RESERVED)
353 return __blk_mq_get_tag(data); 353 return __blk_mq_get_reserved_tag(data);
354 354 return __blk_mq_get_tag(data);
355 return __blk_mq_get_reserved_tag(data);
356} 355}
357 356
358static struct bt_wait_state *bt_wake_ptr(struct blk_mq_bitmap_tags *bt) 357static struct bt_wait_state *bt_wake_ptr(struct blk_mq_bitmap_tags *bt)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6d6f8feb48c0..6889d7183a2a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -229,8 +229,8 @@ __blk_mq_alloc_request(struct blk_mq_alloc_data *data, int rw)
229 return NULL; 229 return NULL;
230} 230}
231 231
232struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, 232struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
233 bool reserved) 233 unsigned int flags)
234{ 234{
235 struct blk_mq_ctx *ctx; 235 struct blk_mq_ctx *ctx;
236 struct blk_mq_hw_ctx *hctx; 236 struct blk_mq_hw_ctx *hctx;
@@ -238,24 +238,22 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp,
238 struct blk_mq_alloc_data alloc_data; 238 struct blk_mq_alloc_data alloc_data;
239 int ret; 239 int ret;
240 240
241 ret = blk_queue_enter(q, gfp); 241 ret = blk_queue_enter(q, flags & BLK_MQ_REQ_NOWAIT);
242 if (ret) 242 if (ret)
243 return ERR_PTR(ret); 243 return ERR_PTR(ret);
244 244
245 ctx = blk_mq_get_ctx(q); 245 ctx = blk_mq_get_ctx(q);
246 hctx = q->mq_ops->map_queue(q, ctx->cpu); 246 hctx = q->mq_ops->map_queue(q, ctx->cpu);
247 blk_mq_set_alloc_data(&alloc_data, q, gfp & ~__GFP_DIRECT_RECLAIM, 247 blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx);
248 reserved, ctx, hctx);
249 248
250 rq = __blk_mq_alloc_request(&alloc_data, rw); 249 rq = __blk_mq_alloc_request(&alloc_data, rw);
251 if (!rq && (gfp & __GFP_DIRECT_RECLAIM)) { 250 if (!rq && !(flags & BLK_MQ_REQ_NOWAIT)) {
252 __blk_mq_run_hw_queue(hctx); 251 __blk_mq_run_hw_queue(hctx);
253 blk_mq_put_ctx(ctx); 252 blk_mq_put_ctx(ctx);
254 253
255 ctx = blk_mq_get_ctx(q); 254 ctx = blk_mq_get_ctx(q);
256 hctx = q->mq_ops->map_queue(q, ctx->cpu); 255 hctx = q->mq_ops->map_queue(q, ctx->cpu);
257 blk_mq_set_alloc_data(&alloc_data, q, gfp, reserved, ctx, 256 blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx);
258 hctx);
259 rq = __blk_mq_alloc_request(&alloc_data, rw); 257 rq = __blk_mq_alloc_request(&alloc_data, rw);
260 ctx = alloc_data.ctx; 258 ctx = alloc_data.ctx;
261 } 259 }
@@ -1175,8 +1173,7 @@ static struct request *blk_mq_map_request(struct request_queue *q,
1175 rw |= REQ_SYNC; 1173 rw |= REQ_SYNC;
1176 1174
1177 trace_block_getrq(q, bio, rw); 1175 trace_block_getrq(q, bio, rw);
1178 blk_mq_set_alloc_data(&alloc_data, q, GFP_ATOMIC, false, ctx, 1176 blk_mq_set_alloc_data(&alloc_data, q, BLK_MQ_REQ_NOWAIT, ctx, hctx);
1179 hctx);
1180 rq = __blk_mq_alloc_request(&alloc_data, rw); 1177 rq = __blk_mq_alloc_request(&alloc_data, rw);
1181 if (unlikely(!rq)) { 1178 if (unlikely(!rq)) {
1182 __blk_mq_run_hw_queue(hctx); 1179 __blk_mq_run_hw_queue(hctx);
@@ -1185,8 +1182,7 @@ static struct request *blk_mq_map_request(struct request_queue *q,
1185 1182
1186 ctx = blk_mq_get_ctx(q); 1183 ctx = blk_mq_get_ctx(q);
1187 hctx = q->mq_ops->map_queue(q, ctx->cpu); 1184 hctx = q->mq_ops->map_queue(q, ctx->cpu);
1188 blk_mq_set_alloc_data(&alloc_data, q, 1185 blk_mq_set_alloc_data(&alloc_data, q, 0, ctx, hctx);
1189 __GFP_RECLAIM|__GFP_HIGH, false, ctx, hctx);
1190 rq = __blk_mq_alloc_request(&alloc_data, rw); 1186 rq = __blk_mq_alloc_request(&alloc_data, rw);
1191 ctx = alloc_data.ctx; 1187 ctx = alloc_data.ctx;
1192 hctx = alloc_data.hctx; 1188 hctx = alloc_data.hctx;
@@ -1794,7 +1790,7 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
1794 * not, we remain on the home node of the device 1790 * not, we remain on the home node of the device
1795 */ 1791 */
1796 if (nr_hw_queues > 1 && hctx->numa_node == NUMA_NO_NODE) 1792 if (nr_hw_queues > 1 && hctx->numa_node == NUMA_NO_NODE)
1797 hctx->numa_node = cpu_to_node(i); 1793 hctx->numa_node = local_memory_node(cpu_to_node(i));
1798 } 1794 }
1799} 1795}
1800 1796
@@ -1854,6 +1850,7 @@ static void blk_mq_map_swqueue(struct request_queue *q,
1854 hctx->tags = set->tags[i]; 1850 hctx->tags = set->tags[i];
1855 WARN_ON(!hctx->tags); 1851 WARN_ON(!hctx->tags);
1856 1852
1853 cpumask_copy(hctx->tags->cpumask, hctx->cpumask);
1857 /* 1854 /*
1858 * Set the map size to the number of mapped software queues. 1855 * Set the map size to the number of mapped software queues.
1859 * This is more accurate and more efficient than looping 1856 * This is more accurate and more efficient than looping
@@ -1867,14 +1864,6 @@ static void blk_mq_map_swqueue(struct request_queue *q,
1867 hctx->next_cpu = cpumask_first(hctx->cpumask); 1864 hctx->next_cpu = cpumask_first(hctx->cpumask);
1868 hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH; 1865 hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
1869 } 1866 }
1870
1871 queue_for_each_ctx(q, ctx, i) {
1872 if (!cpumask_test_cpu(i, online_mask))
1873 continue;
1874
1875 hctx = q->mq_ops->map_queue(q, i);
1876 cpumask_set_cpu(i, hctx->tags->cpumask);
1877 }
1878} 1867}
1879 1868
1880static void queue_set_hctx_shared(struct request_queue *q, bool shared) 1869static void queue_set_hctx_shared(struct request_queue *q, bool shared)
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 713820b47b31..eaede8e45c9c 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -96,8 +96,7 @@ static inline void blk_mq_put_ctx(struct blk_mq_ctx *ctx)
96struct blk_mq_alloc_data { 96struct blk_mq_alloc_data {
97 /* input parameter */ 97 /* input parameter */
98 struct request_queue *q; 98 struct request_queue *q;
99 gfp_t gfp; 99 unsigned int flags;
100 bool reserved;
101 100
102 /* input & output parameter */ 101 /* input & output parameter */
103 struct blk_mq_ctx *ctx; 102 struct blk_mq_ctx *ctx;
@@ -105,13 +104,11 @@ struct blk_mq_alloc_data {
105}; 104};
106 105
107static inline void blk_mq_set_alloc_data(struct blk_mq_alloc_data *data, 106static inline void blk_mq_set_alloc_data(struct blk_mq_alloc_data *data,
108 struct request_queue *q, gfp_t gfp, bool reserved, 107 struct request_queue *q, unsigned int flags,
109 struct blk_mq_ctx *ctx, 108 struct blk_mq_ctx *ctx, struct blk_mq_hw_ctx *hctx)
110 struct blk_mq_hw_ctx *hctx)
111{ 109{
112 data->q = q; 110 data->q = q;
113 data->gfp = gfp; 111 data->flags = flags;
114 data->reserved = reserved;
115 data->ctx = ctx; 112 data->ctx = ctx;
116 data->hctx = hctx; 113 data->hctx = hctx;
117} 114}
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index aa40aa93381b..3610af561748 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -186,6 +186,7 @@ unsigned long blk_rq_timeout(unsigned long timeout)
186 * Notes: 186 * Notes:
187 * Each request has its own timer, and as it is added to the queue, we 187 * Each request has its own timer, and as it is added to the queue, we
188 * set up the timer. When the request completes, we cancel the timer. 188 * set up the timer. When the request completes, we cancel the timer.
189 * Queue lock must be held for the non-mq case, mq case doesn't care.
189 */ 190 */
190void blk_add_timer(struct request *req) 191void blk_add_timer(struct request *req)
191{ 192{
@@ -209,6 +210,11 @@ void blk_add_timer(struct request *req)
209 req->timeout = q->rq_timeout; 210 req->timeout = q->rq_timeout;
210 211
211 req->deadline = jiffies + req->timeout; 212 req->deadline = jiffies + req->timeout;
213
214 /*
215 * Only the non-mq case needs to add the request to a protected list.
216 * For the mq case we simply scan the tag map.
217 */
212 if (!q->mq_ops) 218 if (!q->mq_ops)
213 list_add_tail(&req->timeout_list, &req->q->timeout_list); 219 list_add_tail(&req->timeout_list, &req->q->timeout_list);
214 220
diff --git a/block/genhd.c b/block/genhd.c
index 5aaeb2ad0fd3..9f42526b4d62 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1449,7 +1449,7 @@ static DEFINE_MUTEX(disk_events_mutex);
1449static LIST_HEAD(disk_events); 1449static LIST_HEAD(disk_events);
1450 1450
1451/* disable in-kernel polling by default */ 1451/* disable in-kernel polling by default */
1452static unsigned long disk_events_dfl_poll_msecs = 0; 1452static unsigned long disk_events_dfl_poll_msecs;
1453 1453
1454static unsigned long disk_events_poll_jiffies(struct gendisk *disk) 1454static unsigned long disk_events_poll_jiffies(struct gendisk *disk)
1455{ 1455{
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 34997d8ecd64..15bec407ac37 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -173,7 +173,7 @@ static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd)
173{ 173{
174 struct request *rq; 174 struct request *rq;
175 175
176 rq = blk_mq_alloc_request(dd->queue, 0, __GFP_RECLAIM, true); 176 rq = blk_mq_alloc_request(dd->queue, 0, BLK_MQ_REQ_RESERVED);
177 return blk_mq_rq_to_pdu(rq); 177 return blk_mq_rq_to_pdu(rq);
178} 178}
179 179
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 09e3c0d87ecc..95dff91135ad 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -449,7 +449,7 @@ static int null_lnvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
449 struct request *rq; 449 struct request *rq;
450 struct bio *bio = rqd->bio; 450 struct bio *bio = rqd->bio;
451 451
452 rq = blk_mq_alloc_request(q, bio_rw(bio), GFP_KERNEL, 0); 452 rq = blk_mq_alloc_request(q, bio_rw(bio), 0);
453 if (IS_ERR(rq)) 453 if (IS_ERR(rq))
454 return -ENOMEM; 454 return -ENOMEM;
455 455
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 60316fbaf295..9b9809b709a5 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -71,7 +71,7 @@ static int raw_open(struct inode *inode, struct file *filp)
71 err = -ENODEV; 71 err = -ENODEV;
72 if (!bdev) 72 if (!bdev)
73 goto out; 73 goto out;
74 igrab(bdev->bd_inode); 74 bdgrab(bdev);
75 err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open); 75 err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open);
76 if (err) 76 if (err)
77 goto out; 77 goto out;
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 15f2acb4d5cd..1af54ea20e7b 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -471,7 +471,7 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
471 struct bio *bio = rqd->bio; 471 struct bio *bio = rqd->bio;
472 struct nvme_nvm_command *cmd; 472 struct nvme_nvm_command *cmd;
473 473
474 rq = blk_mq_alloc_request(q, bio_rw(bio), GFP_KERNEL, 0); 474 rq = blk_mq_alloc_request(q, bio_rw(bio), 0);
475 if (IS_ERR(rq)) 475 if (IS_ERR(rq))
476 return -ENOMEM; 476 return -ENOMEM;
477 477
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 0c67b57be83c..f5c0e2613c7c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1041,7 +1041,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
1041 struct request *req; 1041 struct request *req;
1042 int ret; 1042 int ret;
1043 1043
1044 req = blk_mq_alloc_request(q, write, GFP_KERNEL, false); 1044 req = blk_mq_alloc_request(q, write, 0);
1045 if (IS_ERR(req)) 1045 if (IS_ERR(req))
1046 return PTR_ERR(req); 1046 return PTR_ERR(req);
1047 1047
@@ -1094,7 +1094,8 @@ static int nvme_submit_async_admin_req(struct nvme_dev *dev)
1094 struct nvme_cmd_info *cmd_info; 1094 struct nvme_cmd_info *cmd_info;
1095 struct request *req; 1095 struct request *req;
1096 1096
1097 req = blk_mq_alloc_request(dev->admin_q, WRITE, GFP_ATOMIC, true); 1097 req = blk_mq_alloc_request(dev->admin_q, WRITE,
1098 BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_RESERVED);
1098 if (IS_ERR(req)) 1099 if (IS_ERR(req))
1099 return PTR_ERR(req); 1100 return PTR_ERR(req);
1100 1101
@@ -1119,7 +1120,7 @@ static int nvme_submit_admin_async_cmd(struct nvme_dev *dev,
1119 struct request *req; 1120 struct request *req;
1120 struct nvme_cmd_info *cmd_rq; 1121 struct nvme_cmd_info *cmd_rq;
1121 1122
1122 req = blk_mq_alloc_request(dev->admin_q, WRITE, GFP_KERNEL, false); 1123 req = blk_mq_alloc_request(dev->admin_q, WRITE, 0);
1123 if (IS_ERR(req)) 1124 if (IS_ERR(req))
1124 return PTR_ERR(req); 1125 return PTR_ERR(req);
1125 1126
@@ -1320,8 +1321,8 @@ static void nvme_abort_req(struct request *req)
1320 if (!dev->abort_limit) 1321 if (!dev->abort_limit)
1321 return; 1322 return;
1322 1323
1323 abort_req = blk_mq_alloc_request(dev->admin_q, WRITE, GFP_ATOMIC, 1324 abort_req = blk_mq_alloc_request(dev->admin_q, WRITE,
1324 false); 1325 BLK_MQ_REQ_NOWAIT);
1325 if (IS_ERR(abort_req)) 1326 if (IS_ERR(abort_req))
1326 return; 1327 return;
1327 1328
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 530145b607c4..ba762ea07f67 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -400,7 +400,7 @@ int bdev_read_page(struct block_device *bdev, sector_t sector,
400 if (!ops->rw_page || bdev_get_integrity(bdev)) 400 if (!ops->rw_page || bdev_get_integrity(bdev))
401 return result; 401 return result;
402 402
403 result = blk_queue_enter(bdev->bd_queue, GFP_KERNEL); 403 result = blk_queue_enter(bdev->bd_queue, false);
404 if (result) 404 if (result)
405 return result; 405 return result;
406 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, READ); 406 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, READ);
@@ -437,7 +437,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector,
437 437
438 if (!ops->rw_page || bdev_get_integrity(bdev)) 438 if (!ops->rw_page || bdev_get_integrity(bdev))
439 return -EOPNOTSUPP; 439 return -EOPNOTSUPP;
440 result = blk_queue_enter(bdev->bd_queue, GFP_NOIO); 440 result = blk_queue_enter(bdev->bd_queue, false);
441 if (result) 441 if (result)
442 return result; 442 return result;
443 443
@@ -700,7 +700,7 @@ static struct block_device *bd_acquire(struct inode *inode)
700 spin_lock(&bdev_lock); 700 spin_lock(&bdev_lock);
701 bdev = inode->i_bdev; 701 bdev = inode->i_bdev;
702 if (bdev) { 702 if (bdev) {
703 ihold(bdev->bd_inode); 703 bdgrab(bdev);
704 spin_unlock(&bdev_lock); 704 spin_unlock(&bdev_lock);
705 return bdev; 705 return bdev;
706 } 706 }
@@ -716,7 +716,7 @@ static struct block_device *bd_acquire(struct inode *inode)
716 * So, we can access it via ->i_mapping always 716 * So, we can access it via ->i_mapping always
717 * without igrab(). 717 * without igrab().
718 */ 718 */
719 ihold(bdev->bd_inode); 719 bdgrab(bdev);
720 inode->i_bdev = bdev; 720 inode->i_bdev = bdev;
721 inode->i_mapping = bdev->bd_inode->i_mapping; 721 inode->i_mapping = bdev->bd_inode->i_mapping;
722 list_add(&inode->i_devices, &bdev->bd_inodes); 722 list_add(&inode->i_devices, &bdev->bd_inodes);
@@ -739,7 +739,7 @@ void bd_forget(struct inode *inode)
739 spin_unlock(&bdev_lock); 739 spin_unlock(&bdev_lock);
740 740
741 if (bdev) 741 if (bdev)
742 iput(bdev->bd_inode); 742 bdput(bdev);
743} 743}
744 744
745/** 745/**
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index daf17d70aeca..7fc9296b5742 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -188,8 +188,14 @@ void blk_mq_insert_request(struct request *, bool, bool, bool);
188void blk_mq_free_request(struct request *rq); 188void blk_mq_free_request(struct request *rq);
189void blk_mq_free_hctx_request(struct blk_mq_hw_ctx *, struct request *rq); 189void blk_mq_free_hctx_request(struct blk_mq_hw_ctx *, struct request *rq);
190bool blk_mq_can_queue(struct blk_mq_hw_ctx *); 190bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
191
192enum {
193 BLK_MQ_REQ_NOWAIT = (1 << 0), /* return when out of requests */
194 BLK_MQ_REQ_RESERVED = (1 << 1), /* allocate from reserved pool */
195};
196
191struct request *blk_mq_alloc_request(struct request_queue *q, int rw, 197struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
192 gfp_t gfp, bool reserved); 198 unsigned int flags);
193struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag); 199struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
194struct cpumask *blk_mq_tags_cpumask(struct blk_mq_tags *tags); 200struct cpumask *blk_mq_tags_cpumask(struct blk_mq_tags *tags);
195 201
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bfb64d672e19..d372ea87ead5 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -795,7 +795,7 @@ extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
795extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t, 795extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
796 struct scsi_ioctl_command __user *); 796 struct scsi_ioctl_command __user *);
797 797
798extern int blk_queue_enter(struct request_queue *q, gfp_t gfp); 798extern int blk_queue_enter(struct request_queue *q, bool nowait);
799extern void blk_queue_exit(struct request_queue *q); 799extern void blk_queue_exit(struct request_queue *q);
800extern void blk_start_queue(struct request_queue *q); 800extern void blk_start_queue(struct request_queue *q);
801extern void blk_start_queue_async(struct request_queue *q); 801extern void blk_start_queue_async(struct request_queue *q);