On Wed, 2017-06-28 at 13:14 -0700, Dan Williams wrote: > On Wed, Jun 28, 2017 at 1:07 PM, Vishal Verma <[email protected] > m> wrote: > > The UEFI 2.7 specification defines an updated BTT metadata format, > > bumping the revision to 2.0. Add support for the new format, while > > retaining compatibility for the old 1.1 format. > > > > Cc: Toshi Kani <[email protected]> > > Cc: Linda Knippers <[email protected]> > > Cc: Dan Williams <[email protected]> > > Signed-off-by: Vishal Verma <[email protected]> > > [..] > > diff --git a/drivers/nvdimm/namespace_devs.c > > b/drivers/nvdimm/namespace_devs.c > > index f05d9b0..09e7e76 100644 > > --- a/drivers/nvdimm/namespace_devs.c > > +++ b/drivers/nvdimm/namespace_devs.c > > @@ -1411,6 +1411,58 @@ static ssize_t dpa_extents_show(struct device > > *dev, > > } > > static DEVICE_ATTR_RO(dpa_extents); > > > > +static int btt_claim_class(struct device *dev) > > +{ > > + struct nd_region *nd_region = to_nd_region(dev->parent); > > + int i, loop_bitmask = 0; > > + > > + for (i = 0; i < nd_region->ndr_mappings; i++) { > > + struct nd_mapping *nd_mapping = &nd_region- > > >mapping[i]; > > + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); > > + struct nd_namespace_index *nsindex; > > + > > + nsindex = to_namespace_index(ndd, ndd->ns_current); > > + if (nsindex == NULL) > > + loop_bitmask |= 1; > > + else { > > + /* check whether existing labels are v1.1 or > > v1.2 */ > > + if (__le16_to_cpu(nsindex->major) == 1 > > + && __le16_to_cpu(nsindex- > > >minor) == 1) > > + loop_bitmask |= 2; > > + else > > + loop_bitmask |= 4; > > + } > > + } > > + /* > > + * If nsindex is null loop_bitmask's bit 0 will be set, and > > if an index > > + * block is found, a v1.1 label for any mapping will set bit > > 1, and a > > + * v1.2 label will set bit 2. > > + * > > + * At the end of the loop, only one of the three bits must > > be set. > > + * If multiple bits were set, it means the different > > mappings disagree > > + * about their labels, and this must be cleaned up first. > > + * > > + * If all the label index blocks are found to agree, nsindex > > of NULL > > + * implies labels haven't been initialized yet, and when > > they will, > > + * they will be of the 1.2 format, so we can assume BTT2.0 > > + * > > + * If 1.1 labels are found, we enforce BTT1.1, and if 1.2 > > labels are > > + * found, we enforce BTT2.0 > > + * > > + * If the loop was never entered, default to BTT1.1 (legacy > > namespaces) > > + */ > > + switch (loop_bitmask) { > > + case 0: > > + case 2: > > + return NVDIMM_CCLASS_BTT; > > + case 1: > > + case 4: > > + return NVDIMM_CCLASS_BTT2; > > + default: > > + return -ENXIO; > > + } > > Clever, looks good to me. I'll get this queued.
Err Hold on, I just noticed I forgot to properly propagate the ENXIO in __holder_class_store. v5 incoming. _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
