From: "Verma, Vishal L" <vishal.l.verma-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
<jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.org"
<linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.org>
Subject: Re: [PATCH] ndctl: add a BTT check utility
Date: Tue, 31 Jan 2017 00:12:04 +0000 [thread overview]
Message-ID: <1485821454.4857.13.camel@intel.com> (raw)
In-Reply-To: <x49lgu52uk0.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
On Fri, 2017-01-20 at 18:14 -0500, Jeff Moyer wrote:
<snip>
>
> > +static int btt_map_read(struct arena_info *a, __u32 lba, __u32
> > *mapping,
> > + int *trim, int *error)
> > +{
> > + __u32 raw_mapping, postmap, ze, z_flag, e_flag;
> > +
> > + raw_mapping = le32toh(a->map.map[lba]);
> > + z_flag = (raw_mapping & MAP_TRIM_MASK) >> MAP_TRIM_SHIFT;
> > + e_flag = (raw_mapping & MAP_ERR_MASK) >> MAP_ERR_SHIFT;
> > + ze = (z_flag << 1) + e_flag;
> > + postmap = raw_mapping & MAP_LBA_MASK;
> > +
> > + /* Reuse the {z,e}_flag variables for *trim and *error */
> > + z_flag = 0;
> > + e_flag = 0;
> > +
> > + switch (ze) {
> > + case 0:
> > + /* Initial state. Return postmap = premap */
> > + *mapping = lba;
> > + break;
> > + case 1:
> > + *mapping = postmap;
> > + e_flag = 1;
> > + break;
> > + case 2:
> > + *mapping = postmap;
> > + z_flag = 1;
> > + break;
> > + case 3:
> > + *mapping = postmap;
> > + break;
> > + default:
> > + return -EIO;
> > + }
> > +
> > + if (trim)
> > + *trim = z_flag;
> > + if (error)
> > + *error = e_flag;
> > +
> > + return 0;
> > +}
>
> No caller uses z or e, so get rid of those args. Also, your default
> entry in the switch statement can never be hit. Fixing those, the
> function is just:
>
> /*
> * btt_map_lookup
> *
> * Given a pre-map Arena Block Address, return the post-map ABA.
> */
> static u32 btt_map_lookup(struct arena_info *a, __u32 lba)
> {
> return (le32toh(a->map.map[lba]) & MAP_LBA_MASK);
I think this might be an oversimplification?
We still have to check whether the z and e flags are both 0, and if so
return 'lba' -- the initial state check. This would return '0' which
would be incorrect.. I will simplify the arguments etc though, and not
return the values of flags.
> }
>
> You can take or leave the function name change. Please keep the
> comment, and maybe kernel-doc-ify it.
>
> > +static int btt_map_write(struct arena_info *a, __u32 lba, __u32
> > mapping,
> > + __u32 z_flag, __u32 e_flag)
> > +{
>
> Again, z and e are unused. Nuke 'em.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
prev parent reply other threads:[~2017-01-31 0:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 3:12 [PATCH] ndctl: add a BTT check utility Vishal Verma
2017-01-20 20:04 ` Dan Williams
2017-01-23 17:42 ` Ross Zwisler
2017-01-23 17:49 ` Dan Williams
2017-01-20 21:00 ` Linda Knippers
2017-01-24 22:58 ` Verma, Vishal L
[not found] ` <20170120031234.24226-1-vishal.l.verma-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-20 23:14 ` Jeff Moyer
[not found] ` <x49lgu52uk0.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2017-01-21 0:41 ` Verma, Vishal L
[not found] ` <1484959224.4857.6.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-01-23 18:20 ` Jeff Moyer
[not found] ` <x49vat5ljtz.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2017-01-24 20:59 ` Verma, Vishal L
2017-01-31 0:12 ` Verma, Vishal L [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=1485821454.4857.13.camel@intel.com \
--to=vishal.l.verma-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=jmoyer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-nvdimm-y27Ovi1pjclAfugRpC6u6w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox