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.10-20240523' of git://git.kernel.dk/linux

Pull more block updates from Jens Axboe:
"Followup block updates, mostly due to NVMe being a bit late to the
party. But nothing major in there, so not a big deal.

In detail, this contains:

- NVMe pull request via Keith:
- Fabrics connection retries (Daniel, Hannes)
- Fabrics logging enhancements (Tokunori)
- RDMA delete optimization (Sagi)

- ublk DMA alignment fix (me)

- null_blk sparse warning fixes (Bart)

- Discard support for brd (Keith)

- blk-cgroup list corruption fixes (Ming)

- blk-cgroup stat propagation fix (Waiman)

- Regression fix for plugging stall with md (Yu)

- Misc fixes or cleanups (David, Jeff, Justin)"

* tag 'block-6.10-20240523' of git://git.kernel.dk/linux: (24 commits)
null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'
blk-throttle: remove unused struct 'avg_latency_bucket'
block: fix lost bio for plug enabled bio based device
block: t10-pi: add MODULE_DESCRIPTION()
blk-mq: add helper for checking if one CPU is mapped to specified hctx
blk-cgroup: Properly propagate the iostat update up the hierarchy
blk-cgroup: fix list corruption from reorder of WRITE ->lqueued
blk-cgroup: fix list corruption from resetting io stat
cdrom: rearrange last_media_change check to avoid unintentional overflow
nbd: Fix signal handling
nbd: Remove a local variable from nbd_send_cmd()
nbd: Improve the documentation of the locking assumptions
nbd: Remove superfluous casts
nbd: Use NULL to represent a pointer
brd: implement discard support
null_blk: Fix two sparse warnings
ublk_drv: set DMA alignment mask to 3
nvme-rdma, nvme-tcp: include max reconnects for reconnect logging
nvmet-rdma: Avoid o(n^2) loop in delete_ctrl
nvme: do not retry authentication failures
...

