Skip to content

Commit b3bd86a

Browse files
committed
Merge tag 'block-6.5-2023-07-14' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Don't require quirk to use duplicate namespace identifiers (Christoph, Sagi) - One more BOGUS_NID quirk (Pankaj) - IO timeout and error hanlding fixes for PCI (Keith) - Enhanced metadata format mask fix (Ankit) - Association race condition fix for fibre channel (Michael) - Correct debugfs error checks (Minjie) - Use PAGE_SECTORS_SHIFT where needed (Damien) - Reduce kernel logs for legacy nguid attribute (Keith) - Use correct dma direction when unmapping metadata (Ming) - Fix for a flush handling regression in this release (Christoph) - Fix for batched request time stamping (Chengming) - Fix for a regression in the mq-deadline position calculation (Bart) - Lockdep fix for blk-crypto (Eric) - Fix for a regression in the Amiga partition handling changes (Michael) * tag 'block-6.5-2023-07-14' of git://git.kernel.dk/linux: block: queue data commands from the flush state machine at the head blk-mq: fix start_time_ns and alloc_time_ns for pre-allocated rq nvme-pci: fix DMA direction of unmapping integrity data nvme: don't reject probe due to duplicate IDs for single-ported PCIe devices block/mq-deadline: Fix a bug in deadline_from_pos() nvme: ensure disabling pairs with unquiesce nvme-fc: fix race between error recovery and creating association nvme-fc: return non-zero status code when fails to create association nvme: fix parameter check in nvme_fault_inject_init() nvme: warn only once for legacy uuid attribute block: remove dead struc request->completion_data field nvme: fix the NVME_ID_NS_NVM_STS_MASK definition nvmet: use PAGE_SECTORS_SHIFT nvme: add BOGUS_NID quirk for Samsung SM953 blk-crypto: use dynamic lock class for blk_crypto_profile::lock block/partition: fix signedness issue for Amiga partitions
2 parents ec17f16 + 9f87fc4 commit b3bd86a

File tree

15 files changed

+136
-50
lines changed

15 files changed

+136
-50
lines changed

block/blk-crypto-profile.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ int blk_crypto_profile_init(struct blk_crypto_profile *profile,
7979
unsigned int slot_hashtable_size;
8080

8181
memset(profile, 0, sizeof(*profile));
82-
init_rwsem(&profile->lock);
82+
83+
/*
84+
* profile->lock of an underlying device can nest inside profile->lock
85+
* of a device-mapper device, so use a dynamic lock class to avoid
86+
* false-positive lockdep reports.
87+
*/
88+
lockdep_register_key(&profile->lockdep_key);
89+
__init_rwsem(&profile->lock, "&profile->lock", &profile->lockdep_key);
8390

8491
if (num_slots == 0)
8592
return 0;
@@ -89,7 +96,7 @@ int blk_crypto_profile_init(struct blk_crypto_profile *profile,
8996
profile->slots = kvcalloc(num_slots, sizeof(profile->slots[0]),
9097
GFP_KERNEL);
9198
if (!profile->slots)
92-
return -ENOMEM;
99+
goto err_destroy;
93100

94101
profile->num_slots = num_slots;
95102

@@ -435,6 +442,7 @@ void blk_crypto_profile_destroy(struct blk_crypto_profile *profile)
435442
{
436443
if (!profile)
437444
return;
445+
lockdep_unregister_key(&profile->lockdep_key);
438446
kvfree(profile->slot_hashtable);
439447
kvfree_sensitive(profile->slots,
440448
sizeof(profile->slots[0]) * profile->num_slots);

block/blk-flush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static void blk_flush_complete_seq(struct request *rq,
189189
case REQ_FSEQ_DATA:
190190
list_move_tail(&rq->flush.list, &fq->flush_data_in_flight);
191191
spin_lock(&q->requeue_lock);
192-
list_add_tail(&rq->queuelist, &q->flush_list);
192+
list_add(&rq->queuelist, &q->requeue_list);
193193
spin_unlock(&q->requeue_lock);
194194
blk_mq_kick_requeue_list(q);
195195
break;

block/blk-mq.c

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,24 @@ void blk_rq_init(struct request_queue *q, struct request *rq)
328328
}
329329
EXPORT_SYMBOL(blk_rq_init);
330330

331+
/* Set start and alloc time when the allocated request is actually used */
332+
static inline void blk_mq_rq_time_init(struct request *rq, u64 alloc_time_ns)
333+
{
334+
if (blk_mq_need_time_stamp(rq))
335+
rq->start_time_ns = ktime_get_ns();
336+
else
337+
rq->start_time_ns = 0;
338+
339+
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
340+
if (blk_queue_rq_alloc_time(rq->q))
341+
rq->alloc_time_ns = alloc_time_ns ?: rq->start_time_ns;
342+
else
343+
rq->alloc_time_ns = 0;
344+
#endif
345+
}
346+
331347
static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
332-
struct blk_mq_tags *tags, unsigned int tag, u64 alloc_time_ns)
348+
struct blk_mq_tags *tags, unsigned int tag)
333349
{
334350
struct blk_mq_ctx *ctx = data->ctx;
335351
struct blk_mq_hw_ctx *hctx = data->hctx;
@@ -356,14 +372,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
356372
}
357373
rq->timeout = 0;
358374

359-
if (blk_mq_need_time_stamp(rq))
360-
rq->start_time_ns = ktime_get_ns();
361-
else
362-
rq->start_time_ns = 0;
363375
rq->part = NULL;
364-
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
365-
rq->alloc_time_ns = alloc_time_ns;
366-
#endif
367376
rq->io_start_time_ns = 0;
368377
rq->stats_sectors = 0;
369378
rq->nr_phys_segments = 0;
@@ -393,8 +402,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
393402
}
394403

