[PATCH 02/20] nvme: fix initialization of the zone bitmaps
Damien Le Moal
Damien.LeMoal at wdc.com
Mon Sep 28 10:16:34 EDT 2020
On 2020/09/28 21:35, Christoph Hellwig wrote:
> The removal of the ->revalidate_disk method broke the initialization of
> the zone bitmaps, as nvme_revalidate_disk now never gets called during
> initialization.
>
> Move the zone related code from nvme_revalidate_disk into a new helper in
> zns.c, and call it from nvme_alloc_ns in addition to nvme_validate_ns to
> ensure the zone bitmaps are initialized during probe.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
> drivers/nvme/host/core.c | 28 +++++-----------------------
> drivers/nvme/host/nvme.h | 1 +
> drivers/nvme/host/zns.c | 11 +++++++++++
> 3 files changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 0a985c601c62c3..400d995f95fe2d 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2202,28 +2202,6 @@ static int _nvme_revalidate_disk(struct gendisk *disk)
> return ret;
> }
>
> -static int nvme_revalidate_disk(struct gendisk *disk)
> -{
> - int ret;
> -
> - ret = _nvme_revalidate_disk(disk);
> - if (ret)
> - return ret;
> -
> -#ifdef CONFIG_BLK_DEV_ZONED
> - if (blk_queue_is_zoned(disk->queue)) {
> - struct nvme_ns *ns = disk->private_data;
> - struct nvme_ctrl *ctrl = ns->ctrl;
> -
> - ret = blk_revalidate_disk_zones(disk, NULL);
> - if (!ret)
> - blk_queue_max_zone_append_sectors(disk->queue,
> - ctrl->max_zone_append);
> - }
> -#endif
> - return ret;
> -}
> -
> static char nvme_pr_type(enum pr_type type)
> {
> switch (type) {
> @@ -3958,6 +3936,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
>
> if (__nvme_revalidate_disk(disk, id))
> goto out_put_disk;
> + if (blk_queue_is_zoned(ns->queue) && nvme_revalidate_zones(ns))
> + goto out_put_disk;
>
> if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
> ret = nvme_nvm_register(ns, disk_name, node);
> @@ -4052,7 +4032,9 @@ static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid)
> return;
> }
>
> - ret = nvme_revalidate_disk(ns->disk);
> + ret = _nvme_revalidate_disk(ns->disk);
> + if (!ret && blk_queue_is_zoned(ns->queue))
> + ret = nvme_revalidate_zones(ns);
> revalidate_disk_size(ns->disk, ret == 0);
> if (ret)
> nvme_ns_remove(ns);
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 1096ef1f6aa2b0..6cbbd1597ae6d7 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -758,6 +758,7 @@ static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
> }
> #endif /* CONFIG_NVME_MULTIPATH */
>
> +int nvme_revalidate_zones(struct nvme_ns *ns);
> #ifdef CONFIG_BLK_DEV_ZONED
> int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns,
> unsigned lbaf);
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 53efecb6789838..672a18fcf3bfe2 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -7,6 +7,17 @@
> #include <linux/vmalloc.h>
> #include "nvme.h"
>
> +int nvme_revalidate_zones(struct nvme_ns *ns)
> +{
> + struct request_queue *q = ns->disk->queue;
struct request_queue *q = ns->queue;
may be ?
> + int ret;
> +
> + ret = blk_revalidate_disk_zones(ns->disk, NULL);
> + if (!ret)
> + blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append);
> + return ret;
> +}
> +
> static int nvme_set_max_append(struct nvme_ctrl *ctrl)
> {
> struct nvme_command c = { };
>
--
Damien Le Moal
Western Digital Research
More information about the Linux-nvme
mailing list