Skip to content

Commit 8f4ae0f

Browse files
committed
Merge tag 'block-5.13-2021-05-14' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Fix for shared tag set exit (Bart) - Correct ioctl range for zoned ioctls (Damien) - Removed dead/unused function (Lin) - Fix perf regression for shared tags (Ming) - Fix out-of-bounds issue with kyber and preemption (Omar) - BFQ merge fix (Paolo) - Two error handling fixes for nbd (Sun) - Fix weight update in blk-iocost (Tejun) - NVMe pull request (Christoph): - correct the check for using the inline bio in nvmet (Chaitanya Kulkarni) - demote unsupported command warnings (Chaitanya Kulkarni) - fix corruption due to double initializing ANA state (me, Hou Pu) - reset ns->file when open fails (Daniel Wagner) - fix a NULL deref when SEND is completed with error in nvmet-rdma (Michal Kalderon) - Fix kernel-doc warning (Bart) * tag 'block-5.13-2021-05-14' of git://git.kernel.dk/linux-block: block/partitions/efi.c: Fix the efi_partition() kernel-doc header blk-mq: Swap two calls in blk_mq_exit_queue() blk-mq: plug request for shared sbitmap nvmet: use new ana_log_size instead the old one nvmet: seset ns->file when open fails nbd: share nbd_put and return by goto put_nbd nbd: Fix NULL pointer in flush_workqueue blkdev.h: remove unused codes blk_account_rq block, bfq: avoid circular stable merges blk-iocost: fix weight updates of inner active iocgs nvmet: demote fabrics cmd parse err msg to debug nvmet: use helper to remove the duplicate code nvmet: demote discovery cmd parse err msg to debug nvmet-rdma: Fix NULL deref when SEND is completed with error nvmet: fix inline bio check for passthru nvmet: fix inline bio check for bdev-ns nvme-multipath: fix double initialization of ANA state kyber: fix out of bounds access when preempted block: uapi: fix comment about block device ioctl
2 parents 5601591 + 4bc2082 commit 8f4ae0f

File tree

22 files changed

+124
-75
lines changed

22 files changed

+124
-75
lines changed

block/bfq-iosched.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,38 @@ struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync)
372372
return bic->bfqq[is_sync];
373373
}
374374

375+
static void bfq_put_stable_ref(struct bfq_queue *bfqq);
376+
375377
void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, bool is_sync)
376378
{
379+
/*
380+
* If bfqq != NULL, then a non-stable queue merge between
381+
* bic->bfqq and bfqq is happening here. This causes troubles
382+
* in the following case: bic->bfqq has also been scheduled
383+
* for a possible stable merge with bic->stable_merge_bfqq,
384+
* and bic->stable_merge_bfqq == bfqq happens to
385+
* hold. Troubles occur because bfqq may then undergo a split,
386+
* thereby becoming eligible for a stable merge. Yet, if
387+
* bic->stable_merge_bfqq points exactly to bfqq, then bfqq
388+
* would be stably merged with itself. To avoid this anomaly,
389+
* we cancel the stable merge if
390+
* bic->stable_merge_bfqq == bfqq.
391+
*/
377392
bic->bfqq[is_sync] = bfqq;
393+
394+
if (bfqq && bic->stable_merge_bfqq == bfqq) {
395+
/*
396+
* Actually, these same instructions are executed also
397+
* in bfq_setup_cooperator, in case of abort or actual
398+
* execution of a stable merge. We could avoid
399+
* repeating these instructions there too, but if we
400+
* did so, we would nest even more complexity in this
401+
* function.
402+
*/
403+
bfq_put_stable_ref(bic->stable_merge_bfqq);
404+
405+
bic->stable_merge_bfqq = NULL;
406+
}
378407
}
379408

380409
struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic)
@@ -2263,10 +2292,9 @@ static void bfq_remove_request(struct request_queue *q,
22632292

22642293
}
22652294

2266-
static bool bfq_bio_merge(struct blk_mq_hw_ctx *hctx, struct bio *bio,
2295+
static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
22672296
unsigned int nr_segs)
22682297
{
2269-
struct request_queue *q = hctx->queue;
22702298
struct bfq_data *bfqd = q->elevator->elevator_data;
22712299
struct request *free = NULL;
22722300
/*
@@ -2631,8 +2659,6 @@ static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq,
26312659
static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
26322660
struct bfq_queue *bfqq);
26332661

2634-
static void bfq_put_stable_ref(struct bfq_queue *bfqq);
2635-
26362662
/*
26372663
* Attempt to schedule a merge of bfqq with the currently in-service
26382664
* queue or with a close queue among the scheduled queues. Return

block/blk-iocost.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,17 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
10691069

10701070
lockdep_assert_held(&ioc->lock);
10711071

1072-
inuse = clamp_t(u32, inuse, 1, active);
1072+
/*
1073+
* For an active leaf node, its inuse shouldn't be zero or exceed
1074+
* @active. An active internal node's inuse is solely determined by the
1075+
* inuse to active ratio of its children regardless of @inuse.
1076+
*/
1077+
if (list_empty(&iocg->active_list) && iocg->child_active_sum) {
1078+
inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum,
1079+
iocg->child_active_sum);
1080+
} else {
1081+
inuse = clamp_t(u32, inuse, 1, active);
1082+
}
10731083

10741084
iocg->last_inuse = iocg->inuse;
10751085
if (save)
@@ -1086,7 +1096,7 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
10861096
/* update the level sums */
10871097
parent->child_active_sum += (s32)(active - child->active);
10881098
parent->child_inuse_sum += (s32)(inuse - child->inuse);
1089-
/* apply the udpates */
1099+
/* apply the updates */
10901100
child->active = active;
10911101
child->inuse = inuse;
10921102

block/blk-mq-sched.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,16 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
358358
unsigned int nr_segs)
359359
{
360360
struct elevator_queue *e = q->elevator;
361-
struct blk_mq_ctx *ctx = blk_mq_get_ctx(q);
362-
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, bio->bi_opf, ctx);
361+
struct blk_mq_ctx *ctx;
362+
struct blk_mq_hw_ctx *hctx;
363363
bool ret = false;
364364
enum hctx_type type;
365365

366366
if (e && e->type->ops.bio_merge)
367-
return e->type->ops.bio_merge(hctx, bio, nr_segs);
367+
return e->type->ops.bio_merge(q, bio, nr_segs);
368368

369+
ctx = blk_mq_get_ctx(q);
370+
hctx = blk_mq_map_queue(q, bio->bi_opf, ctx);
369371
type = hctx->type;
370372
if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE) ||
371373
list_empty_careful(&ctx->rq_lists[type]))

block/blk-mq.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,8 +2232,9 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
22322232
/* Bypass scheduler for flush requests */
22332233
blk_insert_flush(rq);
22342234
blk_mq_run_hw_queue(data.hctx, true);
2235-
} else if (plug && (q->nr_hw_queues == 1 || q->mq_ops->commit_rqs ||
2236-
!blk_queue_nonrot(q))) {
2235+
} else if (plug && (q->nr_hw_queues == 1 ||
2236+
blk_mq_is_sbitmap_shared(rq->mq_hctx->flags) ||
2237+
q->mq_ops->commit_rqs || !blk_queue_nonrot(q))) {
22372238
/*
22382239
* Use plugging if we have a ->commit_rqs() hook as well, as
22392240
* we know the driver uses bd->last in a smart fashion.
@@ -3285,10 +3286,12 @@ EXPORT_SYMBOL(blk_mq_init_allocated_queue);
32853286
/* tags can _not_ be used after returning from blk_mq_exit_queue */
32863287
void blk_mq_exit_queue(struct request_queue *q)
32873288
{
3288-
struct blk_mq_tag_set *set = q->tag_set;
3289+
struct blk_mq_tag_set *set = q->tag_set;
32893290

3290-
blk_mq_del_queue_tag_set(q);
3291+
/* Checks hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED. */
32913292
blk_mq_exit_hw_queues(q, set, set->nr_hw_queues);
3293+
/* May clear BLK_MQ_F_TAG_QUEUE_SHARED in hctx->flags. */
3294+
blk_mq_del_queue_tag_set(q);
32923295
}
32933296

32943297
static int __blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)

block/kyber-iosched.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,12 @@ static void kyber_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
561561
}
562562
}
563563

564-
static bool kyber_bio_merge(struct blk_mq_hw_ctx *hctx, struct bio *bio,
564+
static bool kyber_bio_merge(struct request_queue *q, struct bio *bio,
565565
unsigned int nr_segs)
566566
{
567+
struct blk_mq_ctx *ctx = blk_mq_get_ctx(q);
568+
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, bio->bi_opf, ctx);
567569
struct kyber_hctx_data *khd = hctx->sched_data;
568-
struct blk_mq_ctx *ctx = blk_mq_get_ctx(hctx->queue);
569570
struct kyber_ctx_queue *kcq = &khd->kcqs[ctx->index_hw[hctx->type]];
570571
unsigned int sched_domain = kyber_sched_domain(bio->bi_opf);
571572
struct list_head *rq_list = &kcq->rq_list[sched_domain];

block/mq-deadline.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,9 @@ static int dd_request_merge(struct request_queue *q, struct request **rq,
461461
return ELEVATOR_NO_MERGE;
462462
}
463463

464-
static bool dd_bio_merge(struct blk_mq_hw_ctx *hctx, struct bio *bio,
464+
static bool dd_bio_merge(struct request_queue *q, struct bio *bio,
465465
unsigned int nr_segs)
466466
{
467-
struct request_queue *q = hctx->queue;
468467
struct deadline_data *dd = q->elevator->elevator_data;
469468
struct request *free = NULL;
470469
bool ret;

block/partitions/efi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ static void utf16_le_to_7bit(const __le16 *in, unsigned int size, u8 *out)
682682
}
683683

684684
/**
685-
* efi_partition(struct parsed_partitions *state)
685+
* efi_partition - scan for GPT partitions
686686
* @state: disk parsed partitions
687687
*
688688
* Description: called from check.c, if the disk contains GPT

drivers/block/nbd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,8 @@ static void nbd_disconnect_and_put(struct nbd_device *nbd)
19801980
* config ref and try to destroy the workqueue from inside the work
19811981
* queue.
19821982
*/
1983-
flush_workqueue(nbd->recv_workq);
1983+
if (nbd->recv_workq)
1984+
flush_workqueue(nbd->recv_workq);
19841985
if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF,
19851986
&nbd->config->runtime_flags))
19861987
nbd_config_put(nbd);
@@ -2014,12 +2015,11 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
20142015
return -EINVAL;
20152016
}
20162017
mutex_unlock(&nbd_index_mutex);
2017-
if (!refcount_inc_not_zero(&nbd->config_refs)) {
2018-
nbd_put(nbd);
2019-
return 0;
2020-
}
2018+
if (!refcount_inc_not_zero(&nbd->config_refs))
2019+
goto put_nbd;
20212020
nbd_disconnect_and_put(nbd);
20222021
nbd_config_put(nbd);
2022+
put_nbd:
20232023
nbd_put(nbd);
20242024
return 0;
20252025
}

