Merge tag 'for-linus-20190420' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"A set of small fixes that should go into this series. This contains:

- Removal of unused queue member (Hou)

- Overflow bvec fix (Ming)

- Various little io_uring tweaks (me)
- kthread parking
- Only call cpu_possible() for verified CPU
- Drop unused 'file' argument to io_file_put()
- io_uring_enter vs io_uring_register deadlock fix
- CQ overflow fix

- BFQ internal depth update fix (me)"

* tag 'for-linus-20190420' of git://git.kernel.dk/linux-block:
block: make sure that bvec length can't be overflow
block: kill all_q_node in request_queue
io_uring: fix CQ overflow condition
io_uring: fix possible deadlock between io_uring_{enter,register}
io_uring: drop io_file_put() 'file' argument
bfq: update internal depth state when queue depth changes
io_uring: only test SQPOLL cpu after we've verified it
io_uring: park SQPOLL thread if it's percpu

Changed files
+43 -15
block
fs
include
+7 -1
block/bfq-iosched.c
··· 5396 5396 return min_shallow; 5397 5397 } 5398 5398 5399 - static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index) 5399 + static void bfq_depth_updated(struct blk_mq_hw_ctx *hctx) 5400 5400 { 5401 5401 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; 5402 5402 struct blk_mq_tags *tags = hctx->sched_tags; ··· 5404 5404 5405 5405 min_shallow = bfq_update_depths(bfqd, &tags->bitmap_tags); 5406 5406 sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, min_shallow); 5407 + } 5408 + 5409 + static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index) 5410 + { 5411 + bfq_depth_updated(hctx); 5407 5412 return 0; 5408 5413 } 5409 5414 ··· 5831 5826 .requests_merged = bfq_requests_merged, 5832 5827 .request_merged = bfq_request_merged, 5833 5828 .has_work = bfq_has_work, 5829 + .depth_updated = bfq_depth_updated, 5834 5830 .init_hctx = bfq_init_hctx, 5835 5831 .init_sched = bfq_init_queue, 5836 5832 .exit_sched = bfq_exit_queue,
+2
block/blk-mq.c
··· 3135 3135 } 3136 3136 if (ret) 3137 3137 break; 3138 + if (q->elevator && q->elevator->type->ops.depth_updated) 3139 + q->elevator->type->ops.depth_updated(hctx); 3138 3140 } 3139 3141 3140 3142 if (!ret)
+30 -11
fs/io_uring.c
··· 338 338 tail = ctx->cached_cq_tail; 339 339 /* See comment at the top of the file */ 340 340 smp_rmb(); 341 - if (tail + 1 == READ_ONCE(ring->r.head)) 341 + if (tail - READ_ONCE(ring->r.head) == ring->ring_entries) 342 342 return NULL; 343 343 344 344 ctx->cached_cq_tail++; ··· 682 682 list_add_tail(&req->list, &ctx->poll_list); 683 683 } 684 684 685 - static void io_file_put(struct io_submit_state *state, struct file *file) 685 + static void io_file_put(struct io_submit_state *state) 686 686 { 687 - if (!state) { 688 - fput(file); 689 - } else if (state->file) { 687 + if (state->file) { 690 688 int diff = state->has_refs - state->used_refs; 691 689 692 690 if (diff) ··· 709 711 state->ios_left--; 710 712 return state->file; 711 713 } 712 - io_file_put(state, NULL); 714 + io_file_put(state); 713 715 } 714 716 state->file = fget_many(fd, state->ios_left); 715 717 if (!state->file) ··· 1669 1671 static void io_submit_state_end(struct io_submit_state *state) 1670 1672 { 1671 1673 blk_finish_plug(&state->plug); 1672 - io_file_put(state, NULL); 1674 + io_file_put(state); 1673 1675 if (state->free_reqs) 1674 1676 kmem_cache_free_bulk(req_cachep, state->free_reqs, 1675 1677 &state->reqs[state->cur_req]); ··· 1918 1920 unuse_mm(cur_mm); 1919 1921 mmput(cur_mm); 1920 1922 } 1923 + 1924 + if (kthread_should_park()) 1925 + kthread_parkme(); 1926 + 1921 1927 return 0; 1922 1928 } 1923 1929 ··· 2056 2054 if (ctx->sqo_thread) { 2057 2055 ctx->sqo_stop = 1; 2058 2056 mb(); 2057 + kthread_park(ctx->sqo_thread); 2059 2058 kthread_stop(ctx->sqo_thread); 2060 2059 ctx->sqo_thread = NULL; 2061 2060 } ··· 2239 2236 mmgrab(current->mm); 2240 2237 ctx->sqo_mm = current->mm; 2241 2238 2242 - ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle); 2243 - if (!ctx->sq_thread_idle) 2244 - ctx->sq_thread_idle = HZ; 2245 - 2246 2239 ret = -EINVAL; 2247 2240 if (!cpu_possible(p->sq_thread_cpu)) 2248 2241 goto err; ··· 2248 2249 if (!capable(CAP_SYS_ADMIN)) 2249 2250 goto err; 2250 2251 2252 + ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle); 2253 + if (!ctx->sq_thread_idle) 2254 + ctx->sq_thread_idle = HZ; 2255 + 2251 2256 if (p->flags & IORING_SETUP_SQ_AFF) { 2252 2257 int cpu; 2253 2258 2254 2259 cpu = array_index_nospec(p->sq_thread_cpu, NR_CPUS); 2260 + ret = -EINVAL; 2261 + if (!cpu_possible(p->sq_thread_cpu)) 2262 + goto err; 2263 + 2255 2264 ctx->sqo_thread = kthread_create_on_cpu(io_sq_thread, 2256 2265 ctx, cpu, 2257 2266 "io_uring-sq"); ··· 2929 2922 2930 2923 static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, 2931 2924 void __user *arg, unsigned nr_args) 2925 + __releases(ctx->uring_lock) 2926 + __acquires(ctx->uring_lock) 2932 2927 { 2933 2928 int ret; 2934 2929 2935 2930 percpu_ref_kill(&ctx->refs); 2931 + 2932 + /* 2933 + * Drop uring mutex before waiting for references to exit. If another 2934 + * thread is currently inside io_uring_enter() it might need to grab 2935 + * the uring_lock to make progress. If we hold it here across the drain 2936 + * wait, then we can deadlock. It's safe to drop the mutex here, since 2937 + * no new references will come in after we've killed the percpu ref. 2938 + */ 2939 + mutex_unlock(&ctx->uring_lock); 2936 2940 wait_for_completion(&ctx->ctx_done); 2941 + mutex_lock(&ctx->uring_lock); 2937 2942 2938 2943 switch (opcode) { 2939 2944 case IORING_REGISTER_BUFFERS:
-1
include/linux/blkdev.h
··· 548 548 struct rcu_head rcu_head; 549 549 wait_queue_head_t mq_freeze_wq; 550 550 struct percpu_ref q_usage_counter; 551 - struct list_head all_q_node; 552 551 553 552 struct blk_mq_tag_set *tag_set; 554 553 struct list_head tag_set_list;
+3 -2
include/linux/bvec.h
··· 160 160 bv->bv_page = nth_page(bv->bv_page, 1); 161 161 bv->bv_offset = 0; 162 162 } else { 163 - bv->bv_page = bvec->bv_page; 164 - bv->bv_offset = bvec->bv_offset; 163 + bv->bv_page = bvec_nth_page(bvec->bv_page, bvec->bv_offset / 164 + PAGE_SIZE); 165 + bv->bv_offset = bvec->bv_offset & ~PAGE_MASK; 165 166 } 166 167 bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, 167 168 bvec->bv_len - iter_all->done);
+1
include/linux/elevator.h
··· 31 31 void (*exit_sched)(struct elevator_queue *); 32 32 int (*init_hctx)(struct blk_mq_hw_ctx *, unsigned int); 33 33 void (*exit_hctx)(struct blk_mq_hw_ctx *, unsigned int); 34 + void (*depth_updated)(struct blk_mq_hw_ctx *); 34 35 35 36 bool (*allow_merge)(struct request_queue *, struct request *, struct bio *); 36 37 bool (*bio_merge)(struct blk_mq_hw_ctx *, struct bio *);