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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'block-6.3-2023-03-03' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:

- NVMe pull request via Christoph:
- Don't access released socket during error recovery (Akinobu
Mita)
- Bring back auto-removal of deleted namespaces during sequential
scan (Christoph Hellwig)
- Fix an error code in nvme_auth_process_dhchap_challenge (Dan
Carpenter)
- Show well known discovery name (Daniel Wagner)
- Add a missing endianess conversion in effects masking (Keith
Busch)

- Fix for a regression introduced in blk-rq-qos during init in this
merge window (Breno)

- Reorder a few fields in struct blk_mq_tag_set, eliminating a few
holes and shrinking it (Christophe)

- Remove redundant bdev_get_queue() NULL checks (Juhyung)

- Add sed-opal single user mode support flag (Luca)

- Remove SQE128 check in ublk as it isn't needed, saving some memory
(Ming)

- Op specific segment checking for cloned requests (Uday)

- Exclusive open partition scan fixes (Yu)

- Loop offset/size checking before assigning them in the device (Zhong)

- Bio polling fixes (me)

* tag 'block-6.3-2023-03-03' of git://git.kernel.dk/linux:
blk-mq: enforce op-specific segment limits in blk_insert_cloned_request
nvme-fabrics: show well known discovery name
nvme-tcp: don't access released socket during error recovery
nvme-auth: fix an error code in nvme_auth_process_dhchap_challenge()
nvme: bring back auto-removal of deleted namespaces during sequential scan
blk-iocost: Pass gendisk to ioc_refresh_params
nvme: fix sparse warning on effects masking
block: be a bit more careful in checking for NULL bdev while polling
block: clear bio->bi_bdev when putting a bio back in the cache
loop: loop_set_status_from_info() check before assignment
ublk: remove check IO_URING_F_SQE128 in ublk_ch_uring_cmd
block: remove more NULL checks after bdev_get_queue()
blk-mq: Reorder fields in 'struct blk_mq_tag_set'
block: fix scan partition for exclusively open device again
block: Revert "block: Do not reread partition table on exclusively open device"
sed-opal: add support flag for SUM in status ioctl

