Skip to content

Commit 9761b02

Browse files
committed
libnvdimm/labels: Add isetcookie validation helper
In preparation to handle CXL labels with the same code that handles EFI labels, add a specific interleave-set-cookie validation helper rather than a getter since the CXL label type does not support this concept. The answer for CXL labels will always be true. Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/162982113550.1124374.206762177785773038.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent b4366a8 commit 9761b02

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,15 +1847,13 @@ static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid,
18471847
list_for_each_entry(label_ent, &nd_mapping->labels, list) {
18481848
struct nd_namespace_label *nd_label = label_ent->label;
18491849
u16 position, nlabel;
1850-
u64 isetcookie;
18511850

18521851
if (!nd_label)
18531852
continue;
1854-
isetcookie = nsl_get_isetcookie(ndd, nd_label);
18551853
position = nsl_get_position(ndd, nd_label);
18561854
nlabel = nsl_get_nlabel(ndd, nd_label);
18571855

1858-
if (isetcookie != cookie)
1856+
if (!nsl_validate_isetcookie(ndd, nd_label, cookie))
18591857
continue;
18601858

18611859
if (memcmp(nd_label->uuid, uuid, NSLABEL_UUID_LEN) != 0)
@@ -1968,10 +1966,10 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
19681966
return ERR_PTR(-ENXIO);
19691967
}
19701968

1971-
if (nsl_get_isetcookie(ndd, nd_label) != cookie) {
1969+
if (!nsl_validate_isetcookie(ndd, nd_label, cookie)) {
19721970
dev_dbg(&nd_region->dev, "invalid cookie in label: %pUb\n",
19731971
nd_label->uuid);
1974-
if (nsl_get_isetcookie(ndd, nd_label) != altcookie)
1972+
if (!nsl_validate_isetcookie(ndd, nd_label, altcookie))
19751973
return ERR_PTR(-EAGAIN);
19761974

19771975
dev_dbg(&nd_region->dev, "valid altcookie in label: %pUb\n",

drivers/nvdimm/nd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ static inline u64 nsl_get_isetcookie(struct nvdimm_drvdata *ndd,
8383
return __le64_to_cpu(nd_label->isetcookie);
8484
}
8585

86+
static inline bool nsl_validate_isetcookie(struct nvdimm_drvdata *ndd,
87+
struct nd_namespace_label *nd_label,
88+
u64 cookie)
89+
{
90+
return cookie == __le64_to_cpu(nd_label->isetcookie);
91+
}
92+
8693
static inline u16 nsl_get_position(struct nvdimm_drvdata *ndd,
8794
struct nd_namespace_label *nd_label)
8895
{

0 commit comments

Comments
 (0)