Skip to content

Commit 8467b0e

Browse files
committed
Merge tag 'for-5.18/drivers-2022-04-01' of git://git.kernel.dk/linux-block
Pull block driver fixes from Jens Axboe: "Followup block driver updates and fixes for the 5.18-rc1 merge window. In detail: - NVMe pull request - Fix multipath hang when disk goes live over reconnect (Anton Eidelman) - fix RCU hole that allowed for endless looping in multipath round robin (Chris Leech) - remove redundant assignment after left shift (Colin Ian King) - add quirks for Samsung X5 SSDs (Monish Kumar R) - fix the read-only state for zoned namespaces with unsupposed features (Pankaj Raghav) - use a private workqueue instead of the system workqueue in nvmet (Sagi Grimberg) - allow duplicate NSIDs for private namespaces (Sungup Moon) - expose use_threaded_interrupts read-only in sysfs (Xin Hao)" - nbd minor allocation fix (Zhang) - drbd fixes and maintainer addition (Lars, Jakob, Christoph) - n64cart build fix (Jackie) - loop compat ioctl fix (Carlos) - misc fixes (Colin, Dongli)" * tag 'for-5.18/drivers-2022-04-01' of git://git.kernel.dk/linux-block: drbd: remove check of list iterator against head past the loop body drbd: remove usage of list iterator variable after loop nbd: fix possible overflow on 'first_minor' in nbd_dev_add() MAINTAINERS: add drbd co-maintainer drbd: fix potential silent data corruption loop: fix ioctl calls using compat_loop_info nvme-multipath: fix hang when disk goes live over reconnect nvme: fix RCU hole that allowed for endless looping in multipath round robin nvme: allow duplicate NSIDs for private namespaces nvmet: remove redundant assignment after left shift nvmet: use a private workqueue instead of the system workqueue nvme-pci: add quirks for Samsung X5 SSDs nvme-pci: expose use_threaded_interrupts read-only in sysfs nvme: fix the read-only state for zoned namespaces with unsupposed features n64cart: convert bi_disk to bi_bdev->bd_disk fix build xen/blkfront: fix comment for need_copy xen-blkback: remove redundant assignment to variable i
2 parents d589ae0 + 2651ee5 commit 8467b0e

25 files changed

Lines changed: 186 additions & 92 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6052,6 +6052,7 @@ F: drivers/scsi/dpt/
60526052
DRBD DRIVER
60536053
M: Philipp Reisner <philipp.reisner@linbit.com>
60546054
M: Lars Ellenberg <lars.ellenberg@linbit.com>
6055+
M: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
60556056
L: drbd-dev@lists.linbit.com
60566057
S: Supported
60576058
W: http://www.drbd.org

