Skip to content

Commit b2dc748

Browse files
author
Christoph Hellwig
committed
nvme: move nvme_validate_ns
Move nvme_validate_ns just above its only remaining caller. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
1 parent 8b7c0ff commit b2dc748

1 file changed

Lines changed: 37 additions & 37 deletions

File tree

drivers/nvme/host/core.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,43 +2156,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
21562156
return ret;
21572157
}
21582158

2159-
static int nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
2160-
{
2161-
struct nvme_ctrl *ctrl = ns->ctrl;
2162-
struct nvme_id_ns *id;
2163-
int ret = 0;
2164-
2165-
if (test_bit(NVME_NS_DEAD, &ns->flags)) {
2166-
set_capacity(ns->disk, 0);
2167-
return -ENODEV;
2168-
}
2169-
2170-
ret = nvme_identify_ns(ctrl, ns->head->ns_id, ids, &id);
2171-
if (ret)
2172-
goto out;
2173-
2174-
if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
2175-
dev_err(ctrl->device,
2176-
"identifiers changed for nsid %d\n", ns->head->ns_id);
2177-
ret = -ENODEV;
2178-
goto free_id;
2179-
}
2180-
2181-
ret = nvme_update_ns_info(ns, id);
2182-
free_id:
2183-
kfree(id);
2184-
out:
2185-
/*
2186-
* Only fail the function if we got a fatal error back from the
2187-
* device, otherwise ignore the error and just move on.
2188-
*/
2189-
if (ret == -ENOMEM || (ret > 0 && !(ret & NVME_SC_DNR)))
2190-
ret = 0;
2191-
else if (ret > 0)
2192-
ret = blk_status_to_errno(nvme_error_status(ret));
2193-
return ret;
2194-
}
2195-
21962159
static char nvme_pr_type(enum pr_type type)
21972160
{
21982161
switch (type) {
@@ -3973,6 +3936,43 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
39733936
}
39743937
}
39753938

3939+
static int nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids)
3940+
{
3941+
struct nvme_ctrl *ctrl = ns->ctrl;
3942+
struct nvme_id_ns *id;
3943+
int ret = 0;
3944+
3945+
if (test_bit(NVME_NS_DEAD, &ns->flags)) {
3946+
set_capacity(ns->disk, 0);
3947+
return -ENODEV;
3948+
}
3949+
3950+
ret = nvme_identify_ns(ctrl, ns->head->ns_id, ids, &id);
3951+
if (ret)
3952+
goto out;
3953+
3954+
if (!nvme_ns_ids_equal(&ns->head->ids, ids)) {
3955+
dev_err(ctrl->device,
3956+
"identifiers changed for nsid %d\n", ns->head->ns_id);
3957+
ret = -ENODEV;
3958+
goto free_id;
3959+
}
3960+
3961+
ret = nvme_update_ns_info(ns, id);
3962+
free_id:
3963+
kfree(id);
3964+
out:
3965+
/*
3966+
* Only fail the function if we got a fatal error back from the
3967+
* device, otherwise ignore the error and just move on.
3968+
*/
3969+
if (ret == -ENOMEM || (ret > 0 && !(ret & NVME_SC_DNR)))
3970+
ret = 0;
3971+
else if (ret > 0)
3972+
ret = blk_status_to_errno(nvme_error_status(ret));
3973+
return ret;
3974+
}
3975+
39763976
static void nvme_validate_or_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
39773977
{
39783978
struct nvme_ns_ids ids = { };

0 commit comments

Comments
 (0)