From: Shivaprasad G Bhat <sbhat@linux.ibm.com>
To: Tarun Sahu <tsahu@linux.ibm.com>, nvdimm@lists.linux.dev
Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com,
aneesh.kumar@linux.ibm.com, vaibhav@linux.ibm.com
Subject: Re: [PATCH v3 1/2] ndctl/namespace:Fix multiple issues with write-infoblock
Date: Tue, 24 May 2022 11:17:14 +0530 [thread overview]
Message-ID: <e1a9cf32-0628-1e2d-83f8-c2946a6298aa@linux.ibm.com> (raw)
In-Reply-To: <20220426172056.122789-2-tsahu@linux.ibm.com>
On 4/26/22 22:50, Tarun Sahu wrote:
> Write-infoblock command has the below issues,
> 1 - Oerwriting the existing alignment value with the default value when
> not passed as parameter.
> 2 - Changing the mode of the namespace to fsdax when -m not specified
> 3 - Incorrectly updating the uuid and parent_uuid if corresponding
> parameter is not specified
<snip>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 257b58c..cca9a51 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
<snip>
> @@ -2026,12 +2105,10 @@ static int namespace_rw_infoblock(struct ndctl_namespace *ndns,
> struct read_infoblock_ctx *ri_ctx, int write)
> {
> int rc;
> - uuid_t uuid;
> - char str[40];
> char path[50];
> - const char *save;
> const char *cmd = write ? "write-infoblock" : "read-infoblock";
> const char *devname = ndctl_namespace_get_devname(ndns);
> + struct ns_info ns_info;
>
> if (ndctl_namespace_is_active(ndns)) {
> pr_verbose("%s: %s enabled, must be disabled\n", cmd, devname);
> @@ -2045,21 +2122,22 @@ static int namespace_rw_infoblock(struct ndctl_namespace *ndns,
> goto out;
This would lead to calling ns_info_destroy() on uninitialized ns_info,
and ns_info->ns_sb_buf would have junk value.
With that fixed,
Reviewed-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> }
>
> - save = param.parent_uuid;
> - if (!param.parent_uuid) {
> - ndctl_namespace_get_uuid(ndns, uuid);
> - uuid_unparse(uuid, str);
> - param.parent_uuid = str;
> - }
> -
> sprintf(path, "/dev/%s", ndctl_namespace_get_block_device(ndns));
> - if (write) {
> + if (ns_info_init(&ns_info) != 0)
> + goto out;
> +
> + rc = file_read_infoblock(path, ndns, ri_ctx, &ns_info);
> + if (!rc && write) {
> unsigned long long align;
> bool align_provided = true;
>
> if (!param.align) {
> align = ndctl_get_default_alignment(ndns);
> -
> + if (ns_info.mode == NDCTL_NS_MODE_FSDAX ||
> + ns_info.mode == NDCTL_NS_MODE_DEVDAX) {
> + align = ((struct pfn_sb *)(ns_info.ns_sb_buf + ns_info.offset))->
> + align;
> + }
> if (asprintf((char **)¶m.align, "%llu", align) < 0) {
> rc = -EINVAL;
> goto out;
> @@ -2078,18 +2156,16 @@ static int namespace_rw_infoblock(struct ndctl_namespace *ndns,
> rc = -EINVAL;
> }
> }
> -
> if (!rc)
> - rc = file_write_infoblock(path);
> + rc = file_write_infoblock(path, &ns_info);
>
> if (!align_provided) {
> free((char *)param.align);
> param.align = NULL;
> }
> - } else
> - rc = file_read_infoblock(path, ndns, ri_ctx);
> - param.parent_uuid = save;
> + }
> out:
> + ns_info_destroy(&ns_info);
> ndctl_namespace_set_raw_mode(ndns, 0);
> ndctl_namespace_disable_invalidate(ndns);
> return rc;
next prev parent reply other threads:[~2022-05-24 5:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 17:20 [PATCH v3 0/2] ndctl/namespace:Fix and improve write-infoblock Tarun Sahu
2022-04-26 17:20 ` [PATCH v3 1/2] ndctl/namespace:Fix multiple issues with write-infoblock Tarun Sahu
2022-05-24 5:47 ` Shivaprasad G Bhat [this message]
2022-05-24 6:09 ` Shivaprasad G Bhat
2022-04-26 17:20 ` [PATCH v3 2/2] ndctl/namespace:Implement write-infoblock for sector mode namespaces Tarun Sahu
2022-05-13 7:07 ` [PATCH v3 0/2] ndctl/namespace:Fix and improve write-infoblock Tarun Sahu
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=e1a9cf32-0628-1e2d-83f8-c2946a6298aa@linux.ibm.com \
--to=sbhat@linux.ibm.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=nvdimm@lists.linux.dev \
--cc=tsahu@linux.ibm.com \
--cc=vaibhav@linux.ibm.com \
--cc=vishal.l.verma@intel.com \
/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