[PATCH 1/3] nvme: cleanup __nvme_check_ids

Kanchan Joshi joshiiitr at gmail.com
Thu Feb 24 05:31:30 PST 2022


On Thu, Feb 24, 2022 at 4:33 PM Christoph Hellwig <hch at lst.de> wrote:
>
> Pass the actual nvme_ns_ids used for the comparism instead of the

s/comparism/comparison

> ns_head that isn't needed and use a more descriptive function name.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>  drivers/nvme/host/core.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 9cffc4770e737..076a03b801b7e 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3673,16 +3673,15 @@ static struct nvme_ns_head *nvme_find_ns_head(struct nvme_subsystem *subsys,
>         return NULL;
>  }
>
> -static int __nvme_check_ids(struct nvme_subsystem *subsys,
> -               struct nvme_ns_head *new)
> +static int nvme_subsys_check_duplicate_ids(struct nvme_subsystem *subsys,
> +               struct nvme_ns_ids *ids)
>  {
>         struct nvme_ns_head *h;
>
>         lockdep_assert_held(&subsys->lock);
>
>         list_for_each_entry(h, &subsys->nsheads, entry) {
> -               if (nvme_ns_ids_valid(&new->ids) &&
> -                   nvme_ns_ids_equal(&new->ids, &h->ids))
> +               if (nvme_ns_ids_valid(ids) && nvme_ns_ids_equal(ids, &h->ids))

Why the first check is inside the loop? Seems we can move this outside
of the loop.



More information about the Linux-nvme mailing list