Skip to content

Commit edc0035

Browse files
committed
Merge tag 'block-6.2-2023-01-20' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: "Various little tweaks all over the place: - NVMe pull request via Christoph: - fix controller shutdown regression in nvme-apple (Janne Grunau) - fix a polling on timeout regression in nvme-pci (Keith Busch) - Fix a bug in the read request side request allocation caching (Pavel) - pktcdvd was brought back after we configured a NULL return on bio splits, make it consistent with the others (me) - BFQ refcount fix (Yu) - Block cgroup policy activation fix (Yu) - Fix for an md regression introduced in the 6.2 cycle (Adrian)" * tag 'block-6.2-2023-01-20' of git://git.kernel.dk/linux: nvme-pci: fix timeout request state check nvme-apple: only reset the controller when RTKit is running nvme-apple: reset controller during shutdown block: fix hctx checks for batch allocation block/rnbd-clt: fix wrong max ID in ida_alloc_max blk-cgroup: fix missing pd_online_fn() while activating policy pktcdvd: check for NULL returna fter calling bio_split_to_limits() block, bfq: switch 'bfqg->ref' to use atomic refcount apis md: fix incorrect declaration about claim_rdev in md_import_device
2 parents 9c38747 + 955bc12 commit edc0035

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

block/bfq-cgroup.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,12 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
316316

317317
static void bfqg_get(struct bfq_group *bfqg)
318318
{
319-
bfqg->ref++;
319+
refcount_inc(&bfqg->ref);
320320
}
321321

322322
static void bfqg_put(struct bfq_group *bfqg)
323323
{
324-
bfqg->ref--;
325-
326-
if (bfqg->ref == 0)
324+
if (refcount_dec_and_test(&bfqg->ref))
327325
kfree(bfqg);
328326
}
329327

@@ -530,7 +528,7 @@ static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, struct request_queue *q,
530528
}
531529

532530
/* see comments in bfq_bic_update_cgroup for why refcounting */
533-
bfqg_get(bfqg);
531+
refcount_set(&bfqg->ref, 1);
534532
return &bfqg->pd;
535533
}
536534

block/bfq-iosched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ struct bfq_group {
928928
char blkg_path[128];
929929

930930
/* reference counter (see comments in bfq_bic_update_cgroup) */
931-
int ref;
931+
refcount_t ref;
932932
/* Is bfq_group still online? */
933933
bool online;
934934

block/blk-cgroup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,10 @@ int blkcg_activate_policy(struct request_queue *q,
14551455
list_for_each_entry_reverse(blkg, &q->blkg_list, q_node)
14561456
pol->pd_init_fn(blkg->pd[pol->plid]);
14571457

1458+
if (pol->pd_online_fn)
1459+
list_for_each_entry_reverse(blkg, &q->blkg_list, q_node)
1460+
pol->pd_online_fn(blkg->pd[pol->plid]);
1461+
14581462
__set_bit(pol->plid, q->blkcg_pols);
14591463
ret = 0;
14601464

block/blk-mq.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,7 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
28902890
struct blk_plug *plug, struct bio **bio, unsigned int nsegs)
28912891
{
28922892
struct request *rq;
2893+
enum hctx_type type, hctx_type;
28932894

28942895
if (!plug)
28952896
return NULL;
@@ -2902,7 +2903,10 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
29022903
return NULL;
29032904
}
29042905

2905-
if (blk_mq_get_hctx_type((*bio)->bi_opf) != rq->mq_hctx->type)
2906+
type = blk_mq_get_hctx_type((*bio)->bi_opf);
2907+
hctx_type = rq->mq_hctx->type;
2908+
if (type != hctx_type &&
2909+
!(type == HCTX_TYPE_READ && hctx_type == HCTX_TYPE_DEFAULT))
29062910
return NULL;
29072911
if (op_is_flush(rq->cmd_flags) != op_is_flush((*bio)->bi_opf))
29082912
return NULL;

drivers/block/pktcdvd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,8 @@ static void pkt_submit_bio(struct bio *bio)
24002400
struct bio *split;
24012401

24022402
bio = bio_split_to_limits(bio);
2403+
if (!bio)
2404+
return;
24032405

24042406
pkt_dbg(2, pd, "start = %6llx stop = %6llx\n",
24052407
(unsigned long long)bio->bi_iter.bi_sector,

drivers/block/rnbd/rnbd-clt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
14401440
goto out_alloc;
14411441
}
14421442

1443-
ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS),
1443+
ret = ida_alloc_max(&index_ida, (1 << (MINORBITS - RNBD_PART_BITS)) - 1,
14441444
GFP_KERNEL);
14451445
if (ret < 0) {
14461446
pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",

drivers/md/md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,7 +3644,7 @@ EXPORT_SYMBOL_GPL(md_rdev_init);
36443644
*/
36453645
static struct md_rdev *md_import_device(dev_t newdev, int super_format, int super_minor)
36463646
{
3647-
static struct md_rdev *claim_rdev; /* just for claiming the bdev */
3647+
static struct md_rdev claim_rdev; /* just for claiming the bdev */
36483648
struct md_rdev *rdev;
36493649
sector_t size;
36503650
int err;
@@ -3662,7 +3662,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
36623662

36633663
rdev->bdev = blkdev_get_by_dev(newdev,
36643664
FMODE_READ | FMODE_WRITE | FMODE_EXCL,
3665-
super_format == -2 ? claim_rdev : rdev);
3665+
super_format == -2 ? &claim_rdev : rdev);
36663666
if (IS_ERR(rdev->bdev)) {
36673667
pr_warn("md: could not open device unknown-block(%u,%u).\n",
36683668
MAJOR(newdev), MINOR(newdev));

drivers/nvme/host/apple.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,23 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)
829829
apple_nvme_remove_cq(anv);
830830
}
831831