drivers/block/drbd/drbd_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
171171
unsigned int set_size)
172172
{
173173
struct drbd_request *r;
174-
struct drbd_request *req = NULL;
174+
struct drbd_request *req = NULL, *tmp = NULL;
175175
int expect_epoch = 0;
176176
int expect_size = 0;
177177

@@ -225,8 +225,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
225225
* to catch requests being barrier-acked "unexpectedly".
226226
* It usually should find the same req again, or some READ preceding it. */
227227
list_for_each_entry(req, &connection->transfer_log, tl_requests)
228-
if (req->epoch == expect_epoch)
228+
if (req->epoch == expect_epoch) {
229+
tmp = req;
229230
break;
231+
}
232+
req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests);
230233
list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) {
231234
if (req->epoch != expect_epoch)
232235
break;

drivers/block/drbd/drbd_req.c

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void start_new_tl_epoch(struct drbd_connection *connection)
180180
void complete_master_bio(struct drbd_device *device,
181181
struct bio_and_error *m)
182182
{
183-
m->bio->bi_status = errno_to_blk_status(m->error);
183+
if (unlikely(m->error))
184+
m->bio->bi_status = errno_to_blk_status(m->error);
184185
bio_endio(m->bio);
185186
dec_ap_bio(device);
186187
}
@@ -332,17 +333,21 @@ static void set_if_null_req_next(struct drbd_peer_device *peer_device, struct dr
332333
static void advance_conn_req_next(struct drbd_peer_device *peer_device, struct drbd_request *req)
333334
{
334335
struct drbd_connection *connection = peer_device ? peer_device->connection : NULL;
336+
struct drbd_request *iter = req;
335337
if (!connection)
336338
return;
337339
if (connection->req_next != req)
338340
return;
339-
list_for_each_entry_continue(req, &connection->transfer_log, tl_requests) {
340-
const unsigned s = req->rq_state;
341-
if (s & RQ_NET_QUEUED)
341+
342+
req = NULL;
343+
list_for_each_entry_continue(iter, &connection->transfer_log, tl_requests) {
344+
const unsigned int s = iter->rq_state;
345+
346+
if (s & RQ_NET_QUEUED) {
347+
req = iter;
342348
break;
349+
}
343350
}
344-
if (&req->tl_requests == &connection->transfer_log)
345-
req = NULL;
346351
connection->req_next = req;
347352
}
348353

@@ -358,17 +363,21 @@ static void set_if_null_req_ack_pending(struct drbd_peer_device *peer_device, st
358363
static void advance_conn_req_ack_pending(struct drbd_peer_device *peer_device, struct drbd_request *req)
359364
{
360365
struct drbd_connection *connection = peer_device ? peer_device->connection : NULL;
366+
struct drbd_request *iter = req;
361367
if (!connection)
362368
return;
363369
if (connection->req_ack_pending != req)
364370
return;
365-
list_for_each_entry_continue(req, &connection->transfer_log, tl_requests) {
366-
const unsigned s = req->rq_state;
367-
if ((s & RQ_NET_SENT) && (s & RQ_NET_PENDING))
371+
372+
req = NULL;
373+
list_for_each_entry_continue(iter, &connection->transfer_log, tl_requests) {
374+
const unsigned int s = iter->rq_state;
375+
376+
if ((s & RQ_NET_SENT) && (s & RQ_NET_PENDING)) {
377+
req = iter;
368378
break;
379+
}
369380
}
370-
if (&req->tl_requests == &connection->transfer_log)
371-
req = NULL;
372381
connection->req_ack_pending = req;
373382
}
374383

@@ -384,17 +393,21 @@ static void set_if_null_req_not_net_done(struct drbd_peer_device *peer_device, s
384393
static void advance_conn_req_not_net_done(struct drbd_peer_device *peer_device, struct drbd_request *req)
385394
{
386395
struct drbd_connection *connection = peer_device ? peer_device->connection : NULL;
396+
struct drbd_request *iter = req;
387397
if (!connection)
388398
return;
389399
if (connection->req_not_net_done != req)
390400
return;
391-
list_for_each_entry_continue(req, &connection->transfer_log, tl_requests) {
392-
const unsigned s = req->rq_state;
393-
if ((s & RQ_NET_SENT) && !(s & RQ_NET_DONE))
401+
402+
req = NULL;
403+
list_for_each_entry_continue(iter, &connection->transfer_log, tl_requests) {
404+
const unsigned int s = iter->rq_state;
405+
406+
if ((s & RQ_NET_SENT) && !(s & RQ_NET_DONE)) {
407+
req = iter;
394408
break;
409+
}
395410
}
396-
if (&req->tl_requests == &connection->transfer_log)
397-
req = NULL;
398411
connection->req_not_net_done = req;
399412
}
400413

drivers/block/loop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,7 @@ struct compat_loop_info {
15911591
compat_ulong_t lo_inode; /* ioctl r/o */
15921592
compat_dev_t lo_rdevice; /* ioctl r/o */
15931593
compat_int_t lo_offset;
1594+
compat_int_t lo_encrypt_type; /* obsolete, ignored */
15941595
compat_int_t lo_encrypt_key_size; /* ioctl w/o */
15951596
compat_int_t lo_flags; /* ioctl r/o */
15961597
char lo_name[LO_NAME_SIZE];

drivers/block/n64cart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void n64cart_submit_bio(struct bio *bio)
8888
{
8989
struct bio_vec bvec;
9090
struct bvec_iter iter;
91-
struct device *dev = bio->bi_disk->private_data;
91+
struct device *dev = bio->bi_bdev->bd_disk->private_data;
9292
u32 pos = bio->bi_iter.bi_sector << SECTOR_SHIFT;
9393

9494
bio_for_each_segment(bvec, bio, iter) {

drivers/block/nbd.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,17 +1800,6 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
18001800
refcount_set(&nbd->refs, 0);
18011801
INIT_LIST_HEAD(&nbd->list);
18021802
disk->major = NBD_MAJOR;
1803-
1804-
/* Too big first_minor can cause duplicate creation of
1805-
* sysfs files/links, since index << part_shift might overflow, or
1806-
* MKDEV() expect that the max bits of first_minor is 20.
1807-
*/
1808-
disk->first_minor = index << part_shift;
1809-
if (disk->first_minor < index || disk->first_minor > MINORMASK) {
1810-
err = -EINVAL;
1811-
goto out_free_work;
1812-
}
1813-
18141803
disk->minors = 1 << part_shift;
18151804
disk->fops = &nbd_fops;
18161805
disk->private_data = nbd;
@@ -1915,8 +1904,19 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
19151904
if (!netlink_capable(skb, CAP_SYS_ADMIN))
19161905
return -EPERM;
19171906

1918-
if (info->attrs[NBD_ATTR_INDEX])
1907+
if (info->attrs[NBD_ATTR_INDEX]) {
19191908
index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
1909+
1910+
/*
1911+
* Too big first_minor can cause duplicate creation of
1912+
* sysfs files/links, since index << part_shift might overflow, or
1913+
* MKDEV() expect that the max bits of first_minor is 20.
1914+
*/
1915+
if (index < 0 || index > MINORMASK >> part_shift) {
1916+
printk(KERN_ERR "nbd: illegal input index %d\n", index);
1917+
return -EINVAL;
1918+
}
1919+
}
19201920
if (!info->attrs[NBD_ATTR_SOCKETS]) {
19211921
printk(KERN_ERR "nbd: must specify at least one socket\n");
19221922
return -EINVAL;

drivers/block/xen-blkback/blkback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ static int xen_blkbk_parse_indirect(struct blkif_request *req,
931931
if (rc)
932932
goto unmap;
933933

934-
for (n = 0, i = 0; n < nseg; n++) {
934+
for (n = 0; n < nseg; n++) {
935935
uint8_t first_sect, last_sect;
936936

937937
if ((n % SEGS_PER_INDIRECT_FRAME) == 0) {

drivers/block/xen-blkfront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ struct setup_rw_req {
576576
struct blkif_request *ring_req;
577577
grant_ref_t gref_head;
578578
unsigned int id;
579-
/* Only used when persistent grant is used and it's a read request */
579+
/* Only used when persistent grant is used and it's a write request */
580580
bool need_copy;
581581
unsigned int bvec_off;
582582
char *bvec_data;

drivers/nvme/host/core.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,9 +1830,6 @@ static void nvme_update_disk_info(struct gendisk *disk,
18301830
nvme_config_discard(disk, ns);
18311831
blk_queue_max_write_zeroes_sectors(disk->queue,
18321832
ns->ctrl->max_zeroes_sectors);
1833-
1834-
set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO) ||
1835-
test_bit(NVME_NS_FORCE_RO, &ns->flags));
18361833
}
18371834

18381835
static inline bool nvme_first_scan(struct gendisk *disk)
@@ -1891,6 +1888,8 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
18911888
goto out_unfreeze;
18921889
}
18931890

1891+
set_disk_ro(ns->disk, (id->nsattr & NVME_NS_ATTR_RO) ||
1892+
test_bit(NVME_NS_FORCE_RO, &ns->flags));
18941893
set_bit(NVME_NS_READY, &ns->flags);
18951894
blk_mq_unfreeze_queue(ns->disk->queue);
18961895

@@ -1903,6 +1902,9 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
19031902
if (nvme_ns_head_multipath(ns->head)) {
19041903
blk_mq_freeze_queue(ns->head->disk->queue);
19051904
nvme_update_disk_info(ns->head->disk, ns, id);
1905+
set_disk_ro(ns->head->disk,
1906+
(id->nsattr & NVME_NS_ATTR_RO) ||
1907+
test_bit(NVME_NS_FORCE_RO, &ns->flags));
19061908
nvme_mpath_revalidate_paths(ns);
19071909
blk_stack_limits(&ns->head->disk->queue->limits,
19081910
&ns->queue->limits, 0);
@@ -3589,15 +3591,20 @@ static const struct attribute_group *nvme_dev_attr_groups[] = {
35893591
NULL,
35903592
};
35913593

3592-
static struct nvme_ns_head *nvme_find_ns_head(struct nvme_subsystem *subsys,
3594+
static struct nvme_ns_head *nvme_find_ns_head(struct nvme_ctrl *ctrl,
35933595
unsigned nsid)
35943596
{
35953597
struct nvme_ns_head *h;
35963598

3597-
lockdep_assert_held(&subsys->lock);
3599+
lockdep_assert_held(&ctrl->subsys->lock);
35983600

3599-
list_for_each_entry(h, &subsys->nsheads, entry) {
3600-
if (h->ns_id != nsid)
3601+
list_for_each_entry(h, &ctrl->subsys->nsheads, entry) {
3602+
/*
3603+
* Private namespaces can share NSIDs under some conditions.
3604+
* In that case we can't use the same ns_head for namespaces
3605+
* with the same NSID.
3606+
*/
3607+
if (h->ns_id != nsid || !nvme_is_unique_nsid(ctrl, h))
36013608
continue;
36023609
if (!list_empty(&h->list) && nvme_tryget_ns_head(h))
36033610
return h;
@@ -3791,7 +3798,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
37913798
}
37923799

37933800
mutex_lock(&ctrl->subsys->lock);
3794-
head = nvme_find_ns_head(ctrl->subsys, nsid);
3801+
head = nvme_find_ns_head(ctrl, nsid);
37953802
if (!head) {
37963803
ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, ids);
37973804
if (ret) {
@@ -3988,6 +3995,16 @@ static void nvme_ns_remove(struct nvme_ns *ns)
39883995
set_capacity(ns->disk, 0);
39893996
nvme_fault_inject_fini(&ns->fault_inject);
39903997

3998+
/*
3999+
* Ensure that !NVME_NS_READY is seen by other threads to prevent
4000+
* this ns going back into current_path.
4001+
*/
4002+
synchronize_srcu(&ns->head->srcu);
4003+
4004+
/* wait for concurrent submissions */
4005+
if (nvme_mpath_clear_current_path(ns))
4006+
synchronize_srcu(&ns->head->srcu);
4007+
39914008
mutex_lock(&ns->ctrl->subsys->lock);
39924009
list_del_rcu(&ns->siblings);
39934010
if (list_empty(&ns->head->list)) {
@@ -3999,10 +4016,6 @@ static void nvme_ns_remove(struct nvme_ns *ns)
39994016
/* guarantee not available in head->list */
40004017
synchronize_rcu();
40014018

4002-
/* wait for concurrent submissions */
4003-
if (nvme_mpath_clear_current_path(ns))
4004-
synchronize_srcu(&ns->head->srcu);
4005-
40064019
if (!nvme_ns_head_multipath(ns->head))
40074020
nvme_cdev_del(&ns->cdev, &ns->cdev_device);
40084021
del_gendisk(ns->disk);
@@ -4480,6 +4493,7 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl)
44804493
if (ctrl->queue_count > 1) {
44814494
nvme_queue_scan(ctrl);
44824495
nvme_start_queues(ctrl);
4496+
nvme_mpath_update(ctrl);
44834497
}
44844498

44854499
nvme_change_uevent(ctrl, "NVME_EVENT=connected");

drivers/nvme/host/multipath.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,11 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
482482

483483
/*
484484
* Add a multipath node if the subsystems supports multiple controllers.
485-
* We also do this for private namespaces as the namespace sharing data could
486-
* change after a rescan.
485+
* We also do this for private namespaces as the namespace sharing flag
486+
* could change after a rescan.
487487
*/
488-
if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) || !multipath)
488+
if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) ||
489+
!nvme_is_unique_nsid(ctrl, head) || !multipath)
489490
return 0;
490491

491492
head->disk = blk_alloc_disk(ctrl->numa_node);
@@ -612,8 +613,17 @@ static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc,
612613
ns->ana_grpid = le32_to_cpu(desc->grpid);
613614
ns->ana_state = desc->state;
614615
clear_bit(NVME_NS_ANA_PENDING, &ns->flags);
615-
616-
if (nvme_state_is_live(ns->ana_state))
616+
/*
617+
* nvme_mpath_set_live() will trigger I/O to the multipath path device
618+
* and in turn to this path device. However we cannot accept this I/O
619+
* if the controller is not live. This may deadlock if called from
620+
* nvme_mpath_init_identify() and the ctrl will never complete
621+
* initialization, preventing I/O from completing. For this case we
622+
* will reprocess the ANA log page in nvme_mpath_update() once the
623+
* controller is ready.
624+
*/
625+
if (nvme_state_is_live(ns->ana_state) &&
626+
ns->ctrl->state == NVME_CTRL_LIVE)
617627
nvme_mpath_set_live(ns);
618628
}
619629

@@ -700,6 +710,18 @@ static void nvme_ana_work(struct work_struct *work)
700710
nvme_read_ana_log(ctrl);
701711
}
702712

713+
void nvme_mpath_update(struct nvme_ctrl *ctrl)
714+
{
715+
u32 nr_change_groups = 0;
716+
717+
if (!ctrl->ana_log_buf)
718+
return;
719+
720+
mutex_lock(&ctrl->ana_lock);
721+
nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
722+
mutex_unlock(&ctrl->ana_lock);
723+
}
724+
703725
static void nvme_anatt_timeout(struct timer_list *t)
704726
{
705727
struct nvme_ctrl *ctrl = from_timer(ctrl, t, anatt_timer);

0 commit comments

Comments
 (0)