395404
static inline struct request *
396-
__blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data,
397-
u64 alloc_time_ns)
405+
__blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data)
398406
{
399407
unsigned int tag, tag_offset;
400408
struct blk_mq_tags *tags;
@@ -413,7 +421,7 @@ __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data,
413421
tag = tag_offset + i;
414422
prefetch(tags->static_rqs[tag]);
415423
tag_mask &= ~(1UL << i);
416-
rq = blk_mq_rq_ctx_init(data, tags, tag, alloc_time_ns);
424+
rq = blk_mq_rq_ctx_init(data, tags, tag);
417425
rq_list_add(data->cached_rq, rq);
418426
nr++;
419427
}
@@ -474,9 +482,11 @@ static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data)
474482
* Try batched alloc if we want more than 1 tag.
475483
*/
476484
if (data->nr_tags > 1) {
477-
rq = __blk_mq_alloc_requests_batch(data, alloc_time_ns);
478-
if (rq)
485+
rq = __blk_mq_alloc_requests_batch(data);
486+
if (rq) {
487+
blk_mq_rq_time_init(rq, alloc_time_ns);
479488
return rq;
489+
}
480490
data->nr_tags = 1;
481491
}
482492

@@ -499,8 +509,9 @@ static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data)
499509
goto retry;
500510
}
501511

502-
return blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag,
503-
alloc_time_ns);
512+
rq = blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag);
513+
blk_mq_rq_time_init(rq, alloc_time_ns);
514+
return rq;
504515
}
505516

506517
static struct request *blk_mq_rq_cache_fill(struct request_queue *q,
@@ -555,6 +566,7 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q,
555566
return NULL;
556567

557568
plug->cached_rq = rq_list_next(rq);
569+
blk_mq_rq_time_init(rq, 0);
558570
}
559571

