Pull block fixes from Jens Axboe: - Fix wbt performance regression introduced with the blk-rq-qos refactoring (Harshad) - Fix io_uring fileset removal inadvertently killing the workqueue (me) - Fix io_uring typo in linked command nonblock submission (Pavel) - Remove spurious io_uring wakeups on request free (Pavel) - Fix null_blk zoned command error return (Keith) - Don't use freezable workqueues for backing_dev, also means we can revert a previous libata hack (Mika) - Fix nbd sysfs mutex dropped too soon at removal time (Xiubo) * tag 'for-linus-20191010' of git://git.kernel.dk/linux-block: nbd: fix possible sysfs duplicate warning null_blk: Fix zoned command return code io_uring: only flush workqueues on fileset removal io_uring: remove wait loop spurious wakeups blk-wbt: fix performance regression in wbt scale_up/scale_down Revert "libata, freezer: avoid block device removal while system is frozen" bdi: Do not use freezable workqueue io_uring: fix reversed nonblock flag for link submission
Unified · Split
| @@ -160,24 +160,27 @@ bool rq_depth_calc_max_depth(struct rq_depth *rqd) · 159 unmodified lines | ||
| 160 | 160 | return ret; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | −void rq_depth_scale_up(struct rq_depth *rqd) | |
| 163 | +/* Returns true on success and false if scaling up wasn't possible */ | |
| 164 | +bool rq_depth_scale_up(struct rq_depth *rqd) | |
| 164 | 165 | { |
| 165 | 166 | /* |
| 166 | 167 | * Hit max in previous round, stop here |
| 167 | 168 | */ |
| 168 | 169 | if (rqd->scaled_max) |
| 169 | − return; | |
| 170 | + return false; | |
| 170 | 171 | |
| 171 | 172 | rqd->scale_step--; |
| 172 | 173 | |
| 173 | 174 | rqd->scaled_max = rq_depth_calc_max_depth(rqd); |
| 175 | + return true; | |
| 174 | 176 | } |
| 175 | 177 | |
| 176 | 178 | /* |
| 177 | 179 | * Scale rwb down. If 'hard_throttle' is set, do it quicker, since we |
| 178 | − * had a latency violation. | |
| 180 | + * had a latency violation. Returns true on success and returns false if | |
| 181 | + * scaling down wasn't possible. | |
| 179 | 182 | */ |
| 180 | −void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) | |
| 183 | +bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) | |
| 181 | 184 | { |
| 182 | 185 | /* |
| 183 | 186 | * Stop scaling down when we've hit the limit. This also prevents |
| @@ -185,7 +188,7 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) · 1 unmodified line | ||
| 185 | 188 | * keep up. |
| 186 | 189 | */ |
| 187 | 190 | if (rqd->max_depth == 1) |
| 188 | − return; | |
| 191 | + return false; | |
| 189 | 192 | |
| 190 | 193 | if (rqd->scale_step < 0 && hard_throttle) |
| 191 | 194 | rqd->scale_step = 0; |
| @@ -194,6 +197,7 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) · 2 unmodified lines | ||
| 194 | 197 | |
| 195 | 198 | rqd->scaled_max = false; |
| 196 | 199 | rq_depth_calc_max_depth(rqd); |
| 200 | + return true; | |
| 197 | 201 | } |
| 198 | 202 | |
| 199 | 203 | struct rq_qos_wait_data { |
| @@ -130,8 +130,8 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data, · 129 unmodified lines | ||
| 130 | 130 | acquire_inflight_cb_t *acquire_inflight_cb, |
| 131 | 131 | cleanup_cb_t *cleanup_cb); |
| 132 | 132 | bool rq_wait_inc_below(struct rq_wait *rq_wait, unsigned int limit); |
| 133 | −void rq_depth_scale_up(struct rq_depth *rqd); | |
| 134 | −void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle); | |
| 133 | +bool rq_depth_scale_up(struct rq_depth *rqd); | |
| 134 | +bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle); | |
| 135 | 135 | bool rq_depth_calc_max_depth(struct rq_depth *rqd); |
| 136 | 136 | |
| 137 | 137 | void __rq_qos_cleanup(struct rq_qos *rqos, struct bio *bio); |
| @@ -308,7 +308,8 @@ static void calc_wb_limits(struct rq_wb *rwb) · 307 unmodified lines | ||
| 308 | 308 | |
| 309 | 309 | static void scale_up(struct rq_wb *rwb) |
| 310 | 310 | { |
| 311 | − rq_depth_scale_up(&rwb->rq_depth); | |
| 311 | + if (!rq_depth_scale_up(&rwb->rq_depth)) | |
| 312 | + return; | |
| 312 | 313 | calc_wb_limits(rwb); |
| 313 | 314 | rwb->unknown_cnt = 0; |
| 314 | 315 | rwb_wake_all(rwb); |
| @@ -317,7 +318,8 @@ static void scale_up(struct rq_wb *rwb) · 2 unmodified lines | ||
| 317 | 318 | |
| 318 | 319 | static void scale_down(struct rq_wb *rwb, bool hard_throttle) |
| 319 | 320 | { |
| 320 | − rq_depth_scale_down(&rwb->rq_depth, hard_throttle); | |
| 321 | + if (!rq_depth_scale_down(&rwb->rq_depth, hard_throttle)) | |
| 322 | + return; | |
| 321 | 323 | calc_wb_limits(rwb); |
| 322 | 324 | rwb->unknown_cnt = 0; |
| 323 | 325 | rwb_trace_step(rwb, "scale down"); |
| @@ -4791,27 +4791,6 @@ void ata_scsi_hotplug(struct work_struct *work) · 4790 unmodified lines | ||
| 4791 | 4791 | return; |
| 4792 | 4792 | } |
| 4793 | 4793 | |
| 4794 | − /* | |
| 4795 | − * XXX - UGLY HACK | |
| 4796 | − * | |
| 4797 | − * The block layer suspend/resume path is fundamentally broken due | |
| 4798 | − * to freezable kthreads and workqueue and may deadlock if a block | |
| 4799 | − * device gets removed while resume is in progress. I don't know | |
| 4800 | − * what the solution is short of removing freezable kthreads and | |
| 4801 | − * workqueues altogether. | |
| 4802 | − * | |
| 4803 | − * The following is an ugly hack to avoid kicking off device | |
| 4804 | − * removal while freezer is active. This is a joke but does avoid | |
| 4805 | − * this particular deadlock scenario. | |
| 4806 | − * | |
| 4807 | − * https://bugzilla.kernel.org/show_bug.cgi?id=62801 | |
| 4808 | − * http://marc.info/?l=linux-kernel&m=138695698516487 | |
| 4809 | − */ | |
| 4810 | −#ifdef CONFIG_FREEZER | |
| 4811 | − while (pm_freezing) | |
| 4812 | − msleep(10); | |
| 4813 | −#endif | |
| 4814 | − | |
| 4815 | 4794 | DPRINTK("ENTER\n"); |
| 4816 | 4795 | mutex_lock(&ap->scsi_scan_mutex); |
| 4817 | 4796 | |
| @@ -248,8 +248,8 @@ static void nbd_put(struct nbd_device *nbd) · 247 unmodified lines | ||
| 248 | 248 | if (refcount_dec_and_mutex_lock(&nbd->refs, |
| 249 | 249 | &nbd_index_mutex)) { |
| 250 | 250 | idr_remove(&nbd_index_idr, nbd->index); |
| 251 | − mutex_unlock(&nbd_index_mutex); | |
| 252 | 251 | nbd_dev_remove(nbd); |
| 252 | + mutex_unlock(&nbd_index_mutex); | |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| @@ -142,8 +142,7 @@ static blk_status_t null_zone_reset(struct nullb_cmd *cmd, sector_t sector) · 141 unmodified lines | ||
| 142 | 142 | zone->wp = zone->start; |
| 143 | 143 | break; |
| 144 | 144 | default: |
| 145 | − cmd->error = BLK_STS_NOTSUPP; | |
| 146 | − break; | |
| 145 | + return BLK_STS_NOTSUPP; | |
| 147 | 146 | } |
| 148 | 147 | return BLK_STS_OK; |
| 149 | 148 | } |
| @@ -591,14 +591,6 @@ static void io_cqring_add_event(struct io_ring_ctx *ctx, u64 user_data, · 590 unmodified lines | ||
| 591 | 591 | io_cqring_ev_posted(ctx); |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | −static void io_ring_drop_ctx_refs(struct io_ring_ctx *ctx, unsigned refs) | |
| 595 | −{ | |
| 596 | − percpu_ref_put_many(&ctx->refs, refs); | |
| 597 | − | |
| 598 | − if (waitqueue_active(&ctx->wait)) | |
| 599 | − wake_up(&ctx->wait); | |
| 600 | −} | |
| 601 | − | |
| 602 | 594 | static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, |
| 603 | 595 | struct io_submit_state *state) |
| 604 | 596 | { |
| @@ -646,7 +638,7 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, · 41 unmodified lines | ||
| 646 | 638 | req->result = 0; |
| 647 | 639 | return req; |
| 648 | 640 | out: |
| 649 | − io_ring_drop_ctx_refs(ctx, 1); | |
| 641 | + percpu_ref_put(&ctx->refs); | |
| 650 | 642 | return NULL; |
| 651 | 643 | } |
| 652 | 644 | |
| @@ -654,7 +646,7 @@ static void io_free_req_many(struct io_ring_ctx *ctx, void **reqs, int *nr) · 1 unmodified line | ||
| 654 | 646 | { |
| 655 | 647 | if (*nr) { |
| 656 | 648 | kmem_cache_free_bulk(req_cachep, *nr, reqs); |
| 657 | − io_ring_drop_ctx_refs(ctx, *nr); | |
| 649 | + percpu_ref_put_many(&ctx->refs, *nr); | |
| 658 | 650 | *nr = 0; |
| 659 | 651 | } |
| 660 | 652 | } |
| @@ -663,7 +655,7 @@ static void __io_free_req(struct io_kiocb *req) · 2 unmodified lines | ||
| 663 | 655 | { |
| 664 | 656 | if (req->file && !(req->flags & REQ_F_FIXED_FILE)) |
| 665 | 657 | fput(req->file); |
| 666 | − io_ring_drop_ctx_refs(req->ctx, 1); | |
| 658 | + percpu_ref_put(&req->ctx->refs); | |
| 667 | 659 | kmem_cache_free(req_cachep, req); |
| 668 | 660 | } |
| 669 | 661 | |
| @@ -2761,7 +2753,7 @@ out: · 2091 unmodified lines | ||
| 2761 | 2753 | |
| 2762 | 2754 | if (link) |
| 2763 | 2755 | io_queue_link_head(ctx, link, &link->submit, shadow_req, |
| 2764 | − block_for_last); | |
| 2756 | + !block_for_last); | |
| 2765 | 2757 | if (statep) |
| 2766 | 2758 | io_submit_state_end(statep); |
| 2767 | 2759 | |
| @@ -2920,8 +2912,12 @@ static void io_finish_async(struct io_ring_ctx *ctx) · 152 unmodified lines | ||
| 2920 | 2912 | static void io_destruct_skb(struct sk_buff *skb) |
| 2921 | 2913 | { |
| 2922 | 2914 | struct io_ring_ctx *ctx = skb->sk->sk_user_data; |
| 2915 | + int i; | |
| 2916 | + | |
| 2917 | + for (i = 0; i < ARRAY_SIZE(ctx->sqo_wq); i++) | |
| 2918 | + if (ctx->sqo_wq[i]) | |
| 2919 | + flush_workqueue(ctx->sqo_wq[i]); | |
| 2923 | 2920 | |
| 2924 | − io_finish_async(ctx); | |
| 2925 | 2921 | unix_destruct_scm(skb); |
| 2926 | 2922 | } |
| 2927 | 2923 | |
| @@ -3630,7 +3626,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, · 702 unmodified lines | ||
| 3630 | 3626 | } |
| 3631 | 3627 | } |
| 3632 | 3628 | |
| 3633 | − io_ring_drop_ctx_refs(ctx, 1); | |
| 3629 | + percpu_ref_put(&ctx->refs); | |
| 3634 | 3630 | out_fput: |
| 3635 | 3631 | fdput(f); |
| 3636 | 3632 | return submitted ? submitted : ret; |
| @@ -22,12 +22,6 @@ EXPORT_SYMBOL(system_freezing_cnt); · 21 unmodified lines | ||
| 22 | 22 | bool pm_freezing; |
| 23 | 23 | bool pm_nosig_freezing; |
| 24 | 24 | |
| 25 | −/* | |
| 26 | − * Temporary export for the deadlock workaround in ata_scsi_hotplug(). | |
| 27 | − * Remove once the hack becomes unnecessary. | |
| 28 | − */ | |
| 29 | −EXPORT_SYMBOL_GPL(pm_freezing); | |
| 30 | − | |
| 31 | 25 | /* protects freezing and frozen transitions */ |
| 32 | 26 | static DEFINE_SPINLOCK(freezer_lock); |
| 33 | 27 | |
| @@ -239,8 +239,8 @@ static int __init default_bdi_init(void) · 238 unmodified lines | ||
| 239 | 239 | { |
| 240 | 240 | int err; |
| 241 | 241 | |
| 242 | − bdi_wq = alloc_workqueue("writeback", WQ_MEM_RECLAIM | WQ_FREEZABLE | | |
| 243 | − WQ_UNBOUND | WQ_SYSFS, 0); | |
| 242 | + bdi_wq = alloc_workqueue("writeback", WQ_MEM_RECLAIM | WQ_UNBOUND | | |
| 243 | + WQ_SYSFS, 0); | |
| 244 | 244 | if (!bdi_wq) |
| 245 | 245 | return -ENOMEM; |
| 246 | 246 | |