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.

nvme: clean up error handling in nvme_init_ns_head

Use a common label for putting the nshead if needed and only convert
nvme status codes for the one case where it actually is needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
6623c5b3 3add1d93

+13 -13
+13 -13
drivers/nvme/host/core.c
··· 3501 3501 int ret = 0; 3502 3502 3503 3503 ret = nvme_report_ns_ids(ctrl, nsid, id, &ids); 3504 - if (ret) 3505 - goto out; 3504 + if (ret) { 3505 + if (ret < 0) 3506 + return ret; 3507 + return blk_status_to_errno(nvme_error_status(ret)); 3508 + } 3506 3509 3507 3510 mutex_lock(&ctrl->subsys->lock); 3508 3511 head = nvme_find_ns_head(ctrl->subsys, nsid); ··· 3517 3514 } 3518 3515 head->shared = is_shared; 3519 3516 } else { 3517 + ret = -EINVAL; 3520 3518 if (!is_shared || !head->shared) { 3521 3519 dev_err(ctrl->device, 3522 - "Duplicate unshared namespace %d\n", 3523 - nsid); 3524 - ret = -EINVAL; 3525 - nvme_put_ns_head(head); 3526 - goto out_unlock; 3520 + "Duplicate unshared namespace %d\n", nsid); 3521 + goto out_put_ns_head; 3527 3522 } 3528 3523 if (!nvme_ns_ids_equal(&head->ids, &ids)) { 3529 3524 dev_err(ctrl->device, 3530 3525 "IDs don't match for shared namespace %d\n", 3531 3526 nsid); 3532 - ret = -EINVAL; 3533 - nvme_put_ns_head(head); 3534 - goto out_unlock; 3527 + goto out_put_ns_head; 3535 3528 } 3536 3529 } 3537 3530 3538 3531 list_add_tail(&ns->siblings, &head->list); 3539 3532 ns->head = head; 3533 + mutex_unlock(&ctrl->subsys->lock); 3534 + return 0; 3540 3535 3536 + out_put_ns_head: 3537 + nvme_put_ns_head(head); 3541 3538 out_unlock: 3542 3539 mutex_unlock(&ctrl->subsys->lock); 3543 - out: 3544 - if (ret > 0) 3545 - ret = blk_status_to_errno(nvme_error_status(ret)); 3546 3540 return ret; 3547 3541 } 3548 3542