560572
rq->cmd_flags = opf;
@@ -656,8 +668,8 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
656668
tag = blk_mq_get_tag(&data);
657669
if (tag == BLK_MQ_NO_TAG)
658670
goto out_queue_exit;
659-
rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
660-
alloc_time_ns);
671+
rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag);
672+
blk_mq_rq_time_init(rq, alloc_time_ns);
661673
rq->__data_len = 0;
662674
rq->__sector = (sector_t) -1;
663675
rq->bio = rq->biotail = NULL;
@@ -2896,6 +2908,7 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
28962908
plug->cached_rq = rq_list_next(rq);
28972909
rq_qos_throttle(q, *bio);
28982910

2911+
blk_mq_rq_time_init(rq, 0);
28992912
rq->cmd_flags = (*bio)->bi_opf;
29002913
INIT_LIST_HEAD(&rq->queuelist);
29012914
return rq;

block/mq-deadline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static inline struct request *deadline_from_pos(struct dd_per_prio *per_prio,
176176
* zoned writes, start searching from the start of a zone.
177177
*/
178178
if (blk_rq_is_seq_zoned_write(rq))
179-
pos -= round_down(pos, rq->q->limits.chunk_sectors);
179+
pos = round_down(pos, rq->q->limits.chunk_sectors);
180180

181181
while (node) {
182182
rq = rb_entry_rq(node);

block/partitions/amiga.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int amiga_partition(struct parsed_partitions *state)
9090
}
9191
blk = be32_to_cpu(rdb->rdb_PartitionList);
9292
put_dev_sector(sect);
93-
for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) {
93+
for (part = 1; (s32) blk>0 && part<=16; part++, put_dev_sector(sect)) {
9494
/* Read in terms partition table understands */
9595
if (check_mul_overflow(blk, (sector_t) blksize, &blk)) {
9696
pr_err("Dev %s: overflow calculating partition block %llu! Skipping partitions %u and beyond\n",

drivers/nvme/host/core.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,10 +3431,40 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
34313431

34323432
ret = nvme_global_check_duplicate_ids(ctrl->subsys, &info->ids);
34333433
if (ret) {
3434-
dev_err(ctrl->device,
3435-
"globally duplicate IDs for nsid %d\n", info->nsid);
3434+
/*
3435+
* We've found two different namespaces on two different
3436+
* subsystems that report the same ID. This is pretty nasty
3437+
* for anything that actually requires unique device
3438+
* identification. In the kernel we need this for multipathing,
3439+
* and in user space the /dev/disk/by-id/ links rely on it.
3440+
*
3441+
* If the device also claims to be multi-path capable back off
3442+
* here now and refuse the probe the second device as this is a
3443+
* recipe for data corruption. If not this is probably a
3444+
* cheap consumer device if on the PCIe bus, so let the user
3445+
* proceed and use the shiny toy, but warn that with changing
3446+
* probing order (which due to our async probing could just be
3447+
* device taking longer to startup) the other device could show
3448+
* up at any time.
3449+
*/
34363450
nvme_print_device_info(ctrl);
3437-
return ret;
3451+
if ((ns->ctrl->ops->flags & NVME_F_FABRICS) || /* !PCIe */
3452+
((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) &&
3453+
info->is_shared)) {
3454+
dev_err(ctrl->device,
3455+
"ignoring nsid %d because of duplicate IDs\n",
3456+
info->nsid);
3457+
return ret;
3458+
}
3459+
3460+
dev_err(ctrl->device,
3461+
"clearing duplicate IDs for nsid %d\n", info->nsid);
3462+
dev_err(ctrl->device,
3463+
"use of /dev/disk/by-id/ may cause data corruption\n");
3464+
memset(&info->ids.nguid, 0, sizeof(info->ids.nguid));
3465+
memset(&info->ids.uuid, 0, sizeof(info->ids.uuid));
3466+
memset(&info->ids.eui64, 0, sizeof(info->ids.eui64));
3467+
ctrl->quirks |= NVME_QUIRK_BOGUS_NID;
34383468
}
34393469

34403470
mutex_lock(&ctrl->subsys->lock);

drivers/nvme/host/fault_inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
2727

2828
/* create debugfs directory and attribute */
2929
parent = debugfs_create_dir(dev_name, NULL);
30-
if (!parent) {
30+
if (IS_ERR(parent)) {
3131
pr_warn("%s: failed to create debugfs directory\n", dev_name);
3232
return;
3333
}

drivers/nvme/host/fc.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,14 +2548,24 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
25482548
* the controller. Abort any ios on the association and let the
25492549
* create_association error path resolve things.
25502550
*/
2551-
if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) {
2552-
__nvme_fc_abort_outstanding_ios(ctrl, true);
2551+
enum nvme_ctrl_state state;
2552+
unsigned long flags;
2553+
2554+
spin_lock_irqsave(&ctrl->lock, flags);
2555+
state = ctrl->ctrl.state;
2556+
if (state == NVME_CTRL_CONNECTING) {
25532557
set_bit(ASSOC_FAILED, &ctrl->flags);
2558+
spin_unlock_irqrestore(&ctrl->lock, flags);
2559+
__nvme_fc_abort_outstanding_ios(ctrl, true);
2560+
dev_warn(ctrl->ctrl.device,
2561+
"NVME-FC{%d}: transport error during (re)connect\n",
2562+
ctrl->cnum);
25542563
return;
25552564
}
2565+
spin_unlock_irqrestore(&ctrl->lock, flags);
25562566

25572567
/* Otherwise, only proceed if in LIVE state - e.g. on first error */
2558-
if (ctrl->ctrl.state != NVME_CTRL_LIVE)
2568+
if (state != NVME_CTRL_LIVE)
25592569
return;
25602570

25612571
dev_warn(ctrl->ctrl.device,
@@ -3110,7 +3120,9 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31103120
*/
31113121

31123122
ret = nvme_enable_ctrl(&ctrl->ctrl);
3113-
if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
3123+
if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3124+
ret = -EIO;
3125+
if (ret)
31143126
goto out_disconnect_admin_queue;
31153127

31163128
ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments;
@@ -3120,7 +3132,9 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31203132
nvme_unquiesce_admin_queue(&ctrl->ctrl);
31213133

31223134
ret = nvme_init_ctrl_finish(&ctrl->ctrl, false);
3123-
if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
3135+
if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3136+
ret = -EIO;
3137+
if (ret)
31243138
goto out_disconnect_admin_queue;
31253139

31263140
/* sanity checks */
@@ -3165,10 +3179,16 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31653179
else
31663180
ret = nvme_fc_recreate_io_queues(ctrl);
31673181
}
3168-
if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
3169-
goto out_term_aen_ops;
31703182

3183+
spin_lock_irqsave(&ctrl->lock, flags);
3184+
if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3185+
ret = -EIO;
3186+
if (ret) {
3187+
spin_unlock_irqrestore(&ctrl->lock, flags);
3188+
goto out_term_aen_ops;
3189+
}
31713190
changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
3191+
spin_unlock_irqrestore(&ctrl->lock, flags);
31723192

31733193
ctrl->ctrl.nr_reconnects = 0;
31743194

@@ -3180,6 +3200,9 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31803200
out_term_aen_ops:
31813201
nvme_fc_term_aen_ops(ctrl);
31823202
out_disconnect_admin_queue:
3203+
dev_warn(ctrl->ctrl.device,
3204+
"NVME-FC{%d}: create_assoc failed, assoc_id %llx ret %d\n",
3205+
ctrl->cnum, ctrl->association_id, ret);
31833206
/* send a Disconnect(association) LS to fc-nvme target */
31843207
nvme_fc_xmt_disconnect_assoc(ctrl);
31853208
spin_lock_irqsave(&ctrl->lock, flags);

drivers/nvme/host/pci.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static __always_inline void nvme_pci_unmap_rq(struct request *req)
967967
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
968968

969969
dma_unmap_page(dev->dev, iod->meta_dma,
970-
rq_integrity_vec(req)->bv_len, rq_data_dir(req));
970+
rq_integrity_vec(req)->bv_len, rq_dma_dir(req));
971971
}
972972

973973
if (blk_rq_nr_phys_segments(req))
@@ -1298,9 +1298,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
12981298
*/
12991299
if (nvme_should_reset(dev, csts)) {
13001300
nvme_warn_reset(dev, csts);
1301-
nvme_dev_disable(dev, false);
1302-
nvme_reset_ctrl(&dev->ctrl);
1303-
return BLK_EH_DONE;
1301+
goto disable;
13041302
}
13051303

13061304
/*
@@ -1351,10 +1349,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13511349
"I/O %d QID %d timeout, reset controller\n",
13521350
req->tag, nvmeq->qid);
13531351
nvme_req(req)->flags |= NVME_REQ_CANCELLED;
1354-
nvme_dev_disable(dev, false);
1355-
nvme_reset_ctrl(&dev->ctrl);
1356-
1357-
return BLK_EH_DONE;
1352+
goto disable;
13581353
}
13591354

13601355
if (atomic_dec_return(&dev->ctrl.abort_limit) < 0) {
@@ -1391,6 +1386,15 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13911386
* as the device then is in a faulty state.
13921387
*/
13931388
return BLK_EH_RESET_TIMER;
1389+
1390+
disable:
1391+
if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING))
1392+
return BLK_EH_DONE;
1393+
1394+
nvme_dev_disable(dev, false);
1395+
if (nvme_try_sched_reset(&dev->ctrl))
1396+
nvme_unquiesce_io_queues(&dev->ctrl);
1397+
return BLK_EH_DONE;
13941398
}
13951399

