Skip to content

Commit 4ff2473

Browse files
committed
Merge tag 'block-5.13-2021-05-22' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Fix BLKRRPART and deletion race (Gulam, Christoph) - NVMe pull request (Christoph): - nvme-tcp corruption and timeout fixes (Sagi Grimberg, Keith Busch) - nvme-fc teardown fix (James Smart) - nvmet/nvme-loop memory leak fixes (Wu Bo)" * tag 'block-5.13-2021-05-22' of git://git.kernel.dk/linux-block: block: fix a race between del_gendisk and BLKRRPART block: prevent block device lookups at the beginning of del_gendisk nvme-fc: clear q_live at beginning of association teardown nvme-tcp: rerun io_work if req_list is not empty nvme-tcp: fix possible use-after-completion nvme-loop: fix memory leak in nvme_loop_create_ctrl() nvmet: fix memory leak in nvmet_alloc_ctrl()
2 parents b9231df + bc6a385 commit 4ff2473

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

block/genhd.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
static struct kobject *block_depr;
3131

32-
DECLARE_RWSEM(bdev_lookup_sem);
33-
3432
/* for extended dynamic devt allocation, currently only one major is used */
3533
#define NR_EXT_DEVT (1 << MINORBITS)
3634
static DEFINE_IDA(ext_devt_ida);
@@ -609,13 +607,8 @@ void del_gendisk(struct gendisk *disk)
609607
blk_integrity_del(disk);
610608
disk_del_events(disk);
611609

612-
/*
613-
* Block lookups of the disk until all bdevs are unhashed and the
614-
* disk is marked as dead (GENHD_FL_UP cleared).
615-
*/
616-
down_write(&bdev_lookup_sem);
617-
618610
mutex_lock(&disk->part0->bd_mutex);
611+
disk->flags &= ~GENHD_FL_UP;
619612
blk_drop_partitions(disk);
620613
mutex_unlock(&disk->part0->bd_mutex);
621614

@@ -629,8 +622,6 @@ void del_gendisk(struct gendisk *disk)
629622
remove_inode_hash(disk->part0->bd_inode);
630623

631624
set_capacity(disk, 0);
632-
disk->flags &= ~GENHD_FL_UP;
633-
up_write(&bdev_lookup_sem);
634625

635626
if (!(disk->flags & GENHD_FL_HIDDEN)) {
636627
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");

drivers/nvme/host/fc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,18 @@ nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
24612461
static void
24622462
__nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
24632463
{
2464+
int q;
2465+
2466+
/*
2467+
* if aborting io, the queues are no longer good, mark them
2468+
* all as not live.
2469+
*/
2470+
if (ctrl->ctrl.queue_count > 1) {
2471+
for (q = 1; q < ctrl->ctrl.queue_count; q++)
2472+
clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[q].flags);
2473+
}
2474+
clear_bit(NVME_FC_Q_LIVE, &ctrl->queues[0].flags);
2475+
24642476
/*
24652477
* If io queues are present, stop them and terminate all outstanding
24662478
* ios on them. As FC allocates FC exchange for each io, the

drivers/nvme/host/tcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
943943
if (ret <= 0)
944944
return ret;
945945

946-
nvme_tcp_advance_req(req, ret);
947946
if (queue->data_digest)
948947
nvme_tcp_ddgst_update(queue->snd_hash, page,
949948
offset, ret);
@@ -960,6 +959,7 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
960959
}
961960
return 1;
962961
}
962+
nvme_tcp_advance_req(req, ret);
963963
}
964964
return -EAGAIN;
965965
}
@@ -1140,7 +1140,8 @@ static void nvme_tcp_io_work(struct work_struct *w)
11401140
pending = true;
11411141
else if (unlikely(result < 0))
11421142
break;
1143-
}
1143+
} else
1144+
pending = !llist_empty(&queue->req_list);
11441145

11451146
result = nvme_tcp_try_recv(queue);
11461147
if (result > 0)

drivers/nvme/target/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
13721372
goto out_free_changed_ns_list;
13731373

13741374
if (subsys->cntlid_min > subsys->cntlid_max)
1375-
goto out_free_changed_ns_list;
1375+
goto out_free_sqs;
13761376

13771377
ret = ida_simple_get(&cntlid_ida,
13781378
subsys->cntlid_min, subsys->cntlid_max,

drivers/nvme/target/loop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
590590

591591
ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops,
592592
0 /* no quirks, we're perfect! */);
593-
if (ret)
593+
if (ret) {
594+
kfree(ctrl);
594595
goto out;
596+
}
595597

596598
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
597599
WARN_ON_ONCE(1);

fs/block_dev.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,9 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
12441244

12451245
lockdep_assert_held(&bdev->bd_mutex);
12461246

1247+
if (!(disk->flags & GENHD_FL_UP))
1248+
return -ENXIO;
1249+
12471250
rescan:
12481251
if (bdev->bd_part_count)
12491252
return -EBUSY;
@@ -1298,6 +1301,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode)
12981301
struct gendisk *disk = bdev->bd_disk;
12991302
int ret = 0;
13001303

1304+
if (!(disk->flags & GENHD_FL_UP))
1305+
return -ENXIO;
1306+
13011307
if (!bdev->bd_openers) {
13021308
if (!bdev_is_partition(bdev)) {
13031309
ret = 0;
@@ -1332,8 +1338,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode)
13321338
whole->bd_part_count++;
13331339
mutex_unlock(&whole->bd_mutex);
13341340

1335-
if (!(disk->flags & GENHD_FL_UP) ||
1336-
!bdev_nr_sectors(bdev)) {
1341+
if (!bdev_nr_sectors(bdev)) {
13371342
__blkdev_put(whole, mode, 1);
13381343
bdput(whole);
13391344
return -ENXIO;
@@ -1364,16 +1369,12 @@ struct block_device *blkdev_get_no_open(dev_t dev)
13641369
struct block_device *bdev;
13651370
struct gendisk *disk;
13661371

1367-
down_read(&bdev_lookup_sem);
13681372
bdev = bdget(dev);
13691373
if (!bdev) {
1370-
up_read(&bdev_lookup_sem);
13711374
blk_request_module(dev);
1372-
down_read(&bdev_lookup_sem);
1373-
13741375
bdev = bdget(dev);
13751376
if (!bdev)
1376-
goto unlock;
1377+
return NULL;
13771378
}
13781379

13791380
disk = bdev->bd_disk;
@@ -1383,14 +1384,11 @@ struct block_device *blkdev_get_no_open(dev_t dev)
13831384
goto put_disk;
13841385
if (!try_module_get(bdev->bd_disk->fops->owner))
13851386
goto put_disk;
1386-
up_read(&bdev_lookup_sem);
13871387
return bdev;
13881388
put_disk:
13891389
put_disk(disk);
13901390
bdput:
13911391
bdput(bdev);
1392-
unlock:
1393-
up_read(&bdev_lookup_sem);
13941392
return NULL;
13951393
}
13961394

include/linux/genhd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ static inline void bd_unlink_disk_holder(struct block_device *bdev,
306306
}
307307
#endif /* CONFIG_SYSFS */
308308

309-
extern struct rw_semaphore bdev_lookup_sem;
310-
311309
dev_t blk_lookup_devt(const char *name, int partno);
312310
void blk_request_module(dev_t devt);
313311
#ifdef CONFIG_BLOCK

0 commit comments

Comments
 (0)