Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()

+28 -26
+1 -10
block/genhd.c
··· 29 29 30 30 static struct kobject *block_depr; 31 31 32 - DECLARE_RWSEM(bdev_lookup_sem); 33 - 34 32 /* for extended dynamic devt allocation, currently only one major is used */ 35 33 #define NR_EXT_DEVT (1 << MINORBITS) 36 34 static DEFINE_IDA(ext_devt_ida); ··· 607 609 blk_integrity_del(disk); 608 610 disk_del_events(disk); 609 611 610 - /* 611 - * Block lookups of the disk until all bdevs are unhashed and the 612 - * disk is marked as dead (GENHD_FL_UP cleared). 613 - */ 614 - down_write(&bdev_lookup_sem); 615 - 616 612 mutex_lock(&disk->part0->bd_mutex); 613 + disk->flags &= ~GENHD_FL_UP; 617 614 blk_drop_partitions(disk); 618 615 mutex_unlock(&disk->part0->bd_mutex); 619 616 ··· 622 629 remove_inode_hash(disk->part0->bd_inode); 623 630 624 631 set_capacity(disk, 0); 625 - disk->flags &= ~GENHD_FL_UP; 626 - up_write(&bdev_lookup_sem); 627 632 628 633 if (!(disk->flags & GENHD_FL_HIDDEN)) { 629 634 sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
+12
drivers/nvme/host/fc.c
··· 2461 2461 static void 2462 2462 __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) 2463 2463 { 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 + 2464 2476 /* 2465 2477 * If io queues are present, stop them and terminate all outstanding 2466 2478 * ios on them. As FC allocates FC exchange for each io, the
+3 -2
drivers/nvme/host/tcp.c
··· 943 943 if (ret <= 0) 944 944 return ret; 945 945 946 - nvme_tcp_advance_req(req, ret); 947 946 if (queue->data_digest) 948 947 nvme_tcp_ddgst_update(queue->snd_hash, page, 949 948 offset, ret); ··· 959 960 } 960 961 return 1; 961 962 } 963 + nvme_tcp_advance_req(req, ret); 962 964 } 963 965 return -EAGAIN; 964 966 } ··· 1140 1140 pending = true; 1141 1141 else if (unlikely(result < 0)) 1142 1142 break; 1143 - } 1143 + } else 1144 + pending = !llist_empty(&queue->req_list); 1144 1145 1145 1146 result = nvme_tcp_try_recv(queue); 1146 1147 if (result > 0)
+1 -1
drivers/nvme/target/core.c
··· 1372 1372 goto out_free_changed_ns_list; 1373 1373 1374 1374 if (subsys->cntlid_min > subsys->cntlid_max) 1375 - goto out_free_changed_ns_list; 1375 + goto out_free_sqs; 1376 1376 1377 1377 ret = ida_simple_get(&cntlid_ida, 1378 1378 subsys->cntlid_min, subsys->cntlid_max,
+3 -1
drivers/nvme/target/loop.c
··· 590 590 591 591 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops, 592 592 0 /* no quirks, we're perfect! */); 593 - if (ret) 593 + if (ret) { 594 + kfree(ctrl); 594 595 goto out; 596 + } 595 597 596 598 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) 597 599 WARN_ON_ONCE(1);
+8 -10
fs/block_dev.c
··· 1244 1244 1245 1245 lockdep_assert_held(&bdev->bd_mutex); 1246 1246 1247 + if (!(disk->flags & GENHD_FL_UP)) 1248 + return -ENXIO; 1249 + 1247 1250 rescan: 1248 1251 if (bdev->bd_part_count) 1249 1252 return -EBUSY; ··· 1301 1298 struct gendisk *disk = bdev->bd_disk; 1302 1299 int ret = 0; 1303 1300 1301 + if (!(disk->flags & GENHD_FL_UP)) 1302 + return -ENXIO; 1303 + 1304 1304 if (!bdev->bd_openers) { 1305 1305 if (!bdev_is_partition(bdev)) { 1306 1306 ret = 0; ··· 1338 1332 whole->bd_part_count++; 1339 1333 mutex_unlock(&whole->bd_mutex); 1340 1334 1341 - if (!(disk->flags & GENHD_FL_UP) || 1342 - !bdev_nr_sectors(bdev)) { 1335 + if (!bdev_nr_sectors(bdev)) { 1343 1336 __blkdev_put(whole, mode, 1); 1344 1337 bdput(whole); 1345 1338 return -ENXIO; ··· 1369 1364 struct block_device *bdev; 1370 1365 struct gendisk *disk; 1371 1366 1372 - down_read(&bdev_lookup_sem); 1373 1367 bdev = bdget(dev); 1374 1368 if (!bdev) { 1375 - up_read(&bdev_lookup_sem); 1376 1369 blk_request_module(dev); 1377 - down_read(&bdev_lookup_sem); 1378 - 1379 1370 bdev = bdget(dev); 1380 1371 if (!bdev) 1381 - goto unlock; 1372 + return NULL; 1382 1373 } 1383 1374 1384 1375 disk = bdev->bd_disk; ··· 1384 1383 goto put_disk; 1385 1384 if (!try_module_get(bdev->bd_disk->fops->owner)) 1386 1385 goto put_disk; 1387 - up_read(&bdev_lookup_sem); 1388 1386 return bdev; 1389 1387 put_disk: 1390 1388 put_disk(disk); 1391 1389 bdput: 1392 1390 bdput(bdev); 1393 - unlock: 1394 - up_read(&bdev_lookup_sem); 1395 1391 return NULL; 1396 1392 } 1397 1393
-2
include/linux/genhd.h
··· 306 306 } 307 307 #endif /* CONFIG_SYSFS */ 308 308 309 - extern struct rw_semaphore bdev_lookup_sem; 310 - 311 309 dev_t blk_lookup_devt(const char *name, int partno); 312 310 void blk_request_module(dev_t devt); 313 311 #ifdef CONFIG_BLOCK