13961400
static void nvme_free_queue(struct nvme_queue *nvmeq)
@@ -3278,6 +3282,10 @@ static pci_ers_result_t nvme_error_detected(struct pci_dev *pdev,
32783282
case pci_channel_io_frozen:
32793283
dev_warn(dev->ctrl.device,
32803284
"frozen state error detected, reset controller\n");
3285+
if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) {
3286+
nvme_dev_disable(dev, true);
3287+
return PCI_ERS_RESULT_DISCONNECT;
3288+
}
32813289
nvme_dev_disable(dev, false);
32823290
return PCI_ERS_RESULT_NEED_RESET;
32833291
case pci_channel_io_perm_failure:
@@ -3294,7 +3302,8 @@ static pci_ers_result_t nvme_slot_reset(struct pci_dev *pdev)
32943302

32953303
dev_info(dev->ctrl.device, "restart after slot reset\n");
32963304
pci_restore_state(pdev);
3297-
nvme_reset_ctrl(&dev->ctrl);
3305+
if (!nvme_try_sched_reset(&dev->ctrl))
3306+
nvme_unquiesce_io_queues(&dev->ctrl);
32983307
return PCI_ERS_RESULT_RECOVERED;
32993308
}
33003309

@@ -3396,6 +3405,8 @@ static const struct pci_device_id nvme_id_table[] = {
33963405
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
33973406
{ PCI_DEVICE(0x144d, 0xa809), /* Samsung MZALQ256HBJD 256G */
33983407
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
3408+
{ PCI_DEVICE(0x144d, 0xa802), /* Samsung SM953 */
3409+
.driver_data = NVME_QUIRK_BOGUS_NID, },
33993410
{ PCI_DEVICE(0x1cc4, 0x6303), /* UMIS RPJTJ512MGE1QDY 512G */
34003411
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
34013412
{ PCI_DEVICE(0x1cc4, 0x6302), /* UMIS RPJTJ256MGE1QDY 256G */

drivers/nvme/host/sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
9292
* we have no UUID set
9393
*/
9494
if (uuid_is_null(&ids->uuid)) {
95-
dev_warn_ratelimited(dev,
95+
dev_warn_once(dev,
9696
"No UUID available providing old NGUID\n");
9797
return sysfs_emit(buf, "%pU\n", ids->nguid);
9898
}

0 commit comments

Comments
 (0)