nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
	"Liu, Jingqi" <jingqi.liu@intel.com>
Subject: Re: [PATCH] ndctl/dimm: Fix to dump namespace indexs and labels
Date: Thu, 8 Jul 2021 00:21:37 +0000	[thread overview]
Message-ID: <8110e80df98fb57fd20d0bf73dc7d266fef5ab84.camel@intel.com> (raw)
In-Reply-To: <20210609030642.66204-1-jingqi.liu@intel.com>

On Wed, 2021-06-09 at 11:06 +0800, Jingqi Liu wrote:
> The following bug is caused by setting the size of Label Index Block
> to a fixed 256 bytes.
> 
> Use the following Qemu command to start a Guest with 2MB label-size:
> 	-object memory-backend-file,id=mem1,share=on,mem-path=/dev/dax1.1,size=14G,align=2M
> 	-device nvdimm,memdev=mem1,id=nv1,label-size=2M
> 
> There is a namespace in the Guest as follows:
> 	$ ndctl list
> 	[
> 	  {
> 	    "dev":"namespace0.0",
> 	    "mode":"devdax",
> 	    "map":"dev",
> 	    "size":14780727296,
> 	    "uuid":"58ad5282-5a16-404f-b8ee-e28b4c784eb8",
> 	    "chardev":"dax0.0",
> 	    "align":2097152,
> 	    "name":"namespace0.0"
> 	  }
> 	]
> 
> Fail to read labels. The result is as follows:
> 	$ ndctl read-labels -u nmem0
> 	[
> 	]
> 	read 0 nmem
> 
> If using the following Qemu command to start the Guest with 128K
> label-size, this label can be read correctly.
> 	-object memory-backend-file,id=mem1,share=on,mem-path=/dev/dax1.1,size=14G,align=2M
> 	-device nvdimm,memdev=mem1,id=nv1,label-size=128K
> 
> The size of a Label Index Block depends on how many label slots fit into
> the label storage area. The minimum size of an index block is 256 bytes
> and the size must be a multiple of 256 bytes. For a storage area of 128KB,
> the corresponding Label Index Block size is 256 bytes. But if the label
> storage area is not 128KB, the Label Index Block size should not be 256 bytes.
> 
> Namespace Label Index Block appears twice at the top of the label storage area.
> Following the two index blocks, an array for storing labels takes up the
> remainder of the label storage area.
> 
> For obtaining the size of Namespace Index Block, we also cannot rely on
> the field of 'mysize' in this index block since it might be corrupted.
> Similar to the linux kernel, we use sizeof_namespace_index() to get the size
> of Namespace Index Block. Then we can also correctly calculate the starting
> offset of the following namespace labels.
> 
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Jingqi Liu <jingqi.liu@intel.com>
> ---
>  ndctl/dimm.c           | 19 +++++++++++++++----
>  ndctl/lib/dimm.c       |  5 +++++
>  ndctl/lib/libndctl.sym |  1 +
>  ndctl/libndctl.h       |  1 +
>  4 files changed, 22 insertions(+), 4 deletions(-)

Hi Jingqi,

This looks fine, one comment below.

[..]
> 
> diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
> index 0a82616..0ce2bb9 100644
> --- a/ndctl/lib/libndctl.sym
> +++ b/ndctl/lib/libndctl.sym
> @@ -290,6 +290,7 @@ global:
>  	ndctl_dimm_validate_labels;
>  	ndctl_dimm_init_labels;
>  	ndctl_dimm_sizeof_namespace_label;
> +	ndctl_dimm_sizeof_namespace_index;

This can't go into an 'old' section of the symbol version script - if
you base off the current 'pending' branch, you should see a LIBNDCTL_26
section at the bottom. You can add this there.

>  	ndctl_mapping_get_position;
>  	ndctl_namespace_set_enforce_mode;
>  	ndctl_namespace_get_enforce_mode;
> diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
> index 60e1288..9a1a799 100644
> --- a/ndctl/libndctl.h
> +++ b/ndctl/libndctl.h
> @@ -335,6 +335,7 @@ int ndctl_dimm_init_labels(struct ndctl_dimm *dimm,
>  		enum ndctl_namespace_version v);
>  unsigned long ndctl_dimm_get_available_labels(struct ndctl_dimm *dimm);
>  unsigned int ndctl_dimm_sizeof_namespace_label(struct ndctl_dimm *dimm);
> +unsigned int ndctl_dimm_sizeof_namespace_index(struct ndctl_dimm *dimm);
>  unsigned int ndctl_cmd_cfg_size_get_size(struct ndctl_cmd *cfg_size);
>  ssize_t ndctl_cmd_cfg_read_get_data(struct ndctl_cmd *cfg_read, void *buf,
>  		unsigned int len, unsigned int offset);


  parent reply	other threads:[~2021-07-08  0:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  3:06 Jingqi Liu
2021-06-16  1:31 ` Liu, Jingqi
2021-07-02  4:41 ` Dan Williams
2021-07-08  0:21 ` Verma, Vishal L [this message]
2021-07-08  1:53   ` Liu, Jingqi
2021-07-08  5:59     ` Verma, Vishal L
2021-07-08  6:52       ` Liu, Jingqi
  -- strict thread matches above, loose matches on Subject: below --
2021-06-03  1:25 Jingqi Liu
2021-06-07 20:03 ` Dan Williams
2021-06-09  1:27   ` Liu, Jingqi
2021-06-02 12:18 Jingqi Liu

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=8110e80df98fb57fd20d0bf73dc7d266fef5ab84.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=jingqi.liu@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --subject='Re: [PATCH] ndctl/dimm: Fix to dump namespace indexs and labels' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).