832-
nvme_disable_ctrl(&anv->ctrl, shutdown);
832+
/*
833+
* Always disable the NVMe controller after shutdown.
834+
* We need to do this to bring it back up later anyway, and we
835+
* can't do it while the firmware is not running (e.g. in the
836+
* resume reset path before RTKit is initialized), so for Apple
837+
* controllers it makes sense to unconditionally do it here.
838+
* Additionally, this sequence of events is reliable, while
839+
* others (like disabling after bringing back the firmware on
840+
* resume) seem to run into trouble under some circumstances.
841+
*
842+
* Both U-Boot and m1n1 also use this convention (i.e. an ANS
843+
* NVMe controller is handed off with firmware shut down, in an
844+
* NVMe disabled state, after a clean shutdown).
845+
*/
846+
if (shutdown)
847+
nvme_disable_ctrl(&anv->ctrl, shutdown);
848+
nvme_disable_ctrl(&anv->ctrl, false);
833849
}
834850

835851
WRITE_ONCE(anv->ioq.enabled, false);
@@ -985,11 +1001,11 @@ static void apple_nvme_reset_work(struct work_struct *work)
9851001
goto out;
9861002
}
9871003

988-
if (anv->ctrl.ctrl_config & NVME_CC_ENABLE)
989-
apple_nvme_disable(anv, false);
990-
9911004
/* RTKit must be shut down cleanly for the (soft)-reset to work */
9921005
if (apple_rtkit_is_running(anv->rtk)) {
1006+
/* reset the controller if it is enabled */
1007+
if (anv->ctrl.ctrl_config & NVME_CC_ENABLE)
1008+
apple_nvme_disable(anv, false);
9931009
dev_dbg(anv->dev, "Trying to shut down RTKit before reset.");
9941010
ret = apple_rtkit_shutdown(anv->rtk);
9951011
if (ret)

drivers/nvme/host/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13621362
else
13631363
nvme_poll_irqdisable(nvmeq);
13641364

1365-
if (blk_mq_request_completed(req)) {
1365+
if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT) {
13661366
dev_warn(dev->ctrl.device,
13671367
"I/O %d QID %d timeout, completion polled\n",
13681368
req->tag, nvmeq->qid);

0 commit comments

Comments
 (0)