+114 -85
+1
block/bio.c
··· 772 772 773 773 if ((bio->bi_opf & REQ_POLLED) && !WARN_ON_ONCE(in_interrupt())) { 774 774 bio->bi_next = cache->free_list; 775 + bio->bi_bdev = NULL; 775 776 cache->free_list = bio; 776 777 cache->nr++; 777 778 } else {
+8 -2
block/blk-core.c
··· 858 858 */ 859 859 int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags) 860 860 { 861 - struct request_queue *q = bdev_get_queue(bio->bi_bdev); 862 861 blk_qc_t cookie = READ_ONCE(bio->bi_cookie); 862 + struct block_device *bdev; 863 + struct request_queue *q; 863 864 int ret = 0; 864 865 866 + bdev = READ_ONCE(bio->bi_bdev); 867 + if (!bdev) 868 + return 0; 869 + 870 + q = bdev_get_queue(bdev); 865 871 if (cookie == BLK_QC_T_NONE || 866 872 !test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) 867 873 return 0; ··· 936 930 */ 937 931 rcu_read_lock(); 938 932 bio = READ_ONCE(kiocb->private); 939 - if (bio && bio->bi_bdev) 933 + if (bio) 940 934 ret = bio_poll(bio, iob, flags); 941 935 rcu_read_unlock(); 942 936
+20 -6
block/blk-iocost.c
··· 800 800 ioc_refresh_margins(ioc); 801 801 } 802 802 803 - static int ioc_autop_idx(struct ioc *ioc) 803 + /* 804 + * ioc->rqos.disk isn't initialized when this function is called from 805 + * the init path. 806 + */ 807 + static int ioc_autop_idx(struct ioc *ioc, struct gendisk *disk) 804 808 { 805 809 int idx = ioc->autop_idx; 806 810 const struct ioc_params *p = &autop[idx]; ··· 812 808 u64 now_ns; 813 809 814 810 /* rotational? */ 815 - if (!blk_queue_nonrot(ioc->rqos.disk->queue)) 811 + if (!blk_queue_nonrot(disk->queue)) 816 812 return AUTOP_HDD; 817 813 818 814 /* handle SATA SSDs w/ broken NCQ */ 819 - if (blk_queue_depth(ioc->rqos.disk->queue) == 1) 815 + if (blk_queue_depth(disk->queue) == 1) 820 816 return AUTOP_SSD_QD1; 821 817 822 818 /* use one of the normal ssd sets */ ··· 905 901 &c[LCOEF_WPAGE], &c[LCOEF_WSEQIO], &c[LCOEF_WRANDIO]); 906 902 } 907 903 908 - static bool ioc_refresh_params(struct ioc *ioc, bool force) 904 + /* 905 + * struct gendisk is required as an argument because ioc->rqos.disk 906 + * is not properly initialized when called from the init path. 907 + */ 908 + static bool ioc_refresh_params_disk(struct ioc *ioc, bool force, 909 + struct gendisk *disk) 909 910 { 910 911 const struct ioc_params *p; 911 912 int idx; 912 913 913 914 lockdep_assert_held(&ioc->lock); 914 915 915 - idx = ioc_autop_idx(ioc); 916 + idx = ioc_autop_idx(ioc, disk); 916 917 p = &autop[idx]; 917 918 918 919 if (idx == ioc->autop_idx && !force) ··· 946 937 VTIME_PER_USEC, MILLION); 947 938 948 939 return true; 940 + } 941 + 942 + static bool ioc_refresh_params(struct ioc *ioc, bool force) 943 + { 944 + return ioc_refresh_params_disk(ioc, force, ioc->rqos.disk); 949 945 } 950 946 951 947 /* ··· 2894 2880 2895 2881 spin_lock_irq(&ioc->lock); 2896 2882 ioc->autop_idx = AUTOP_INVALID; 2897 - ioc_refresh_params(ioc, true); 2883 + ioc_refresh_params_disk(ioc, true, disk); 2898 2884 spin_unlock_irq(&ioc->lock); 2899 2885 2900 2886 /*
-7
block/blk-merge.c
··· 587 587 } 588 588 EXPORT_SYMBOL(__blk_rq_map_sg); 589 589 590 - static inline unsigned int blk_rq_get_max_segments(struct request *rq) 591 - { 592 - if (req_op(rq) == REQ_OP_DISCARD) 593 - return queue_max_discard_segments(rq->q); 594 - return queue_max_segments(rq->q); 595 - } 596 - 597 590 static inline unsigned int blk_rq_get_max_sectors(struct request *rq, 598 591 sector_t offset) 599 592 {
+4 -3
block/blk-mq.c
··· 3000 3000 { 3001 3001 struct request_queue *q = rq->q; 3002 3002 unsigned int max_sectors = blk_queue_get_max_sectors(q, req_op(rq)); 3003 + unsigned int max_segments = blk_rq_get_max_segments(rq); 3003 3004 blk_status_t ret; 3004 3005 3005 3006 if (blk_rq_sectors(rq) > max_sectors) { ··· 3027 3026 * original queue. 3028 3027 */ 3029 3028 rq->nr_phys_segments = blk_recalc_rq_segments(rq); 3030 - if (rq->nr_phys_segments > queue_max_segments(q)) { 3031 - printk(KERN_ERR "%s: over max segments limit. (%hu > %hu)\n", 3032 - __func__, rq->nr_phys_segments, queue_max_segments(q)); 3029 + if (rq->nr_phys_segments > max_segments) { 3030 + printk(KERN_ERR "%s: over max segments limit. (%u > %u)\n", 3031 + __func__, rq->nr_phys_segments, max_segments); 3033 3032 return BLK_STS_IOERR; 3034 3033 } 3035 3034
-10
block/blk-zoned.c
··· 334 334 { 335 335 void __user *argp = (void __user *)arg; 336 336 struct zone_report_args args; 337 - struct request_queue *q; 338 337 struct blk_zone_report rep; 339 338 int ret; 340 339 341 340 if (!argp) 342 341 return -EINVAL; 343 - 344 - q = bdev_get_queue(bdev); 345 - if (!q) 346 - return -ENXIO; 347 342 348 343 if (!bdev_is_zoned(bdev)) 349 344 return -ENOTTY; ··· 386 391 unsigned int cmd, unsigned long arg) 387 392 { 388 393 void __user *argp = (void __user *)arg; 389 - struct request_queue *q; 390 394 struct blk_zone_range zrange; 391 395 enum req_op op; 392 396 int ret; 393 397 394 398 if (!argp) 395 399 return -EINVAL; 396 - 397 - q = bdev_get_queue(bdev); 398 - if (!q) 399 - return -ENXIO; 400 400 401 401 if (!bdev_is_zoned(bdev)) 402 402 return -ENOTTY;
+8 -1
block/blk.h
··· 156 156 return false; 157 157 } 158 158 159 + static inline unsigned int blk_rq_get_max_segments(struct request *rq) 160 + { 161 + if (req_op(rq) == REQ_OP_DISCARD) 162 + return queue_max_discard_segments(rq->q); 163 + return queue_max_segments(rq->q); 164 + } 165 + 159 166 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, 160 167 enum req_op op) 161 168 { ··· 434 427 435 428 struct request_queue *blk_alloc_queue(int node_id); 436 429 437 - int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner); 430 + int disk_scan_partitions(struct gendisk *disk, fmode_t mode); 438 431 439 432 int disk_alloc_events(struct gendisk *disk); 440 433 void disk_add_events(struct gendisk *disk);
+28 -9
block/genhd.c
··· 356 356 } 357 357 EXPORT_SYMBOL_GPL(disk_uevent); 358 358 359 - int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner) 359 + int disk_scan_partitions(struct gendisk *disk, fmode_t mode) 360 360 { 361 361 struct block_device *bdev; 362 + int ret = 0; 362 363 363 364 if (disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN)) 364 365 return -EINVAL; ··· 367 366 return -EINVAL; 368 367 if (disk->open_partitions) 369 368 return -EBUSY; 370 - /* Someone else has bdev exclusively open? */ 371 - if (disk->part0->bd_holder && disk->part0->bd_holder != owner) 372 - return -EBUSY; 373 369 374 370 set_bit(GD_NEED_PART_SCAN, &disk->state); 375 - bdev = blkdev_get_by_dev(disk_devt(disk), mode, NULL); 371 + /* 372 + * If the device is opened exclusively by current thread already, it's 373 + * safe to scan partitons, otherwise, use bd_prepare_to_claim() to 374 + * synchronize with other exclusive openers and other partition 375 + * scanners. 376 + */ 377 + if (!(mode & FMODE_EXCL)) { 378 + ret = bd_prepare_to_claim(disk->part0, disk_scan_partitions); 379 + if (ret) 380 + return ret; 381 + } 382 + 383 + bdev = blkdev_get_by_dev(disk_devt(disk), mode & ~FMODE_EXCL, NULL); 376 384 if (IS_ERR(bdev)) 377 - return PTR_ERR(bdev); 378 - blkdev_put(bdev, mode); 379 - return 0; 385 + ret = PTR_ERR(bdev); 386 + else 387 + blkdev_put(bdev, mode); 388 + 389 + if (!(mode & FMODE_EXCL)) 390 + bd_abort_claiming(disk->part0, disk_scan_partitions); 391 + return ret; 380 392 } 381 393 382 394 /** ··· 511 497 if (ret) 512 498 goto out_unregister_bdi; 513 499 500 + /* Make sure the first partition scan will be proceed */ 501 + if (get_capacity(disk) && !(disk->flags & GENHD_FL_NO_PART) && 502 + !test_bit(GD_SUPPRESS_PART_SCAN, &disk->state)) 503 + set_bit(GD_NEED_PART_SCAN, &disk->state); 504 + 514 505 bdev_add(disk->part0, ddev->devt); 515 506 if (get_capacity(disk)) 516 - disk_scan_partitions(disk, FMODE_READ, NULL); 507 + disk_scan_partitions(disk, FMODE_READ); 517 508 518 509 /* 519 510 * Announce the disk and partitions after all partitions are
+6 -7
block/ioctl.c
··· 467 467 * user space. Note the separate arg/argp parameters that are needed 468 468 * to deal with the compat_ptr() conversion. 469 469 */ 470 - static int blkdev_common_ioctl(struct file *file, fmode_t mode, unsigned cmd, 471 - unsigned long arg, void __user *argp) 470 + static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, 471 + unsigned int cmd, unsigned long arg, 472 + void __user *argp) 472 473 { 473 - struct block_device *bdev = I_BDEV(file->f_mapping->host); 474 474 unsigned int max_sectors; 475 475 476 476 switch (cmd) { ··· 528 528 return -EACCES; 529 529 if (bdev_is_partition(bdev)) 530 530 return -EINVAL; 531 - return disk_scan_partitions(bdev->bd_disk, mode & ~FMODE_EXCL, 532 - file); 531 + return disk_scan_partitions(bdev->bd_disk, mode); 533 532 case BLKTRACESTART: 534 533 case BLKTRACESTOP: 535 534 case BLKTRACETEARDOWN: ··· 606 607 break; 607 608 } 608 609 609 - ret = blkdev_common_ioctl(file, mode, cmd, arg, argp); 610 + ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); 610 611 if (ret != -ENOIOCTLCMD) 611 612 return ret; 612 613 ··· 675 676 break; 676 677 } 677 678 678 - ret = blkdev_common_ioctl(file, mode, cmd, arg, argp); 679 + ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); 679 680 if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl) 680 681 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg); 681 682
+2
block/sed-opal.c
··· 487 487 break; 488 488 case FC_SINGLEUSER: 489 489 single_user = check_sum(body->features); 490 + if (single_user) 491 + dev->flags |= OPAL_FL_SUM_SUPPORTED; 490 492 break; 491 493 case FC_GEOMETRY: 492 494 check_geometry(dev, body);
+4 -4
drivers/block/loop.c
··· 977 977 return -EINVAL; 978 978 } 979 979 980 + /* Avoid assigning overflow values */ 981 + if (info->lo_offset > LLONG_MAX || info->lo_sizelimit > LLONG_MAX) 982 + return -EOVERFLOW; 983 + 980 984 lo->lo_offset = info->lo_offset; 981 985 lo->lo_sizelimit = info->lo_sizelimit; 982 - 983 - /* loff_t vars have been assigned __u64 */ 984 - if (lo->lo_offset < 0 || lo->lo_sizelimit < 0) 985 - return -EOVERFLOW; 986 986 987 987 memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE); 988 988 lo->lo_file_name[LO_NAME_SIZE-1] = 0;
-3
drivers/block/ublk_drv.c
··· 1271 1271 __func__, cmd->cmd_op, ub_cmd->q_id, tag, 1272 1272 ub_cmd->result); 1273 1273 1274 - if (!(issue_flags & IO_URING_F_SQE128)) 1275 - goto out; 1276 - 1277 1274 if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues) 1278 1275 goto out; 1279 1276
+1 -1
drivers/nvme/host/auth.c
··· 256 256 chap->qid, ret, gid_name); 257 257 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; 258 258 chap->dh_tfm = NULL; 259 - return -ret; 259 + return ret; 260 260 } 261 261 dev_dbg(ctrl->device, "qid %d: selected DH group %s\n", 262 262 chap->qid, gid_name);
+19 -18
drivers/nvme/host/core.c
··· 38 38 bool is_shared; 39 39 bool is_readonly; 40 40 bool is_ready; 41 + bool is_removed; 41 42 }; 42 43 43 44 unsigned int admin_timeout = 60; ··· 1403 1402 error = nvme_submit_sync_cmd(ctrl->admin_q, &c, *id, sizeof(**id)); 1404 1403 if (error) { 1405 1404 dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error); 1406 - goto out_free_id; 1405 + kfree(*id); 1407 1406 } 1408 - 1409 - error = NVME_SC_INVALID_NS | NVME_SC_DNR; 1410 - if ((*id)->ncap == 0) /* namespace not allocated or attached */ 1411 - goto out_free_id; 1412 - return 0; 1413 - 1414 - out_free_id: 1415 - kfree(*id); 1416 1407 return error; 1417 1408 } 1418 1409 ··· 1418 1425 ret = nvme_identify_ns(ctrl, info->nsid, &id); 1419 1426 if (ret) 1420 1427 return ret; 1428 + 1429 + if (id->ncap == 0) { 1430 + /* namespace not allocated or attached */ 1431 + info->is_removed = true; 1432 + return -ENODEV; 1433 + } 1434 + 1421 1435 info->anagrpid = id->anagrpid; 1422 1436 info->is_shared = id->nmic & NVME_NS_NMIC_SHARED; 1423 1437 info->is_readonly = id->nsattr & NVME_NS_ATTR_RO; ··· 3104 3104 * Rather than blindly freezing the IO queues for this effect that 3105 3105 * doesn't even apply to IO, mask it off. 3106 3106 */ 3107 - log->acs[nvme_admin_security_recv] &= ~NVME_CMD_EFFECTS_CSE_MASK; 3107 + log->acs[nvme_admin_security_recv] &= cpu_to_le32(~NVME_CMD_EFFECTS_CSE_MASK); 3108 3108 3109 3109 log->iocs[nvme_cmd_write] |= cpu_to_le32(NVME_CMD_EFFECTS_LBCC); 3110 3110 log->iocs[nvme_cmd_write_zeroes] |= cpu_to_le32(NVME_CMD_EFFECTS_LBCC); ··· 4429 4429 { 4430 4430 struct nvme_ns_info info = { .nsid = nsid }; 4431 4431 struct nvme_ns *ns; 4432 + int ret; 4432 4433 4433 4434 if (nvme_identify_ns_descs(ctrl, &info)) 4434 4435 return; ··· 4446 4445 * set up a namespace. If not fall back to the legacy version. 4447 4446 */ 4448 4447 if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) || 4449 - (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) { 4450 - if (nvme_ns_info_from_id_cs_indep(ctrl, &info)) 4451 - return; 4452 - } else { 4453 - if (nvme_ns_info_from_identify(ctrl, &info)) 4454 - return; 4455 - } 4448 + (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) 4449 + ret = nvme_ns_info_from_id_cs_indep(ctrl, &info); 4450 + else 4451 + ret = nvme_ns_info_from_identify(ctrl, &info); 4452 + 4453 + if (info.is_removed) 4454 + nvme_ns_remove_by_nsid(ctrl, nsid); 4456 4455 4457 4456 /* 4458 4457 * Ignore the namespace if it is not ready. We will get an AEN once it 4459 4458 * becomes ready and restart the scan. 4460 4459 */ 4461 - if (!info.is_ready) 4460 + if (ret || !info.is_ready) 4462 4461 return; 4463 4462 4464 4463 ns = nvme_find_get_ns(ctrl, nsid);
+2 -1
drivers/nvme/host/fabrics.h
··· 189 189 190 190 static inline char *nvmf_ctrl_subsysnqn(struct nvme_ctrl *ctrl) 191 191 { 192 - if (!ctrl->subsys) 192 + if (!ctrl->subsys || 193 + !strcmp(ctrl->opts->subsysnqn, NVME_DISC_SUBSYS_NAME)) 193 194 return ctrl->opts->subsysnqn; 194 195 return ctrl->subsys->subnqn; 195 196 }
+6
drivers/nvme/host/tcp.c
··· 2492 2492 2493 2493 len = nvmf_get_address(ctrl, buf, size); 2494 2494 2495 + mutex_lock(&queue->queue_lock); 2496 + 2497 + if (!test_bit(NVME_TCP_Q_LIVE, &queue->flags)) 2498 + goto done; 2495 2499 ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src_addr); 2496 2500 if (ret > 0) { 2497 2501 if (len > 0) ··· 2503 2499 len += scnprintf(buf + len, size - len, "%ssrc_addr=%pISc\n", 2504 2500 (len) ? "," : "", &src_addr); 2505 2501 } 2502 + done: 2503 + mutex_unlock(&queue->queue_lock); 2506 2504 2507 2505 return len; 2508 2506 }
+2 -2
include/linux/blk-mq.h
··· 473 473 474 474 /** 475 475 * struct blk_mq_tag_set - tag set that can be shared between request queues 476 + * @ops: Pointers to functions that implement block driver behavior. 476 477 * @map: One or more ctx -> hctx mappings. One map exists for each 477 478 * hardware queue type (enum hctx_type) that the driver wishes 478 479 * to support. There are no restrictions on maps being of the ··· 481 480 * types. 482 481 * @nr_maps: Number of elements in the @map array. A number in the range 483 482 * [1, HCTX_MAX_TYPES]. 484 - * @ops: Pointers to functions that implement block driver behavior. 485 483 * @nr_hw_queues: Number of hardware queues supported by the block driver that 486 484 * owns this data structure. 487 485 * @queue_depth: Number of tags per hardware queue, reserved tags included. ··· 505 505 * (BLK_MQ_F_BLOCKING). 506 506 */ 507 507 struct blk_mq_tag_set { 508 + const struct blk_mq_ops *ops; 508 509 struct blk_mq_queue_map map[HCTX_MAX_TYPES]; 509 510 unsigned int nr_maps; 510 - const struct blk_mq_ops *ops; 511 511 unsigned int nr_hw_queues; 512 512 unsigned int queue_depth; 513 513 unsigned int reserved_tags;
+1 -6
include/linux/blkdev.h
··· 1283 1283 1284 1284 static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) 1285 1285 { 1286 - struct request_queue *q = bdev_get_queue(bdev); 1287 - 1288 - if (q) 1289 - return blk_queue_zoned_model(q); 1290 - 1291 - return BLK_ZONED_NONE; 1286 + return blk_queue_zoned_model(bdev_get_queue(bdev)); 1292 1287 } 1293 1288 1294 1289 static inline bool bdev_is_zoned(struct block_device *bdev)
+1
include/uapi/linux/sed-opal.h
··· 144 144 #define OPAL_FL_LOCKED 0x00000008 145 145 #define OPAL_FL_MBR_ENABLED 0x00000010 146 146 #define OPAL_FL_MBR_DONE 0x00000020 147 + #define OPAL_FL_SUM_SUPPORTED 0x00000040 147 148 148 149 struct opal_status { 149 150 __u32 flags;
+1 -5
kernel/trace/blktrace.c
··· 729 729 **/ 730 730 int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) 731 731 { 732 - struct request_queue *q; 732 + struct request_queue *q = bdev_get_queue(bdev); 733 733 int ret, start = 0; 734 734 char b[BDEVNAME_SIZE]; 735 - 736 - q = bdev_get_queue(bdev); 737 - if (!q) 738 - return -ENXIO; 739 735 740 736 mutex_lock(&q->debugfs_mutex); 741 737