* [PATCH 0/2] libnvdimm, dax: autodetect fixes
@ 2016-05-18 23:43 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:43 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable
Now that the base device-DAX implementation is settling I am circling
back to further flesh out the ndctl unit tests. These 2 fixes fell out
as a result.
---
Dan Williams (2):
libnvdimm, dax: autodetect support
libnvdimm, dax: fix alignment validation
drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/nd.h | 11 +++++++++--
drivers/nvdimm/pfn.h | 1 +
drivers/nvdimm/pfn_devs.c | 20 +++++++++++++-------
drivers/nvdimm/pmem.c | 3 ++-
5 files changed, 60 insertions(+), 10 deletions(-)
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/2] libnvdimm, dax: autodetect fixes
@ 2016-05-18 23:43 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:43 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable, jthumshirn
Now that the base device-DAX implementation is settling I am circling
back to further flesh out the ndctl unit tests. These 2 fixes fell out
as a result.
---
Dan Williams (2):
libnvdimm, dax: autodetect support
libnvdimm, dax: fix alignment validation
drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/nd.h | 11 +++++++++--
drivers/nvdimm/pfn.h | 1 +
drivers/nvdimm/pfn_devs.c | 20 +++++++++++++-------
drivers/nvdimm/pmem.c | 3 ++-
5 files changed, 60 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/2] libnvdimm, dax: autodetect fixes
@ 2016-05-18 23:43 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:43 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable, jthumshirn
Now that the base device-DAX implementation is settling I am circling
back to further flesh out the ndctl unit tests. These 2 fixes fell out
as a result.
---
Dan Williams (2):
libnvdimm, dax: autodetect support
libnvdimm, dax: fix alignment validation
drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/nd.h | 11 +++++++++--
drivers/nvdimm/pfn.h | 1 +
drivers/nvdimm/pfn_devs.c | 20 +++++++++++++-------
drivers/nvdimm/pmem.c | 3 ++-
5 files changed, 60 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/2] libnvdimm, dax: autodetect support
2016-05-18 23:43 ` Dan Williams
@ 2016-05-18 23:44 ` Dan Williams
-1 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:44 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel
For autodetecting a previously established dax configuration we need the
info block to indicate block-device vs device-dax mode, and we need to
have the default namespace probe hand-off the configuration to the
dax_pmem driver.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/nd.h | 11 +++++++++--
drivers/nvdimm/pfn.h | 1 +
drivers/nvdimm/pfn_devs.c | 15 ++++++++++-----
drivers/nvdimm/pmem.c | 3 ++-
5 files changed, 57 insertions(+), 8 deletions(-)
diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
index f90f7549e7f4..45fa82cae87c 100644
--- a/drivers/nvdimm/dax_devs.c
+++ b/drivers/nvdimm/dax_devs.c
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/mm.h>
#include "nd-core.h"
+#include "pfn.h"
#include "nd.h"
static void nd_dax_release(struct device *dev)
@@ -97,3 +98,37 @@ struct device *nd_dax_create(struct nd_region *nd_region)
__nd_device_register(dev);
return dev;
}
+
+int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
+{
+ int rc;
+ struct nd_dax *nd_dax;
+ struct device *dax_dev;
+ struct nd_pfn *nd_pfn;
+ struct nd_pfn_sb *pfn_sb;
+ struct nd_region *nd_region = to_nd_region(ndns->dev.parent);
+
+ if (ndns->force_raw)
+ return -ENODEV;
+
+ nvdimm_bus_lock(&ndns->dev);
+ nd_dax = nd_dax_alloc(nd_region);
+ nd_pfn = &nd_dax->nd_pfn;
+ dax_dev = nd_pfn_devinit(nd_pfn, ndns);
+ nvdimm_bus_unlock(&ndns->dev);
+ if (!dax_dev)
+ return -ENOMEM;
+ pfn_sb = devm_kzalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
+ nd_pfn->pfn_sb = pfn_sb;
+ rc = nd_pfn_validate(nd_pfn, DAX_SIG);
+ dev_dbg(dev, "%s: dax: %s\n", __func__,
+ rc == 0 ? dev_name(dax_dev) : "<none>");
+ if (rc < 0) {
+ __nd_detach_ndns(dax_dev, &nd_pfn->ndns);
+ put_device(dax_dev);
+ } else
+ __nd_device_register(dax_dev);
+
+ return rc;
+}
+EXPORT_SYMBOL(nd_dax_probe);
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 46910b8f32b1..d0ac93c31dda 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -232,7 +232,7 @@ bool is_nd_pfn(struct device *dev);
struct device *nd_pfn_create(struct nd_region *nd_region);
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
struct nd_namespace_common *ndns);
-int nd_pfn_validate(struct nd_pfn *nd_pfn);
+int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig);
extern struct attribute_group nd_pfn_attribute_group;
#else
static inline int nd_pfn_probe(struct device *dev,
@@ -251,7 +251,7 @@ static inline struct device *nd_pfn_create(struct nd_region *nd_region)
return NULL;
}
-static inline int nd_pfn_validate(struct nd_pfn *nd_pfn)
+static inline int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
{
return -ENODEV;
}
@@ -259,9 +259,16 @@ static inline int nd_pfn_validate(struct nd_pfn *nd_pfn)
struct nd_dax *to_nd_dax(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_DAX)
+int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_dax(struct device *dev);
struct device *nd_dax_create(struct nd_region *nd_region);
#else
+static inline int nd_dax_probe(struct device *dev,
+ struct nd_namespace_common *ndns)
+{
+ return -ENODEV;
+}
+
static inline bool is_nd_dax(struct device *dev)
{
return false;
diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h
index 9d2704c83fa7..dde9853453d3 100644
--- a/drivers/nvdimm/pfn.h
+++ b/drivers/nvdimm/pfn.h
@@ -19,6 +19,7 @@
#define PFN_SIG_LEN 16
#define PFN_SIG "NVDIMM_PFN_INFO\0"
+#define DAX_SIG "NVDIMM_DAX_INFO\0"
struct nd_pfn_sb {
u8 signature[PFN_SIG_LEN];
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 58740d7ce81b..816cd9828ca5 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -360,7 +360,7 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
return dev;
}
-int nd_pfn_validate(struct nd_pfn *nd_pfn)
+int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
{
u64 checksum, offset;
struct nd_namespace_io *nsio;
@@ -377,7 +377,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn)
if (nvdimm_read_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb)))
return -ENXIO;
- if (memcmp(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN) != 0)
+ if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0)
return -ENODEV;
checksum = le64_to_cpu(pfn_sb->checksum);
@@ -467,7 +467,7 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
pfn_sb = devm_kzalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
nd_pfn = to_nd_pfn(pfn_dev);
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn);
+ rc = nd_pfn_validate(nd_pfn, PFN_SIG);
dev_dbg(dev, "%s: pfn: %s\n", __func__,
rc == 0 ? dev_name(pfn_dev) : "<none>");
if (rc < 0) {
@@ -552,6 +552,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
struct nd_pfn_sb *pfn_sb;
unsigned long npfns;
phys_addr_t offset;
+ const char *sig;
u64 checksum;
int rc;
@@ -560,7 +561,11 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
return -ENOMEM;
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn);
+ if (is_nd_dax(&nd_pfn->dev))
+ sig = DAX_SIG;
+ else
+ sig = PFN_SIG;
+ rc = nd_pfn_validate(nd_pfn, sig);
if (rc != -ENODEV)
return rc;
@@ -628,7 +633,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
pfn_sb->mode = cpu_to_le32(nd_pfn->mode);
pfn_sb->dataoff = cpu_to_le64(offset);
pfn_sb->npfns = cpu_to_le64(npfns);
- memcpy(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN);
+ memcpy(pfn_sb->signature, sig, PFN_SIG_LEN);
memcpy(pfn_sb->uuid, nd_pfn->uuid, 16);
memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16);
pfn_sb->version_major = cpu_to_le16(1);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index d9a0dbc2d023..042baec56931 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -320,7 +320,8 @@ static int nd_pmem_probe(struct device *dev)
return pmem_attach_disk(dev, ndns);
/* if we find a valid info-block we'll come back as that personality */
- if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0)
+ if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0
+ || nd_dax_probe(dev, ndns) == 0)
return -ENXIO;
/* ...otherwise we're just a raw pmem device */
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 1/2] libnvdimm, dax: autodetect support
@ 2016-05-18 23:44 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:44 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, jthumshirn
For autodetecting a previously established dax configuration we need the
info block to indicate block-device vs device-dax mode, and we need to
have the default namespace probe hand-off the configuration to the
dax_pmem driver.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/nd.h | 11 +++++++++--
drivers/nvdimm/pfn.h | 1 +
drivers/nvdimm/pfn_devs.c | 15 ++++++++++-----
drivers/nvdimm/pmem.c | 3 ++-
5 files changed, 57 insertions(+), 8 deletions(-)
diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
index f90f7549e7f4..45fa82cae87c 100644
--- a/drivers/nvdimm/dax_devs.c
+++ b/drivers/nvdimm/dax_devs.c
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/mm.h>
#include "nd-core.h"
+#include "pfn.h"
#include "nd.h"
static void nd_dax_release(struct device *dev)
@@ -97,3 +98,37 @@ struct device *nd_dax_create(struct nd_region *nd_region)
__nd_device_register(dev);
return dev;
}
+
+int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
+{
+ int rc;
+ struct nd_dax *nd_dax;
+ struct device *dax_dev;
+ struct nd_pfn *nd_pfn;
+ struct nd_pfn_sb *pfn_sb;
+ struct nd_region *nd_region = to_nd_region(ndns->dev.parent);
+
+ if (ndns->force_raw)
+ return -ENODEV;
+
+ nvdimm_bus_lock(&ndns->dev);
+ nd_dax = nd_dax_alloc(nd_region);
+ nd_pfn = &nd_dax->nd_pfn;
+ dax_dev = nd_pfn_devinit(nd_pfn, ndns);
+ nvdimm_bus_unlock(&ndns->dev);
+ if (!dax_dev)
+ return -ENOMEM;
+ pfn_sb = devm_kzalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
+ nd_pfn->pfn_sb = pfn_sb;
+ rc = nd_pfn_validate(nd_pfn, DAX_SIG);
+ dev_dbg(dev, "%s: dax: %s\n", __func__,
+ rc == 0 ? dev_name(dax_dev) : "<none>");
+ if (rc < 0) {
+ __nd_detach_ndns(dax_dev, &nd_pfn->ndns);
+ put_device(dax_dev);
+ } else
+ __nd_device_register(dax_dev);
+
+ return rc;
+}
+EXPORT_SYMBOL(nd_dax_probe);
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 46910b8f32b1..d0ac93c31dda 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -232,7 +232,7 @@ bool is_nd_pfn(struct device *dev);
struct device *nd_pfn_create(struct nd_region *nd_region);
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
struct nd_namespace_common *ndns);
-int nd_pfn_validate(struct nd_pfn *nd_pfn);
+int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig);
extern struct attribute_group nd_pfn_attribute_group;
#else
static inline int nd_pfn_probe(struct device *dev,
@@ -251,7 +251,7 @@ static inline struct device *nd_pfn_create(struct nd_region *nd_region)
return NULL;
}
-static inline int nd_pfn_validate(struct nd_pfn *nd_pfn)
+static inline int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
{
return -ENODEV;
}
@@ -259,9 +259,16 @@ static inline int nd_pfn_validate(struct nd_pfn *nd_pfn)
struct nd_dax *to_nd_dax(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_DAX)
+int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_dax(struct device *dev);
struct device *nd_dax_create(struct nd_region *nd_region);
#else
+static inline int nd_dax_probe(struct device *dev,
+ struct nd_namespace_common *ndns)
+{
+ return -ENODEV;
+}
+
static inline bool is_nd_dax(struct device *dev)
{
return false;
diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h
index 9d2704c83fa7..dde9853453d3 100644
--- a/drivers/nvdimm/pfn.h
+++ b/drivers/nvdimm/pfn.h
@@ -19,6 +19,7 @@
#define PFN_SIG_LEN 16
#define PFN_SIG "NVDIMM_PFN_INFO\0"
+#define DAX_SIG "NVDIMM_DAX_INFO\0"
struct nd_pfn_sb {
u8 signature[PFN_SIG_LEN];
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 58740d7ce81b..816cd9828ca5 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -360,7 +360,7 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
return dev;
}
-int nd_pfn_validate(struct nd_pfn *nd_pfn)
+int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
{
u64 checksum, offset;
struct nd_namespace_io *nsio;
@@ -377,7 +377,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn)
if (nvdimm_read_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb)))
return -ENXIO;
- if (memcmp(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN) != 0)
+ if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0)
return -ENODEV;
checksum = le64_to_cpu(pfn_sb->checksum);
@@ -467,7 +467,7 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
pfn_sb = devm_kzalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
nd_pfn = to_nd_pfn(pfn_dev);
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn);
+ rc = nd_pfn_validate(nd_pfn, PFN_SIG);
dev_dbg(dev, "%s: pfn: %s\n", __func__,
rc == 0 ? dev_name(pfn_dev) : "<none>");
if (rc < 0) {
@@ -552,6 +552,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
struct nd_pfn_sb *pfn_sb;
unsigned long npfns;
phys_addr_t offset;
+ const char *sig;
u64 checksum;
int rc;
@@ -560,7 +561,11 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
return -ENOMEM;
nd_pfn->pfn_sb = pfn_sb;
- rc = nd_pfn_validate(nd_pfn);
+ if (is_nd_dax(&nd_pfn->dev))
+ sig = DAX_SIG;
+ else
+ sig = PFN_SIG;
+ rc = nd_pfn_validate(nd_pfn, sig);
if (rc != -ENODEV)
return rc;
@@ -628,7 +633,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
pfn_sb->mode = cpu_to_le32(nd_pfn->mode);
pfn_sb->dataoff = cpu_to_le64(offset);
pfn_sb->npfns = cpu_to_le64(npfns);
- memcpy(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN);
+ memcpy(pfn_sb->signature, sig, PFN_SIG_LEN);
memcpy(pfn_sb->uuid, nd_pfn->uuid, 16);
memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16);
pfn_sb->version_major = cpu_to_le16(1);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index d9a0dbc2d023..042baec56931 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -320,7 +320,8 @@ static int nd_pmem_probe(struct device *dev)
return pmem_attach_disk(dev, ndns);
/* if we find a valid info-block we'll come back as that personality */
- if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0)
+ if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0
+ || nd_dax_probe(dev, ndns) == 0)
return -ENXIO;
/* ...otherwise we're just a raw pmem device */
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] libnvdimm, dax: fix alignment validation
2016-05-18 23:43 ` Dan Williams
(?)
@ 2016-05-18 23:44 ` Dan Williams
-1 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:44 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable
Testing the dax-device autodetect support revealed a probe failure with
the following result:
dax0.1: bad offset: 0x8200000 dax disabled
The original pfn-device implementation inferred the alignment from
ilog2(offset), now that the alignment is explicit the is_power_of_2()
needs replacing with a real sanity check against the recorded alignment.
Otherwise the alignment check is useless in the implicit case and only
the minimum size of the offset matters.
This self-consistency check is further validated by the probe path that
will re-check that the offset is large enough to contain all the
metadata required to enable the device.
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pfn_devs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 816cd9828ca5..33c97076ddf0 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -416,6 +416,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -ENODEV;
}
+ nd_pfn->align = le32_to_cpu(pfn_sb->align);
if (nd_pfn->align > nvdimm_namespace_capacity(ndns)) {
dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n",
nd_pfn->align, nvdimm_namespace_capacity(ndns));
@@ -436,8 +437,8 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -EBUSY;
}
- nd_pfn->align = le32_to_cpu(pfn_sb->align);
- if (!is_power_of_2(offset) || offset < PAGE_SIZE) {
+ if ((nd_pfn->align && !IS_ALIGNED(offset, nd_pfn->align))
+ || !IS_ALIGNED(offset, PAGE_SIZE)) {
dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n",
offset);
return -ENXIO;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] libnvdimm, dax: fix alignment validation
@ 2016-05-18 23:44 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:44 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable, jthumshirn
Testing the dax-device autodetect support revealed a probe failure with
the following result:
dax0.1: bad offset: 0x8200000 dax disabled
The original pfn-device implementation inferred the alignment from
ilog2(offset), now that the alignment is explicit the is_power_of_2()
needs replacing with a real sanity check against the recorded alignment.
Otherwise the alignment check is useless in the implicit case and only
the minimum size of the offset matters.
This self-consistency check is further validated by the probe path that
will re-check that the offset is large enough to contain all the
metadata required to enable the device.
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pfn_devs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 816cd9828ca5..33c97076ddf0 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -416,6 +416,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -ENODEV;
}
+ nd_pfn->align = le32_to_cpu(pfn_sb->align);
if (nd_pfn->align > nvdimm_namespace_capacity(ndns)) {
dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n",
nd_pfn->align, nvdimm_namespace_capacity(ndns));
@@ -436,8 +437,8 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -EBUSY;
}
- nd_pfn->align = le32_to_cpu(pfn_sb->align);
- if (!is_power_of_2(offset) || offset < PAGE_SIZE) {
+ if ((nd_pfn->align && !IS_ALIGNED(offset, nd_pfn->align))
+ || !IS_ALIGNED(offset, PAGE_SIZE)) {
dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n",
offset);
return -ENXIO;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] libnvdimm, dax: fix alignment validation
@ 2016-05-18 23:44 ` Dan Williams
0 siblings, 0 replies; 13+ messages in thread
From: Dan Williams @ 2016-05-18 23:44 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-kernel, stable, jthumshirn
Testing the dax-device autodetect support revealed a probe failure with
the following result:
dax0.1: bad offset: 0x8200000 dax disabled
The original pfn-device implementation inferred the alignment from
ilog2(offset), now that the alignment is explicit the is_power_of_2()
needs replacing with a real sanity check against the recorded alignment.
Otherwise the alignment check is useless in the implicit case and only
the minimum size of the offset matters.
This self-consistency check is further validated by the probe path that
will re-check that the offset is large enough to contain all the
metadata required to enable the device.
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pfn_devs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 816cd9828ca5..33c97076ddf0 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -416,6 +416,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -ENODEV;
}
+ nd_pfn->align = le32_to_cpu(pfn_sb->align);
if (nd_pfn->align > nvdimm_namespace_capacity(ndns)) {
dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n",
nd_pfn->align, nvdimm_namespace_capacity(ndns));
@@ -436,8 +437,8 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -EBUSY;
}
- nd_pfn->align = le32_to_cpu(pfn_sb->align);
- if (!is_power_of_2(offset) || offset < PAGE_SIZE) {
+ if ((nd_pfn->align && !IS_ALIGNED(offset, nd_pfn->align))
+ || !IS_ALIGNED(offset, PAGE_SIZE)) {
dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n",
offset);
return -ENXIO;
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] libnvdimm, dax: fix alignment validation
2016-05-18 23:44 ` Dan Williams
(?)
@ 2016-05-23 9:17 ` Johannes Thumshirn
-1 siblings, 0 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:17 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-kernel, stable, linux-nvdimm
On Wed, May 18, 2016 at 04:44:07PM -0700, Dan Williams wrote:
> Testing the dax-device autodetect support revealed a probe failure with
> the following result:
>
> dax0.1: bad offset: 0x8200000 dax disabled
>
> The original pfn-device implementation inferred the alignment from
> ilog2(offset), now that the alignment is explicit the is_power_of_2()
> needs replacing with a real sanity check against the recorded alignment.
> Otherwise the alignment check is useless in the implicit case and only
> the minimum size of the offset matters.
>
> This self-consistency check is further validated by the probe path that
> will re-check that the offset is large enough to contain all the
> metadata required to enable the device.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] libnvdimm, dax: fix alignment validation
@ 2016-05-23 9:17 ` Johannes Thumshirn
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:17 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm, linux-kernel, stable
On Wed, May 18, 2016 at 04:44:07PM -0700, Dan Williams wrote:
> Testing the dax-device autodetect support revealed a probe failure with
> the following result:
>
> dax0.1: bad offset: 0x8200000 dax disabled
>
> The original pfn-device implementation inferred the alignment from
> ilog2(offset), now that the alignment is explicit the is_power_of_2()
> needs replacing with a real sanity check against the recorded alignment.
> Otherwise the alignment check is useless in the implicit case and only
> the minimum size of the offset matters.
>
> This self-consistency check is further validated by the probe path that
> will re-check that the offset is large enough to contain all the
> metadata required to enable the device.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] libnvdimm, dax: fix alignment validation
@ 2016-05-23 9:17 ` Johannes Thumshirn
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:17 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm, linux-kernel, stable
On Wed, May 18, 2016 at 04:44:07PM -0700, Dan Williams wrote:
> Testing the dax-device autodetect support revealed a probe failure with
> the following result:
>
> dax0.1: bad offset: 0x8200000 dax disabled
>
> The original pfn-device implementation inferred the alignment from
> ilog2(offset), now that the alignment is explicit the is_power_of_2()
> needs replacing with a real sanity check against the recorded alignment.
> Otherwise the alignment check is useless in the implicit case and only
> the minimum size of the offset matters.
>
> This self-consistency check is further validated by the probe path that
> will re-check that the offset is large enough to contain all the
> metadata required to enable the device.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] libnvdimm, dax: autodetect support
2016-05-18 23:44 ` Dan Williams
@ 2016-05-23 9:18 ` Johannes Thumshirn
-1 siblings, 0 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:18 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-kernel, linux-nvdimm
On Wed, May 18, 2016 at 04:44:02PM -0700, Dan Williams wrote:
> For autodetecting a previously established dax configuration we need the
> info block to indicate block-device vs device-dax mode, and we need to
> have the default namespace probe hand-off the configuration to the
> dax_pmem driver.
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] libnvdimm, dax: autodetect support
@ 2016-05-23 9:18 ` Johannes Thumshirn
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:18 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm, linux-kernel
On Wed, May 18, 2016 at 04:44:02PM -0700, Dan Williams wrote:
> For autodetecting a previously established dax configuration we need the
> info block to indicate block-device vs device-dax mode, and we need to
> have the default namespace probe hand-off the configuration to the
> dax_pmem driver.
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2016-05-23 9:18 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 23:43 [PATCH 0/2] libnvdimm, dax: autodetect fixes Dan Williams
2016-05-18 23:43 ` Dan Williams
2016-05-18 23:43 ` Dan Williams
2016-05-18 23:44 ` [PATCH 1/2] libnvdimm, dax: autodetect support Dan Williams
2016-05-18 23:44 ` Dan Williams
2016-05-23 9:18 ` Johannes Thumshirn
2016-05-23 9:18 ` Johannes Thumshirn
2016-05-18 23:44 ` [PATCH 2/2] libnvdimm, dax: fix alignment validation Dan Williams
2016-05-18 23:44 ` Dan Williams
2016-05-18 23:44 ` Dan Williams
2016-05-23 9:17 ` Johannes Thumshirn
2016-05-23 9:17 ` Johannes Thumshirn
2016-05-23 9:17 ` Johannes Thumshirn
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.