All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [ndctl PATCH] test, libndctl: check btt size
Date: Fri, 26 Aug 2016 10:31:43 -0600	[thread overview]
Message-ID: <20160826163143.GE7799@omniknight.lm.intel.com> (raw)
In-Reply-To: <147216948018.40698.3869445232513766645.stgit@dwillia2-desk3.amr.corp.intel.com>

On 08/25, Dan Williams wrote:
> Now that the kernel reports the size of the btt, lets check that the
> size stays constant across kernel updates.  I.e. if we inadvertently
> introduce a change that causes the btt to reduce the effective capacity
> of the block device, this test is meant to catch it.
> 
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  test/libndctl.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
> 
Good idea!
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> diff --git a/test/libndctl.c b/test/libndctl.c
> index 5f86addc5c7e..e36fe8a4fe6f 100644
> --- a/test/libndctl.c
> +++ b/test/libndctl.c
> @@ -937,6 +937,68 @@ static int check_pfn_create(struct ndctl_region *region,
>  	return rc;
>  }
>  
> +static int check_btt_size(struct ndctl_btt *btt)
> +{
> +	struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
> +	unsigned long long ns_size = ndctl_namespace_get_size(ndns);
> +	unsigned long sect_size = ndctl_btt_get_sector_size(btt);
> +	unsigned long long actual, expect;
> +	int size_select, sect_select;
> +	unsigned long long expect_table[][2] = {
> +		[0] = {
> +			[0] = 0x11b4400,
> +			[1] = 0x8da2000,
> +		},
> +		[1] = {
> +			[0] = 0x13b0400,
> +			[1] = 0x9d82000,
> +		},
> +		[2] = {
> +			[0] = 0x1aa2600,
> +			[1] = 0xd513000,
> +		},
> +	};
> +
> +	if (sect_size >= SZ_4K)
> +		sect_select = 1;
> +	else if (sect_size >= 512)
> +		sect_select = 0;
> +	else {
> +		fprintf(stderr, "%s: %s unexpected sector size: %lx\n",
> +				__func__, ndctl_btt_get_devname(btt),
> +				sect_size);
> +		return -ENXIO;
> +	}
> +
> +	switch (ns_size) {
> +	case SZ_18M:
> +		size_select = 0;
> +		break;
> +	case SZ_20M:
> +		size_select = 1;
> +		break;
> +	case SZ_27M:
> +		size_select = 2;
> +		break;
> +	default:
> +		fprintf(stderr, "%s: %s unexpected namespace size: %llx\n",
> +				__func__, ndctl_namespace_get_devname(ndns),
> +				ns_size);
> +		break;
> +	}
> +
> +	expect = expect_table[size_select][sect_select];
> +	actual = ndctl_btt_get_size(btt);
> +	if (expect != actual) {
> +		fprintf(stderr, "%s: namespace: %s unexpected size: %llx (expected: %llx)\n",
> +				ndctl_btt_get_devname(btt),
> +				ndctl_namespace_get_devname(ndns), actual, expect);
> +		return -ENXIO;
> +	}
> +
> +	return 0;
> +}
> +
>  static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace *ndns,
>  		struct namespace *namespace)
>  {
> @@ -982,6 +1044,10 @@ static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
>  			fprintf(stderr, "%s: expected safe mode got: %d\n",
>  					devname, mode);
>  
> +		rc = check_btt_size(btt);
> +		if (rc)
> +			goto err;
> +
>  		if (btt_seed == ndctl_region_get_btt_seed(region)
>  				&& btt == btt_seed) {
>  			fprintf(stderr, "%s: failed to advance btt seed\n",
> 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

      reply	other threads:[~2016-08-26 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 23:58 [ndctl PATCH] test, libndctl: check btt size Dan Williams
2016-08-26 16:31 ` Vishal Verma [this message]

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=20160826163143.GE7799@omniknight.lm.intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.