+314 -186
+63 -24
block/blk-cgroup.c
··· 322 322 blkg->q = disk->queue; 323 323 INIT_LIST_HEAD(&blkg->q_node); 324 324 blkg->blkcg = blkcg; 325 + blkg->iostat.blkg = blkg; 325 326 #ifdef CONFIG_BLK_CGROUP_PUNT_BIO 326 327 spin_lock_init(&blkg->async_bio_lock); 327 328 bio_list_init(&blkg->async_bios); ··· 619 618 spin_unlock_irq(&q->queue_lock); 620 619 } 621 620 621 + static void blkg_iostat_set(struct blkg_iostat *dst, struct blkg_iostat *src) 622 + { 623 + int i; 624 + 625 + for (i = 0; i < BLKG_IOSTAT_NR; i++) { 626 + dst->bytes[i] = src->bytes[i]; 627 + dst->ios[i] = src->ios[i]; 628 + } 629 + } 630 + 631 + static void __blkg_clear_stat(struct blkg_iostat_set *bis) 632 + { 633 + struct blkg_iostat cur = {0}; 634 + unsigned long flags; 635 + 636 + flags = u64_stats_update_begin_irqsave(&bis->sync); 637 + blkg_iostat_set(&bis->cur, &cur); 638 + blkg_iostat_set(&bis->last, &cur); 639 + u64_stats_update_end_irqrestore(&bis->sync, flags); 640 + } 641 + 642 + static void blkg_clear_stat(struct blkcg_gq *blkg) 643 + { 644 + int cpu; 645 + 646 + for_each_possible_cpu(cpu) { 647 + struct blkg_iostat_set *s = per_cpu_ptr(blkg->iostat_cpu, cpu); 648 + 649 + __blkg_clear_stat(s); 650 + } 651 + __blkg_clear_stat(&blkg->iostat); 652 + } 653 + 622 654 static int blkcg_reset_stats(struct cgroup_subsys_state *css, 623 655 struct cftype *cftype, u64 val) 624 656 { 625 657 struct blkcg *blkcg = css_to_blkcg(css); 626 658 struct blkcg_gq *blkg; 627 - int i, cpu; 659 + int i; 628 660 629 661 mutex_lock(&blkcg_pol_mutex); 630 662 spin_lock_irq(&blkcg->lock); ··· 668 634 * anyway. If you get hit by a race, retry. 669 635 */ 670 636 hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) { 671 - for_each_possible_cpu(cpu) { 672 - struct blkg_iostat_set *bis = 673 - per_cpu_ptr(blkg->iostat_cpu, cpu); 674 - memset(bis, 0, sizeof(*bis)); 675 - 676 - /* Re-initialize the cleared blkg_iostat_set */ 677 - u64_stats_init(&bis->sync); 678 - bis->blkg = blkg; 679 - } 680 - memset(&blkg->iostat, 0, sizeof(blkg->iostat)); 681 - u64_stats_init(&blkg->iostat.sync); 682 - 637 + blkg_clear_stat(blkg); 683 638 for (i = 0; i < BLKCG_MAX_POLS; i++) { 684 639 struct blkcg_policy *pol = blkcg_policy[i]; 685 640 ··· 971 948 } 972 949 EXPORT_SYMBOL_GPL(blkg_conf_exit); 973 950 974 - static void blkg_iostat_set(struct blkg_iostat *dst, struct blkg_iostat *src) 975 - { 976 - int i; 977 - 978 - for (i = 0; i < BLKG_IOSTAT_NR; i++) { 979 - dst->bytes[i] = src->bytes[i]; 980 - dst->ios[i] = src->ios[i]; 981 - } 982 - } 983 - 984 951 static void blkg_iostat_add(struct blkg_iostat *dst, struct blkg_iostat *src) 985 952 { 986 953 int i; ··· 1036 1023 struct blkg_iostat cur; 1037 1024 unsigned int seq; 1038 1025 1026 + /* 1027 + * Order assignment of `next_bisc` from `bisc->lnode.next` in 1028 + * llist_for_each_entry_safe and clearing `bisc->lqueued` for 1029 + * avoiding to assign `next_bisc` with new next pointer added 1030 + * in blk_cgroup_bio_start() in case of re-ordering. 1031 + * 1032 + * The pair barrier is implied in llist_add() in blk_cgroup_bio_start(). 1033 + */ 1034 + smp_mb(); 1035 + 1039 1036 WRITE_ONCE(bisc->lqueued, false); 1037 + if (bisc == &blkg->iostat) 1038 + goto propagate_up; /* propagate up to parent only */ 1040 1039 1041 1040 /* fetch the current per-cpu values */ 1042 1041 do { ··· 1058 1033 1059 1034 blkcg_iostat_update(blkg, &cur, &bisc->last); 1060 1035 1036 + propagate_up: 1061 1037 /* propagate global delta to parent (unless that's root) */ 1062 - if (parent && parent->parent) 1038 + if (parent && parent->parent) { 1063 1039 blkcg_iostat_update(parent, &blkg->iostat.cur, 1064 1040 &blkg->iostat.last); 1041 + /* 1042 + * Queue parent->iostat to its blkcg's lockless 1043 + * list to propagate up to the grandparent if the 1044 + * iostat hasn't been queued yet. 1045 + */ 1046 + if (!parent->iostat.lqueued) { 1047 + struct llist_head *plhead; 1048 + 1049 + plhead = per_cpu_ptr(parent->blkcg->lhead, cpu); 1050 + llist_add(&parent->iostat.lnode, plhead); 1051 + parent->iostat.lqueued = true; 1052 + } 1053 + } 1065 1054 } 1066 1055 raw_spin_unlock_irqrestore(&blkg_stat_lock, flags); 1067 1056 out:
+7 -6
block/blk-core.c
··· 615 615 616 616 static void __submit_bio(struct bio *bio) 617 617 { 618 + /* If plug is not used, add new plug here to cache nsecs time. */ 619 + struct blk_plug plug; 620 + 618 621 if (unlikely(!blk_crypto_bio_prep(&bio))) 619 622 return; 623 + 624 + blk_start_plug(&plug); 620 625 621 626 if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) { 622 627 blk_mq_submit_bio(bio); ··· 631 626 disk->fops->submit_bio(bio); 632 627 blk_queue_exit(disk->queue); 633 628 } 629 + 630 + blk_finish_plug(&plug); 634 631 } 635 632 636 633 /* ··· 657 650 static void __submit_bio_noacct(struct bio *bio) 658 651 { 659 652 struct bio_list bio_list_on_stack[2]; 660 - struct blk_plug plug; 661 653 662 654 BUG_ON(bio->bi_next); 663 655 664 656 bio_list_init(&bio_list_on_stack[0]); 665 657 current->bio_list = bio_list_on_stack; 666 - blk_start_plug(&plug); 667 658 668 659 do { 669 660 struct request_queue *q = bdev_get_queue(bio->bi_bdev); ··· 695 690 bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]); 696 691 } while ((bio = bio_list_pop(&bio_list_on_stack[0]))); 697 692 698 - blk_finish_plug(&plug); 699 693 current->bio_list = NULL; 700 694 } 701 695 702 696 static void __submit_bio_noacct_mq(struct bio *bio) 703 697 { 704 698 struct bio_list bio_list[2] = { }; 705 - struct blk_plug plug; 706 699 707 700 current->bio_list = bio_list; 708 - blk_start_plug(&plug); 709 701 710 702 do { 711 703 __submit_bio(bio); 712 704 } while ((bio = bio_list_pop(&bio_list[0]))); 713 705 714 - blk_finish_plug(&plug); 715 706 current->bio_list = NULL; 716 707 } 717 708
+18 -2
block/blk-mq.c
··· 3545 3545 return 0; 3546 3546 } 3547 3547 3548 + /* 3549 + * Check if one CPU is mapped to the specified hctx 3550 + * 3551 + * Isolated CPUs have been ruled out from hctx->cpumask, which is supposed 3552 + * to be used for scheduling kworker only. For other usage, please call this 3553 + * helper for checking if one CPU belongs to the specified hctx 3554 + */ 3555 + static bool blk_mq_cpu_mapped_to_hctx(unsigned int cpu, 3556 + const struct blk_mq_hw_ctx *hctx) 3557 + { 3558 + struct blk_mq_hw_ctx *mapped_hctx = blk_mq_map_queue_type(hctx->queue, 3559 + hctx->type, cpu); 3560 + 3561 + return mapped_hctx == hctx; 3562 + } 3563 + 3548 3564 static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node) 3549 3565 { 3550 3566 struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node, 3551 3567 struct blk_mq_hw_ctx, cpuhp_online); 3552 3568 3553 - if (cpumask_test_cpu(cpu, hctx->cpumask)) 3569 + if (blk_mq_cpu_mapped_to_hctx(cpu, hctx)) 3554 3570 clear_bit(BLK_MQ_S_INACTIVE, &hctx->state); 3555 3571 return 0; 3556 3572 } ··· 3584 3568 enum hctx_type type; 3585 3569 3586 3570 hctx = hlist_entry_safe(node, struct blk_mq_hw_ctx, cpuhp_dead); 3587 - if (!cpumask_test_cpu(cpu, hctx->cpumask)) 3571 + if (!blk_mq_cpu_mapped_to_hctx(cpu, hctx)) 3588 3572 return 0; 3589 3573 3590 3574 ctx = __blk_mq_get_ctx(hctx->queue, cpu);
-5
block/blk-throttle.c
··· 39 39 int samples; 40 40 }; 41 41 42 - struct avg_latency_bucket { 43 - unsigned long latency; /* ns / 1024 */ 44 - bool valid; 45 - }; 46 - 47 42 struct throtl_data 48 43 { 49 44 /* service tree for active throtl groups */
+1 -1
block/t10-pi.c
··· 495 495 }; 496 496 EXPORT_SYMBOL_GPL(ext_pi_type3_crc64); 497 497 498 - MODULE_LICENSE("GPL"); 498 + MODULE_DESCRIPTION("T10 Protection Information module"); 499 499 MODULE_LICENSE("GPL");
+26
drivers/block/brd.c
··· 222 222 return err; 223 223 } 224 224 225 + static void brd_do_discard(struct brd_device *brd, sector_t sector, u32 size) 226 + { 227 + sector_t aligned_sector = (sector + PAGE_SECTORS) & ~PAGE_SECTORS; 228 + struct page *page; 229 + 230 + size -= (aligned_sector - sector) * SECTOR_SIZE; 231 + xa_lock(&brd->brd_pages); 232 + while (size >= PAGE_SIZE && aligned_sector < rd_size * 2) { 233 + page = __xa_erase(&brd->brd_pages, aligned_sector >> PAGE_SECTORS_SHIFT); 234 + if (page) 235 + __free_page(page); 236 + aligned_sector += PAGE_SECTORS; 237 + size -= PAGE_SIZE; 238 + } 239 + xa_unlock(&brd->brd_pages); 240 + } 241 + 225 242 static void brd_submit_bio(struct bio *bio) 226 243 { 227 244 struct brd_device *brd = bio->bi_bdev->bd_disk->private_data; 228 245 sector_t sector = bio->bi_iter.bi_sector; 229 246 struct bio_vec bvec; 230 247 struct bvec_iter iter; 248 + 249 + if (unlikely(op_is_discard(bio->bi_opf))) { 250 + brd_do_discard(brd, sector, bio->bi_iter.bi_size); 251 + bio_endio(bio); 252 + return; 253 + } 231 254 232 255 bio_for_each_segment(bvec, bio, iter) { 233 256 unsigned int len = bvec.bv_len; ··· 332 309 * is harmless) 333 310 */ 334 311 .physical_block_size = PAGE_SIZE, 312 + .max_hw_discard_sectors = UINT_MAX, 313 + .max_discard_segments = 1, 314 + .discard_granularity = PAGE_SIZE, 335 315 }; 336 316 337 317 list_for_each_entry(brd, &brd_devices, brd_list)
+22 -19
drivers/block/nbd.c
··· 222 222 struct device_attribute *attr, char *buf) 223 223 { 224 224 struct gendisk *disk = dev_to_disk(dev); 225 - struct nbd_device *nbd = (struct nbd_device *)disk->private_data; 225 + struct nbd_device *nbd = disk->private_data; 226 226 227 227 return sprintf(buf, "%d\n", nbd->pid); 228 228 } ··· 236 236 struct device_attribute *attr, char *buf) 237 237 { 238 238 struct gendisk *disk = dev_to_disk(dev); 239 - struct nbd_device *nbd = (struct nbd_device *)disk->private_data; 239 + struct nbd_device *nbd = disk->private_data; 240 240 241 241 return sprintf(buf, "%s\n", nbd->backend ?: ""); 242 242 } ··· 588 588 return result == -ERESTARTSYS || result == -EINTR; 589 589 } 590 590 591 - /* always call with the tx_lock held */ 591 + /* 592 + * Returns BLK_STS_RESOURCE if the caller should retry after a delay. Returns 593 + * -EAGAIN if the caller should requeue @cmd. Returns -EIO if sending failed. 594 + */ 592 595 static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) 593 596 { 594 597 struct request *req = blk_mq_rq_from_pdu(cmd); ··· 601 598 struct nbd_request request = {.magic = htonl(NBD_REQUEST_MAGIC)}; 602 599 struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)}; 603 600 struct iov_iter from; 604 - unsigned long size = blk_rq_bytes(req); 605 601 struct bio *bio; 606 602 u64 handle; 607 603 u32 type; 608 604 u32 nbd_cmd_flags = 0; 609 605 int sent = nsock->sent, skip = 0; 606 + 607 + lockdep_assert_held(&cmd->lock); 608 + lockdep_assert_held(&nsock->tx_lock); 610 609 611 610 iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request)); 612 611 ··· 649 644 request.type = htonl(type | nbd_cmd_flags); 650 645 if (type != NBD_CMD_FLUSH) { 651 646 request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9); 652 - request.len = htonl(size); 647 + request.len = htonl(blk_rq_bytes(req)); 653 648 } 654 649 handle = nbd_cmd_handle(cmd); 655 650 request.cookie = cpu_to_be64(handle); ··· 674 669 nsock->sent = sent; 675 670 } 676 671 set_bit(NBD_CMD_REQUEUED, &cmd->flags); 677 - return BLK_STS_RESOURCE; 672 + return (__force int)BLK_STS_RESOURCE; 678 673 } 679 674 dev_err_ratelimited(disk_to_dev(nbd->disk), 680 675 "Send control failed (result %d)\n", result); ··· 715 710 nsock->pending = req; 716 711 nsock->sent = sent; 717 712 set_bit(NBD_CMD_REQUEUED, &cmd->flags); 718 - return BLK_STS_RESOURCE; 713 + return (__force int)BLK_STS_RESOURCE; 719 714 } 720 715 dev_err(disk_to_dev(nbd->disk), 721 716 "Send data failed (result %d)\n", ··· 1012 1007 return !test_bit(NBD_RT_DISCONNECTED, &config->runtime_flags); 1013 1008 } 1014 1009 1015 - static int nbd_handle_cmd(struct nbd_cmd *cmd, int index) 1010 + static blk_status_t nbd_handle_cmd(struct nbd_cmd *cmd, int index) 1016 1011 { 1017 1012 struct request *req = blk_mq_rq_from_pdu(cmd); 1018 1013 struct nbd_device *nbd = cmd->nbd; ··· 1020 1015 struct nbd_sock *nsock; 1021 1016 int ret; 1022 1017 1018 + lockdep_assert_held(&cmd->lock); 1019 + 1023 1020 config = nbd_get_config_unlocked(nbd); 1024 1021 if (!config) { 1025 1022 dev_err_ratelimited(disk_to_dev(nbd->disk), 1026 1023 "Socks array is empty\n"); 1027 - return -EINVAL; 1024 + return BLK_STS_IOERR; 1028 1025 } 1029 1026 1030 1027 if (index >= config->num_connections) { 1031 1028 dev_err_ratelimited(disk_to_dev(nbd->disk), 1032 1029 "Attempted send on invalid socket\n"); 1033 1030 nbd_config_put(nbd); 1034 - return -EINVAL; 1031 + return BLK_STS_IOERR; 1035 1032 } 1036 1033 cmd->status = BLK_STS_OK; 1037 1034 again: ··· 1056 1049 */ 1057 1050 sock_shutdown(nbd); 1058 1051 nbd_config_put(nbd); 1059 - return -EIO; 1052 + return BLK_STS_IOERR; 1060 1053 } 1061 1054 goto again; 1062 1055 } ··· 1069 1062 blk_mq_start_request(req); 1070 1063 if (unlikely(nsock->pending && nsock->pending != req)) { 1071 1064 nbd_requeue_cmd(cmd); 1072 - ret = 0; 1065 + ret = BLK_STS_OK; 1073 1066 goto out; 1074 1067 } 1075 1068 /* ··· 1088 1081 "Request send failed, requeueing\n"); 1089 1082 nbd_mark_nsock_dead(nbd, nsock, 1); 1090 1083 nbd_requeue_cmd(cmd); 1091 - ret = 0; 1084 + ret = BLK_STS_OK; 1092 1085 } 1093 1086 out: 1094 1087 mutex_unlock(&nsock->tx_lock); 1095 1088 nbd_config_put(nbd); 1096 - return ret; 1089 + return ret < 0 ? BLK_STS_IOERR : (__force blk_status_t)ret; 1097 1090 } 1098 1091 1099 1092 static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx, 1100 1093 const struct blk_mq_queue_data *bd) 1101 1094 { 1102 1095 struct nbd_cmd *cmd = blk_mq_rq_to_pdu(bd->rq); 1103 - int ret; 1096 + blk_status_t ret; 1104 1097 1105 1098 /* 1106 1099 * Since we look at the bio's to send the request over the network we ··· 1120 1113 * appropriate. 1121 1114 */ 1122 1115 ret = nbd_handle_cmd(cmd, hctx->queue_num); 1123 - if (ret < 0) 1124 - ret = BLK_STS_IOERR; 1125 - else if (!ret) 1126 - ret = BLK_STS_OK; 1127 1116 mutex_unlock(&cmd->lock); 1128 1117 1129 1118 return ret;
+27 -15
drivers/block/null_blk/main.c
··· 413 413 static int nullb_apply_submit_queues(struct nullb_device *dev, 414 414 unsigned int submit_queues) 415 415 { 416 - return nullb_update_nr_hw_queues(dev, submit_queues, dev->poll_queues); 416 + int ret; 417 + 418 + mutex_lock(&lock); 419 + ret = nullb_update_nr_hw_queues(dev, submit_queues, dev->poll_queues); 420 + mutex_unlock(&lock); 421 + 422 + return ret; 417 423 } 418 424 419 425 static int nullb_apply_poll_queues(struct nullb_device *dev, 420 426 unsigned int poll_queues) 421 427 { 422 - return nullb_update_nr_hw_queues(dev, dev->submit_queues, poll_queues); 428 + int ret; 429 + 430 + mutex_lock(&lock); 431 + ret = nullb_update_nr_hw_queues(dev, dev->submit_queues, poll_queues); 432 + mutex_unlock(&lock); 433 + 434 + return ret; 423 435 } 424 436 425 437 NULLB_DEVICE_ATTR(size, ulong, NULL); ··· 480 468 if (ret < 0) 481 469 return ret; 482 470 471 + ret = count; 472 + mutex_lock(&lock); 483 473 if (!dev->power && newp) { 484 474 if (test_and_set_bit(NULLB_DEV_FL_UP, &dev->flags)) 485 - return count; 475 + goto out; 476 + 486 477 ret = null_add_dev(dev); 487 478 if (ret) { 488 479 clear_bit(NULLB_DEV_FL_UP, &dev->flags); 489 - return ret; 480 + goto out; 490 481 } 491 482 492 483 set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags); 493 484 dev->power = newp; 494 485 } else if (dev->power && !newp) { 495 486 if (test_and_clear_bit(NULLB_DEV_FL_UP, &dev->flags)) { 496 - mutex_lock(&lock); 497 487 dev->power = newp; 498 488 null_del_dev(dev->nullb); 499 - mutex_unlock(&lock); 500 489 } 501 490 clear_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags); 502 491 } 503 492 504 - return count; 493 + out: 494 + mutex_unlock(&lock); 495 + return ret; 505 496 } 506 497 507 498 CONFIGFS_ATTR(nullb_device_, power); ··· 1233 1218 return err; 1234 1219 } 1235 1220 1236 - static int null_handle_rq(struct nullb_cmd *cmd) 1221 + static blk_status_t null_handle_rq(struct nullb_cmd *cmd) 1237 1222 { 1238 1223 struct request *rq = blk_mq_rq_from_pdu(cmd); 1239 1224 struct nullb *nullb = cmd->nq->dev->nullb; ··· 1947 1932 nullb->q->queuedata = nullb; 1948 1933 blk_queue_flag_set(QUEUE_FLAG_NONROT, nullb->q); 1949 1934 1950 - mutex_lock(&lock); 1951 1935 rv = ida_alloc(&nullb_indexes, GFP_KERNEL); 1952 - if (rv < 0) { 1953 - mutex_unlock(&lock); 1936 + if (rv < 0) 1954 1937 goto out_cleanup_disk; 1955 - } 1938 + 1956 1939 nullb->index = rv; 1957 1940 dev->index = rv; 1958 - mutex_unlock(&lock); 1959 1941 1960 1942 if (config_item_name(&dev->group.cg_item)) { 1961 1943 /* Use configfs dir name as the device name */ ··· 1981 1969 if (rv) 1982 1970 goto out_ida_free; 1983 1971 1984 - mutex_lock(&lock); 1985 1972 list_add_tail(&nullb->list, &nullb_list); 1986 - mutex_unlock(&lock); 1987 1973 1988 1974 pr_info("disk %s created\n", nullb->disk_name); 1989 1975 ··· 2030 2020 if (!dev) 2031 2021 return -ENOMEM; 2032 2022 2023 + mutex_lock(&lock); 2033 2024 ret = null_add_dev(dev); 2025 + mutex_unlock(&lock); 2034 2026 if (ret) { 2035 2027 null_free_dev(dev); 2036 2028 return ret;
+6 -1
drivers/block/null_blk/trace.h
··· 36 36 TP_ARGS(cmd, zone_no, zone_cond), 37 37 TP_STRUCT__entry( 38 38 __array(char, disk, DISK_NAME_LEN) 39 - __field(enum req_op, op) 39 + /* 40 + * __field() uses is_signed_type(). is_signed_type() does not 41 + * support bitwise types. Use __field_struct() instead because 42 + * it does not use is_signed_type(). 43 + */ 44 + __field_struct(enum req_op, op) 40 45 __field(unsigned int, zone_no) 41 46 __field(unsigned int, zone_cond) 42 47 ),
+1
drivers/block/ublk_drv.c
··· 2178 2178 .virt_boundary_mask = p->virt_boundary_mask, 2179 2179 .max_segments = USHRT_MAX, 2180 2180 .max_segment_size = UINT_MAX, 2181 + .dma_alignment = 3, 2181 2182 }; 2182 2183 struct gendisk *disk; 2183 2184 int ret = -EINVAL;
+1 -1
drivers/cdrom/cdrom.c
··· 2358 2358 return -EFAULT; 2359 2359 2360 2360 tmp_info.media_flags = 0; 2361 - if (tmp_info.last_media_change - cdi->last_media_change_ms < 0) 2361 + if (cdi->last_media_change_ms > tmp_info.last_media_change) 2362 2362 tmp_info.media_flags |= MEDIA_CHANGED_FLAG; 2363 2363 2364 2364 tmp_info.last_media_change = cdi->last_media_change_ms;
+3 -3
drivers/nvme/host/auth.c
··· 730 730 NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE); 731 731 if (ret) { 732 732 chap->status = ret; 733 - chap->error = -ECONNREFUSED; 733 + chap->error = -EKEYREJECTED; 734 734 return; 735 735 } 736 736 ··· 797 797 NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1); 798 798 if (ret) { 799 799 chap->status = ret; 800 - chap->error = -ECONNREFUSED; 800 + chap->error = -EKEYREJECTED; 801 801 return; 802 802 } 803 803 ··· 818 818 ret = nvme_auth_process_dhchap_success1(ctrl, chap); 819 819 if (ret) { 820 820 /* Controller authentication failed */ 821 - chap->error = -ECONNREFUSED; 821 + chap->error = -EKEYREJECTED; 822 822 goto fail2; 823 823 } 824 824
+3 -3
drivers/nvme/host/core.c
··· 383 383 if (likely(nvme_req(req)->status == 0)) 384 384 return COMPLETE; 385 385 386 - if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED) 387 - return AUTHENTICATE; 388 - 389 386 if (blk_noretry_request(req) || 390 387 (nvme_req(req)->status & NVME_SC_DNR) || 391 388 nvme_req(req)->retries >= nvme_max_retries) 392 389 return COMPLETE; 390 + 391 + if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED) 392 + return AUTHENTICATE; 393 393 394 394 if (req->cmd_flags & REQ_NVME_MPATH) { 395 395 if (nvme_is_path_error(nvme_req(req)->status) ||
+32 -19
drivers/nvme/host/fabrics.c
··· 428 428 * fabrics-protocol connection of the NVMe Admin queue between the 429 429 * host system device and the allocated NVMe controller on the 430 430 * target system via a NVMe Fabrics "Connect" command. 431 - * 432 - * Return: 433 - * 0: success 434 - * > 0: NVMe error status code 435 - * < 0: Linux errno error code 436 - * 437 431 */ 438 432 int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) 439 433 { ··· 461 467 if (result & NVME_CONNECT_AUTHREQ_ASCR) { 462 468 dev_warn(ctrl->device, 463 469 "qid 0: secure concatenation is not supported\n"); 464 - ret = NVME_SC_AUTH_REQUIRED; 470 + ret = -EOPNOTSUPP; 465 471 goto out_free_data; 466 472 } 467 473 /* Authentication required */ ··· 469 475 if (ret) { 470 476 dev_warn(ctrl->device, 471 477 "qid 0: authentication setup failed\n"); 472 - ret = NVME_SC_AUTH_REQUIRED; 473 478 goto out_free_data; 474 479 } 475 480 ret = nvme_auth_wait(ctrl, 0); 476 - if (ret) 481 + if (ret) { 477 482 dev_warn(ctrl->device, 478 - "qid 0: authentication failed\n"); 479 - else 483 + "qid 0: authentication failed, error %d\n", 484 + ret); 485 + } else 480 486 dev_info(ctrl->device, 481 487 "qid 0: authenticated\n"); 482 488 } ··· 536 542 if (result & NVME_CONNECT_AUTHREQ_ASCR) { 537 543 dev_warn(ctrl->device, 538 544 "qid 0: secure concatenation is not supported\n"); 539 - ret = NVME_SC_AUTH_REQUIRED; 545 + ret = -EOPNOTSUPP; 540 546 goto out_free_data; 541 547 } 542 548 /* Authentication required */ ··· 544 550 if (ret) { 545 551 dev_warn(ctrl->device, 546 552 "qid %d: authentication setup failed\n", qid); 547 - ret = NVME_SC_AUTH_REQUIRED; 548 - } else { 549 - ret = nvme_auth_wait(ctrl, qid); 550 - if (ret) 551 - dev_warn(ctrl->device, 552 - "qid %u: authentication failed\n", qid); 553 + goto out_free_data; 554 + } 555 + ret = nvme_auth_wait(ctrl, qid); 556 + if (ret) { 557 + dev_warn(ctrl->device, 558 + "qid %u: authentication failed, error %d\n", 559 + qid, ret); 553 560 } 554 561 } 555 562 out_free_data: ··· 559 564 } 560 565 EXPORT_SYMBOL_GPL(nvmf_connect_io_queue); 561 566 562 - bool nvmf_should_reconnect(struct nvme_ctrl *ctrl) 567 + /* 568 + * Evaluate the status information returned by the transport in order to decided 569 + * if a reconnect attempt should be scheduled. 570 + * 571 + * Do not retry when: 572 + * 573 + * - the DNR bit is set and the specification states no further connect 574 + * attempts with the same set of paramenters should be attempted. 575 + * 576 + * - when the authentication attempt fails, because the key was invalid. 577 + * This error code is set on the host side. 578 + */ 579 + bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status) 563 580 { 581 + if (status > 0 && (status & NVME_SC_DNR)) 582 + return false; 583 + 584 + if (status == -EKEYREJECTED) 585 + return false; 586 + 564 587 if (ctrl->opts->max_reconnects == -1 || 565 588 ctrl->nr_reconnects < ctrl->opts->max_reconnects) 566 589 return true;
+1 -1
drivers/nvme/host/fabrics.h
··· 223 223 void nvmf_unregister_transport(struct nvmf_transport_ops *ops); 224 224 void nvmf_free_options(struct nvmf_ctrl_options *opts); 225 225 int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); 226 - bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); 226 + bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status); 227 227 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, 228 228 struct nvmf_ctrl_options *opts); 229 229 void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,
+1 -3
drivers/nvme/host/fc.c
··· 3310 3310 dev_info(ctrl->ctrl.device, 3311 3311 "NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n", 3312 3312 ctrl->cnum, status); 3313 - if (status > 0 && (status & NVME_SC_DNR)) 3314 - recon = false; 3315 3313 } else if (time_after_eq(jiffies, rport->dev_loss_end)) 3316 3314 recon = false; 3317 3315 3318 - if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { 3316 + if (recon && nvmf_should_reconnect(&ctrl->ctrl, status)) { 3319 3317 if (portptr->port_state == FC_OBJSTATE_ONLINE) 3320 3318 dev_info(ctrl->ctrl.device, 3321 3319 "NVME-FC{%d}: Reconnect attempt in %ld "
+1 -1
drivers/nvme/host/nvme.h
··· 1148 1148 } 1149 1149 static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid) 1150 1150 { 1151 - return NVME_SC_AUTH_REQUIRED; 1151 + return -EPROTONOSUPPORT; 1152 1152 } 1153 1153 static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {}; 1154 1154 #endif
+14 -9
drivers/nvme/host/rdma.c
··· 982 982 kfree(ctrl); 983 983 } 984 984 985 - static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) 985 + static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl, 986 + int status) 986 987 { 987 988 enum nvme_ctrl_state state = nvme_ctrl_state(&ctrl->ctrl); 988 989 ··· 993 992 return; 994 993 } 995 994 996 - if (nvmf_should_reconnect(&ctrl->ctrl)) { 995 + if (nvmf_should_reconnect(&ctrl->ctrl, status)) { 997 996 dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", 998 997 ctrl->ctrl.opts->reconnect_delay); 999 998 queue_delayed_work(nvme_wq, &ctrl->reconnect_work, ··· 1105 1104 { 1106 1105 struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), 1107 1106 struct nvme_rdma_ctrl, reconnect_work); 1107 + int ret; 1108 1108 1109 1109 ++ctrl->ctrl.nr_reconnects; 1110 1110 1111 - if (nvme_rdma_setup_ctrl(ctrl, false)) 1111 + ret = nvme_rdma_setup_ctrl(ctrl, false); 1112 + if (ret) 1112 1113 goto requeue; 1113 1114 1114 1115 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", ··· 1121 1118 return; 1122 1119 1123 1120 requeue: 1124 - dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", 1125 - ctrl->ctrl.nr_reconnects); 1126 - nvme_rdma_reconnect_or_remove(ctrl); 1121 + dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d/%d\n", 1122 + ctrl->ctrl.nr_reconnects, ctrl->ctrl.opts->max_reconnects); 1123 + nvme_rdma_reconnect_or_remove(ctrl, ret); 1127 1124 } 1128 1125 1129 1126 static void nvme_rdma_error_recovery_work(struct work_struct *work) ··· 1148 1145 return; 1149 1146 } 1150 1147 1151 - nvme_rdma_reconnect_or_remove(ctrl); 1148 + nvme_rdma_reconnect_or_remove(ctrl, 0); 1152 1149 } 1153 1150 1154 1151 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) ··· 2172 2169 { 2173 2170 struct nvme_rdma_ctrl *ctrl = 2174 2171 container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); 2172 + int ret; 2175 2173 2176 2174 nvme_stop_ctrl(&ctrl->ctrl); 2177 2175 nvme_rdma_shutdown_ctrl(ctrl, false); ··· 2183 2179 return; 2184 2180 } 2185 2181 2186 - if (nvme_rdma_setup_ctrl(ctrl, false)) 2182 + ret = nvme_rdma_setup_ctrl(ctrl, false); 2183 + if (ret) 2187 2184 goto out_fail; 2188 2185 2189 2186 return; 2190 2187 2191 2188 out_fail: 2192 2189 ++ctrl->ctrl.nr_reconnects; 2193 - nvme_rdma_reconnect_or_remove(ctrl); 2190 + nvme_rdma_reconnect_or_remove(ctrl, ret); 2194 2191 } 2195 2192 2196 2193 static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = {
+18 -12
drivers/nvme/host/tcp.c
··· 2161 2161 nvme_tcp_destroy_io_queues(ctrl, remove); 2162 2162 } 2163 2163 2164 - static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl) 2164 + static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, 2165 + int status) 2165 2166 { 2166 2167 enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); 2167 2168 ··· 2172 2171 return; 2173 2172 } 2174 2173 2175 - if (nvmf_should_reconnect(ctrl)) { 2174 + if (nvmf_should_reconnect(ctrl, status)) { 2176 2175 dev_info(ctrl->device, "Reconnecting in %d seconds...\n", 2177 2176 ctrl->opts->reconnect_delay); 2178 2177 queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, 2179 2178 ctrl->opts->reconnect_delay * HZ); 2180 2179 } else { 2181 - dev_info(ctrl->device, "Removing controller...\n"); 2180 + dev_info(ctrl->device, "Removing controller (%d)...\n", 2181 + status); 2182 2182 nvme_delete_ctrl(ctrl); 2183 2183 } 2184 2184 } ··· 2260 2258 struct nvme_tcp_ctrl *tcp_ctrl = container_of(to_delayed_work(work), 2261 2259 struct nvme_tcp_ctrl, connect_work); 2262 2260 struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; 2261 + int ret; 2263 2262 2264 2263 ++ctrl->nr_reconnects; 2265 2264 2266 - if (nvme_tcp_setup_ctrl(ctrl, false)) 2265 + ret = nvme_tcp_setup_ctrl(ctrl, false); 2266 + if (ret) 2267 2267 goto requeue; 2268 2268 2269 - dev_info(ctrl->device, "Successfully reconnected (%d attempt)\n", 2270 - ctrl->nr_reconnects); 2269 + dev_info(ctrl->device, "Successfully reconnected (attempt %d/%d)\n", 2270 + ctrl->nr_reconnects, ctrl->opts->max_reconnects); 2271 2271 2272 2272 ctrl->nr_reconnects = 0; 2273 2273 2274 2274 return; 2275 2275 2276 2276 requeue: 2277 - dev_info(ctrl->device, "Failed reconnect attempt %d\n", 2278 - ctrl->nr_reconnects); 2279 - nvme_tcp_reconnect_or_remove(ctrl); 2277 + dev_info(ctrl->device, "Failed reconnect attempt %d/%d\n", 2278 + ctrl->nr_reconnects, ctrl->opts->max_reconnects); 2279 + nvme_tcp_reconnect_or_remove(ctrl, ret); 2280 2280 } 2281 2281 2282 2282 static void nvme_tcp_error_recovery_work(struct work_struct *work) ··· 2305 2301 return; 2306 2302 } 2307 2303 2308 - nvme_tcp_reconnect_or_remove(ctrl); 2304 + nvme_tcp_reconnect_or_remove(ctrl, 0); 2309 2305 } 2310 2306 2311 2307 static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) ··· 2325 2321 { 2326 2322 struct nvme_ctrl *ctrl = 2327 2323 container_of(work, struct nvme_ctrl, reset_work); 2324 + int ret; 2328 2325 2329 2326 nvme_stop_ctrl(ctrl); 2330 2327 nvme_tcp_teardown_ctrl(ctrl, false); ··· 2339 2334 return; 2340 2335 } 2341 2336 2342 - if (nvme_tcp_setup_ctrl(ctrl, false)) 2337 + ret = nvme_tcp_setup_ctrl(ctrl, false); 2338 + if (ret) 2343 2339 goto out_fail; 2344 2340 2345 2341 return; 2346 2342 2347 2343 out_fail: 2348 2344 ++ctrl->nr_reconnects; 2349 - nvme_tcp_reconnect_or_remove(ctrl); 2345 + nvme_tcp_reconnect_or_remove(ctrl, ret); 2350 2346 } 2351 2347 2352 2348 static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl)
+10 -12
drivers/nvme/target/auth.c
··· 44 44 dhchap_secret = kstrdup(secret, GFP_KERNEL); 45 45 if (!dhchap_secret) 46 46 return -ENOMEM; 47 + down_write(&nvmet_config_sem); 47 48 if (set_ctrl) { 48 49 kfree(host->dhchap_ctrl_secret); 49 50 host->dhchap_ctrl_secret = strim(dhchap_secret); ··· 54 53 host->dhchap_secret = strim(dhchap_secret); 55 54 host->dhchap_key_hash = key_hash; 56 55 } 56 + up_write(&nvmet_config_sem); 57 57 return 0; 58 58 } 59 59 ··· 126 124 return ret; 127 125 } 128 126 129 - int nvmet_setup_auth(struct nvmet_ctrl *ctrl) 127 + u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl) 130 128 { 131 129 int ret = 0; 132 130 struct nvmet_host_link *p; 133 131 struct nvmet_host *host = NULL; 134 - const char *hash_name; 135 132 136 133 down_read(&nvmet_config_sem); 137 134 if (nvmet_is_disc_subsys(ctrl->subsys)) ··· 148 147 } 149 148 if (!host) { 150 149 pr_debug("host %s not found\n", ctrl->hostnqn); 151 - ret = -EPERM; 150 + ret = NVME_AUTH_DHCHAP_FAILURE_FAILED; 152 151 goto out_unlock; 153 152 } 154 153 155 154 ret = nvmet_setup_dhgroup(ctrl, host->dhchap_dhgroup_id); 156 - if (ret < 0) 155 + if (ret < 0) { 157 156 pr_warn("Failed to setup DH group"); 157 + ret = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; 158 + goto out_unlock; 159 + } 158 160 159 161 if (!host->dhchap_secret) { 160 162 pr_debug("No authentication provided\n"); ··· 168 164 pr_debug("Re-use existing hash ID %d\n", 169 165 ctrl->shash_id); 170 166 } else { 171 - hash_name = nvme_auth_hmac_name(host->dhchap_hash_id); 172 - if (!hash_name) { 173 - pr_warn("Hash ID %d invalid\n", host->dhchap_hash_id); 174 - ret = -EINVAL; 175 - goto out_unlock; 176 - } 177 167 ctrl->shash_id = host->dhchap_hash_id; 178 168 } 179 169 ··· 176 178 ctrl->host_key = nvme_auth_extract_key(host->dhchap_secret + 10, 177 179 host->dhchap_key_hash); 178 180 if (IS_ERR(ctrl->host_key)) { 179 - ret = PTR_ERR(ctrl->host_key); 181 + ret = NVME_AUTH_DHCHAP_FAILURE_NOT_USABLE; 180 182 ctrl->host_key = NULL; 181 183 goto out_free_hash; 182 184 } ··· 194 196 ctrl->ctrl_key = nvme_auth_extract_key(host->dhchap_ctrl_secret + 10, 195 197 host->dhchap_ctrl_key_hash); 196 198 if (IS_ERR(ctrl->ctrl_key)) { 197 - ret = PTR_ERR(ctrl->ctrl_key); 199 + ret = NVME_AUTH_DHCHAP_FAILURE_NOT_USABLE; 198 200 ctrl->ctrl_key = NULL; 199 201 goto out_free_hash; 200 202 }
+17 -5
drivers/nvme/target/configfs.c
··· 2007 2007 static ssize_t nvmet_host_dhchap_key_show(struct config_item *item, 2008 2008 char *page) 2009 2009 { 2010 - u8 *dhchap_secret = to_host(item)->dhchap_secret; 2010 + u8 *dhchap_secret; 2011 + ssize_t ret; 2011 2012 2013 + down_read(&nvmet_config_sem); 2014 + dhchap_secret = to_host(item)->dhchap_secret; 2012 2015 if (!dhchap_secret) 2013 - return sprintf(page, "\n"); 2014 - return sprintf(page, "%s\n", dhchap_secret); 2016 + ret = sprintf(page, "\n"); 2017 + else 2018 + ret = sprintf(page, "%s\n", dhchap_secret); 2019 + up_read(&nvmet_config_sem); 2020 + return ret; 2015 2021 } 2016 2022 2017 2023 static ssize_t nvmet_host_dhchap_key_store(struct config_item *item, ··· 2041 2035 char *page) 2042 2036 { 2043 2037 u8 *dhchap_secret = to_host(item)->dhchap_ctrl_secret; 2038 + ssize_t ret; 2044 2039 2040 + down_read(&nvmet_config_sem); 2041 + dhchap_secret = to_host(item)->dhchap_ctrl_secret; 2045 2042 if (!dhchap_secret) 2046 - return sprintf(page, "\n"); 2047 - return sprintf(page, "%s\n", dhchap_secret); 2043 + ret = sprintf(page, "\n"); 2044 + else 2045 + ret = sprintf(page, "%s\n", dhchap_secret); 2046 + up_read(&nvmet_config_sem); 2047 + return ret; 2048 2048 } 2049 2049 2050 2050 static ssize_t nvmet_host_dhchap_ctrl_key_store(struct config_item *item,
+25 -24
drivers/nvme/target/fabrics-cmd-auth.c
··· 31 31 sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; 32 32 } 33 33 34 - static u16 nvmet_auth_negotiate(struct nvmet_req *req, void *d) 34 + static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d) 35 35 { 36 36 struct nvmet_ctrl *ctrl = req->sq->ctrl; 37 37 struct nvmf_auth_dhchap_negotiate_data *data = d; ··· 109 109 return 0; 110 110 } 111 111 112 - static u16 nvmet_auth_reply(struct nvmet_req *req, void *d) 112 + static u8 nvmet_auth_reply(struct nvmet_req *req, void *d) 113 113 { 114 114 struct nvmet_ctrl *ctrl = req->sq->ctrl; 115 115 struct nvmf_auth_dhchap_reply_data *data = d; ··· 172 172 return 0; 173 173 } 174 174 175 - static u16 nvmet_auth_failure2(void *d) 175 + static u8 nvmet_auth_failure2(void *d) 176 176 { 177 177 struct nvmf_auth_dhchap_failure_data *data = d; 178 178 ··· 186 186 void *d; 187 187 u32 tl; 188 188 u16 status = 0; 189 + u8 dhchap_status; 189 190 190 191 if (req->cmd->auth_send.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { 191 192 status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; ··· 238 237 if (data->auth_type == NVME_AUTH_COMMON_MESSAGES) { 239 238 if (data->auth_id == NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE) { 240 239 /* Restart negotiation */ 241 - pr_debug("%s: ctrl %d qid %d reset negotiation\n", __func__, 242 - ctrl->cntlid, req->sq->qid); 240 + pr_debug("%s: ctrl %d qid %d reset negotiation\n", 241 + __func__, ctrl->cntlid, req->sq->qid); 243 242 if (!req->sq->qid) { 244 - if (nvmet_setup_auth(ctrl) < 0) { 245 - status = NVME_SC_INTERNAL; 246 - pr_err("ctrl %d qid 0 failed to setup" 247 - "re-authentication", 243 + dhchap_status = nvmet_setup_auth(ctrl); 244 + if (dhchap_status) { 245 + pr_err("ctrl %d qid 0 failed to setup re-authentication\n", 248 246 ctrl->cntlid); 249 - goto done_failure1; 247 + req->sq->dhchap_status = dhchap_status; 248 + req->sq->dhchap_step = 249 + NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; 250 + goto done_kfree; 250 251 } 251 252 } 252 - req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; 253 + req->sq->dhchap_step = 254 + NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; 253 255 } else if (data->auth_id != req->sq->dhchap_step) 254 256 goto done_failure1; 255 257 /* Validate negotiation parameters */ 256 - status = nvmet_auth_negotiate(req, d); 257 - if (status == 0) 258 + dhchap_status = nvmet_auth_negotiate(req, d); 259 + if (dhchap_status == 0) 258 260 req->sq->dhchap_step = 259 261 NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE; 260 262 else { 261 263 req->sq->dhchap_step = 262 264 NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; 263 - req->sq->dhchap_status = status; 264 - status = 0; 265 + req->sq->dhchap_status = dhchap_status; 265 266 } 266 267 goto done_kfree; 267 268 } ··· 287 284 288 285 switch (data->auth_id) { 289 286 case NVME_AUTH_DHCHAP_MESSAGE_REPLY: 290 - status = nvmet_auth_reply(req, d); 291 - if (status == 0) 287 + dhchap_status = nvmet_auth_reply(req, d); 288 + if (dhchap_status == 0) 292 289 req->sq->dhchap_step = 293 290 NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1; 294 291 else { 295 292 req->sq->dhchap_step = 296 293 NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; 297 - req->sq->dhchap_status = status; 298 - status = 0; 294 + req->sq->dhchap_status = dhchap_status; 299 295 } 300 296 goto done_kfree; 301 297 case NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2: ··· 303 301 __func__, ctrl->cntlid, req->sq->qid); 304 302 goto done_kfree; 305 303 case NVME_AUTH_DHCHAP_MESSAGE_FAILURE2: 306 - status = nvmet_auth_failure2(d); 307 - if (status) { 304 + dhchap_status = nvmet_auth_failure2(d); 305 + if (dhchap_status) { 308 306 pr_warn("ctrl %d qid %d: authentication failed (%d)\n", 309 - ctrl->cntlid, req->sq->qid, status); 310 - req->sq->dhchap_status = status; 307 + ctrl->cntlid, req->sq->qid, dhchap_status); 308 + req->sq->dhchap_status = dhchap_status; 311 309 req->sq->authenticated = false; 312 - status = 0; 313 310 } 314 311 goto done_kfree; 315 312 default:
+6 -5
drivers/nvme/target/fabrics-cmd.c
··· 211 211 struct nvmf_connect_data *d; 212 212 struct nvmet_ctrl *ctrl = NULL; 213 213 u16 status; 214 - int ret; 214 + u8 dhchap_status; 215 215 216 216 if (!nvmet_check_transfer_len(req, sizeof(struct nvmf_connect_data))) 217 217 return; ··· 254 254 255 255 uuid_copy(&ctrl->hostid, &d->hostid); 256 256 257 - ret = nvmet_setup_auth(ctrl); 258 - if (ret < 0) { 259 - pr_err("Failed to setup authentication, error %d\n", ret); 257 + dhchap_status = nvmet_setup_auth(ctrl); 258 + if (dhchap_status) { 259 + pr_err("Failed to setup authentication, dhchap status %u\n", 260 + dhchap_status); 260 261 nvmet_ctrl_put(ctrl); 261 - if (ret == -EPERM) 262 + if (dhchap_status == NVME_AUTH_DHCHAP_FAILURE_FAILED) 262 263 status = (NVME_SC_CONNECT_INVALID_HOST | NVME_SC_DNR); 263 264 else 264 265 status = NVME_SC_INTERNAL;
+4 -4
drivers/nvme/target/nvmet.h
··· 113 113 bool authenticated; 114 114 struct delayed_work auth_expired_work; 115 115 u16 dhchap_tid; 116 - u16 dhchap_status; 117 - int dhchap_step; 116 + u8 dhchap_status; 117 + u8 dhchap_step; 118 118 u8 *dhchap_c1; 119 119 u8 *dhchap_c2; 120 120 u32 dhchap_s1; ··· 714 714 int nvmet_auth_set_key(struct nvmet_host *host, const char *secret, 715 715 bool set_ctrl); 716 716 int nvmet_auth_set_host_hash(struct nvmet_host *host, const char *hash); 717 - int nvmet_setup_auth(struct nvmet_ctrl *ctrl); 717 + u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl); 718 718 void nvmet_auth_sq_init(struct nvmet_sq *sq); 719 719 void nvmet_destroy_auth(struct nvmet_ctrl *ctrl); 720 720 void nvmet_auth_sq_free(struct nvmet_sq *sq); ··· 733 733 int nvmet_auth_ctrl_sesskey(struct nvmet_req *req, 734 734 u8 *buf, int buf_size); 735 735 #else 736 - static inline int nvmet_setup_auth(struct nvmet_ctrl *ctrl) 736 + static inline u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl) 737 737 { 738 738 return 0; 739 739 }
+6 -10
drivers/nvme/target/rdma.c
··· 1806 1806 1807 1807 static void nvmet_rdma_delete_ctrl(struct nvmet_ctrl *ctrl) 1808 1808 { 1809 - struct nvmet_rdma_queue *queue; 1809 + struct nvmet_rdma_queue *queue, *n; 1810 1810 1811 - restart: 1812 1811 mutex_lock(&nvmet_rdma_queue_mutex); 1813 - list_for_each_entry(queue, &nvmet_rdma_queue_list, queue_list) { 1814 - if (queue->nvme_sq.ctrl == ctrl) { 1815 - list_del_init(&queue->queue_list); 1816 - mutex_unlock(&nvmet_rdma_queue_mutex); 1817 - 1818 - __nvmet_rdma_queue_disconnect(queue); 1819 - goto restart; 1820 - } 1812 + list_for_each_entry_safe(queue, n, &nvmet_rdma_queue_list, queue_list) { 1813 + if (queue->nvme_sq.ctrl != ctrl) 1814 + continue; 1815 + list_del_init(&queue->queue_list); 1816 + __nvmet_rdma_queue_disconnect(queue); 1821 1817 } 1822 1818 mutex_unlock(&nvmet_rdma_queue_mutex); 1823 1819 }
+1 -1
include/trace/events/nbd.h
··· 72 72 ), 73 73 74 74 TP_fast_assign( 75 - __entry->nbd_request = 0; 75 + __entry->nbd_request = NULL; 76 76 __entry->dev_index = index; 77 77 __entry->request = rq; 78 78 ),