drivers/nvme/host/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
29012901
ctrl->hmmaxd = le16_to_cpu(id->hmmaxd);
29022902
}
29032903

2904-
ret = nvme_mpath_init(ctrl, id);
2904+
ret = nvme_mpath_init_identify(ctrl, id);
29052905
if (ret < 0)
29062906
goto out_free;
29072907

@@ -4364,6 +4364,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
43644364
min(default_ps_max_latency_us, (unsigned long)S32_MAX));
43654365

43664366
nvme_fault_inject_init(&ctrl->fault_inject, dev_name(ctrl->device));
4367+
nvme_mpath_init_ctrl(ctrl);
43674368

43684369
return 0;
43694370
out_free_name:

drivers/nvme/host/multipath.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,18 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
781781
put_disk(head->disk);
782782
}
783783

784-
int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
784+
void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl)
785785
{
786-
int error;
786+
mutex_init(&ctrl->ana_lock);
787+
timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
788+
INIT_WORK(&ctrl->ana_work, nvme_ana_work);
789+
}
790+
791+
int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
792+
{
793+
size_t max_transfer_size = ctrl->max_hw_sectors << SECTOR_SHIFT;
794+
size_t ana_log_size;
795+
int error = 0;
787796

788797
/* check if multipath is enabled and we have the capability */
789798
if (!multipath || !ctrl->subsys ||
@@ -795,37 +804,31 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
795804
ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
796805
ctrl->anagrpmax = le32_to_cpu(id->anagrpmax);
797806

798-
mutex_init(&ctrl->ana_lock);
799-
timer_setup(&ctrl->anatt_timer, nvme_anatt_timeout, 0);
800-
ctrl->ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
801-
ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc);
802-
ctrl->ana_log_size += ctrl->max_namespaces * sizeof(__le32);
803-
804-
if (ctrl->ana_log_size > ctrl->max_hw_sectors << SECTOR_SHIFT) {
807+
ana_log_size = sizeof(struct nvme_ana_rsp_hdr) +
808+
ctrl->nanagrpid * sizeof(struct nvme_ana_group_desc) +
809+
ctrl->max_namespaces * sizeof(__le32);
810+
if (ana_log_size > max_transfer_size) {
805811
dev_err(ctrl->device,
806-
"ANA log page size (%zd) larger than MDTS (%d).\n",
807-
ctrl->ana_log_size,
808-
ctrl->max_hw_sectors << SECTOR_SHIFT);
812+
"ANA log page size (%zd) larger than MDTS (%zd).\n",
813+
ana_log_size, max_transfer_size);
809814
dev_err(ctrl->device, "disabling ANA support.\n");
810-
return 0;
815+
goto out_uninit;
811816
}
812-
813-
INIT_WORK(&ctrl->ana_work, nvme_ana_work);
814-
kfree(ctrl->ana_log_buf);
815-
ctrl->ana_log_buf = kmalloc(ctrl->ana_log_size, GFP_KERNEL);
816-
if (!ctrl->ana_log_buf) {
817-
error = -ENOMEM;
818-
goto out;
817+
if (ana_log_size > ctrl->ana_log_size) {
818+
nvme_mpath_stop(ctrl);
819+
kfree(ctrl->ana_log_buf);
820+
ctrl->ana_log_buf = kmalloc(ana_log_size, GFP_KERNEL);
821+
if (!ctrl->ana_log_buf)
822+
return -ENOMEM;
819823
}
820-
824+
ctrl->ana_log_size = ana_log_size;
821825
error = nvme_read_ana_log(ctrl);
822826
if (error)
823-
goto out_free_ana_log_buf;
827+
goto out_uninit;
824828
return 0;
825-
out_free_ana_log_buf:
826-
kfree(ctrl->ana_log_buf);
827-
ctrl->ana_log_buf = NULL;
828-
out:
829+
830+
out_uninit:
831+
nvme_mpath_uninit(ctrl);
829832
return error;
830833
}
831834

0 commit comments

Comments
 (0)