From: Joel Granados <j.granados@samsung.com>
To: Christoph Hellwig <hch@lst.de>
Cc: kbusch@kernel.org, sagi@grimberg.me, joshi.k@samsung.com,
linux-nvme@lists.infradead.org, gost.dev@samsung.com,
k.jensen@samsung.com, "Javier González" <javier.gonz@samsung.com>,
"Chaitanya Kulkarni" <kch@nvidia.com>
Subject: Re: [PATCH 5/6] nvme: factor out a nvme_ns_is_readonly helper
Date: Thu, 21 Jul 2022 11:54:47 +0200 [thread overview]
Message-ID: <20220721095447.a5y4ds7k7iw77xm6@localhost> (raw)
In-Reply-To: <20220721060320.1704646-6-hch@lst.de>
[-- Attachment #1: Type: text/plain, Size: 3047 bytes --]
On Thu, Jul 21, 2022 at 08:03:19AM +0200, Christoph Hellwig wrote:
> Add a little helper to check if a namespace should be marked read-only
> that uses a new is_readonly flag in the nvme_ns_info structure.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Javier González <javier.gonz@samsung.com>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
> drivers/nvme/host/core.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 6169737c233b2..271c0de483a9b 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -36,6 +36,7 @@ struct nvme_ns_info {
> u32 nsid;
> __le32 anagrpid;
> bool is_shared;
> + bool is_readonly;
> bool is_ready;
> };
>
> @@ -1447,6 +1448,7 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
> return ret;
> info->anagrpid = id->anagrpid;
> info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
> + info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
> info->is_ready = true;
> if (ctrl->quirks & NVME_QUIRK_BOGUS_NID) {
> dev_info(ctrl->device,
> @@ -1482,6 +1484,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
> if (!ret) {
> info->anagrpid = id->anagrpid;
> info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
> + info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
> info->is_ready = id->nstat & NVME_NSTAT_NRDY;
> }
> kfree(id);
> @@ -1909,6 +1912,11 @@ static void nvme_update_disk_info(struct gendisk *disk,
> ns->ctrl->max_zeroes_sectors);
> }
>
> +static bool nvme_ns_is_readonly(struct nvme_ns *ns, struct nvme_ns_info *info)
> +{
> + return info->is_readonly || test_bit(NVME_NS_FORCE_RO, &ns->flags);
> +}
> +
> static inline bool nvme_first_scan(struct gendisk *disk)
> {
> /* nvme_alloc_ns() scans the disk prior to adding it */
> @@ -1974,8 +1982,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
> }
> }
>
> - set_disk_ro(ns->disk, (id->nsattr & NVME_NS_ATTR_RO) ||
> - test_bit(NVME_NS_FORCE_RO, &ns->flags));
> + set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
> set_bit(NVME_NS_READY, &ns->flags);
> blk_mq_unfreeze_queue(ns->disk->queue);
>
> @@ -1988,9 +1995,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
> if (nvme_ns_head_multipath(ns->head)) {
> blk_mq_freeze_queue(ns->head->disk->queue);
> nvme_update_disk_info(ns->head->disk, ns, id);
> - set_disk_ro(ns->head->disk,
> - (id->nsattr & NVME_NS_ATTR_RO) ||
> - test_bit(NVME_NS_FORCE_RO, &ns->flags));
> + set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
> nvme_mpath_revalidate_paths(ns);
> blk_stack_limits(&ns->head->disk->queue->limits,
> &ns->queue->limits, 0);
> --
> 2.30.2
>
LGTM
Reviewed-by: Joel Granados <j.granados@samsung.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2022-07-21 9:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 6:03 enable generic interface (/dev/ngX) for unknown command sets v3 Christoph Hellwig
2022-07-21 6:03 ` [PATCH 1/6] nvme: catch -ENODEV from nvme_revalidate_zones again Christoph Hellwig
2022-07-21 9:53 ` Joel Granados
2022-07-21 6:03 ` [PATCH 2/6] nvme: rename nvme_validate_or_alloc_ns to nvme_scan_ns Christoph Hellwig
2022-07-21 6:03 ` [PATCH 3/6] nvme: generalize the nvme_multi_css check in nvme_scan_ns Christoph Hellwig
2022-07-21 9:54 ` Joel Granados
2022-07-21 6:03 ` [PATCH 4/6] nvme: refactor namespace probing Christoph Hellwig
2022-07-21 9:36 ` Joel Granados
2022-07-21 6:03 ` [PATCH 5/6] nvme: factor out a nvme_ns_is_readonly helper Christoph Hellwig
2022-07-21 9:54 ` Joel Granados [this message]
2022-07-21 6:03 ` [PATCH 6/6] nvme: enable generic interface (/dev/ngXnY) for unknown command sets Christoph Hellwig
2022-07-21 22:17 ` enable generic interface (/dev/ngX) for unknown command sets v3 Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220721095447.a5y4ds7k7iw77xm6@localhost \
--to=j.granados@samsung.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=javier.gonz@samsung.com \
--cc=joshi.k@samsung.com \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox