aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.c
diff options
context:
space:
mode:
authorDmitry Krivenok <krivenok.dmitry@gmail.com>2015-12-01 16:48:12 -0500
committerDan Williams <dan.j.williams@intel.com>2015-12-08 19:27:30 -0500
commitbd26d0d0ce7434a86dde61a7c65c94fe3801d8f6 (patch)
tree3dd255a6a7b645b098dd5e8fb2977e353a6c569a /drivers/nvdimm/namespace_devs.c
parent527e9316f8ec44bd53d90fb9f611fa7ffff52bb9 (diff)
nvdimm: improve diagnosibility of namespaces
In order to bind namespace to the driver user must first set all mandatory attributes in the following order: - uuid - size - sector_size (for blk namespace only) If the order is wrong, then user either won't be able to set the attribute or bind the namespace. This simple patch improves diagnosibility of common operations with namespaces by printing some details about the error instead of failing silently. Below are examples of error messages (assuming dyndbg is enabled for nvdimms): [/]# echo 4194304 > /sys/bus/nd/devices/region5/namespace5.0/size [ 288.372612] nd namespace5.0: __size_store: uuid not set [ 288.374839] nd namespace5.0: size_store: 400000 fail (-6) sh: write error: No such device or address [/]# [/]# echo namespace5.0 > /sys/bus/nd/drivers/nd_blk/bind [ 554.671648] nd_blk namespace5.0: nvdimm_namespace_common_probe: sector size not set [ 554.674688] ndbus1: nd_blk.probe(namespace5.0) = -19 sh: write error: No such device [/]# Signed-off-by: Dmitry V. Krivenok <krivenok.dmitry@gmail.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 0955b2cb10fe..f981177524a1 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -791,6 +791,15 @@ static void nd_namespace_pmem_set_size(struct nd_region *nd_region,
791 res->end = nd_region->ndr_start + size - 1; 791 res->end = nd_region->ndr_start + size - 1;
792} 792}
793 793
794static bool uuid_not_set(const u8 *uuid, struct device *dev, const char *where)
795{
796 if (!uuid) {
797 dev_dbg(dev, "%s: uuid not set\n", where);
798 return true;
799 }
800 return false;
801}
802
794static ssize_t __size_store(struct device *dev, unsigned long long val) 803static ssize_t __size_store(struct device *dev, unsigned long long val)
795{ 804{
796 resource_size_t allocated = 0, available = 0; 805 resource_size_t allocated = 0, available = 0;
@@ -820,8 +829,12 @@ static ssize_t __size_store(struct device *dev, unsigned long long val)
820 * We need a uuid for the allocation-label and dimm(s) on which 829 * We need a uuid for the allocation-label and dimm(s) on which
821 * to store the label. 830 * to store the label.
822 */ 831 */
823 if (!uuid || nd_region->ndr_mappings == 0) 832 if (uuid_not_set(uuid, dev, __func__))
824 return -ENXIO; 833 return -ENXIO;
834 if (nd_region->ndr_mappings == 0) {
835 dev_dbg(dev, "%s: not associated with dimm(s)\n", __func__);
836 return -ENXIO;
837 }
825 838
826 div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); 839 div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder);
827 if (remainder) { 840 if (remainder) {
@@ -1343,14 +1356,19 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
1343 struct nd_namespace_pmem *nspm; 1356 struct nd_namespace_pmem *nspm;
1344 1357
1345 nspm = to_nd_namespace_pmem(&ndns->dev); 1358 nspm = to_nd_namespace_pmem(&ndns->dev);
1346 if (!nspm->uuid) { 1359 if (uuid_not_set(nspm->uuid, &ndns->dev, __func__))
1347 dev_dbg(&ndns->dev, "%s: uuid not set\n", __func__);
1348 return ERR_PTR(-ENODEV); 1360 return ERR_PTR(-ENODEV);
1349 }
1350 } else if (is_namespace_blk(&ndns->dev)) { 1361 } else if (is_namespace_blk(&ndns->dev)) {
1351 struct nd_namespace_blk *nsblk; 1362 struct nd_namespace_blk *nsblk;
1352 1363
1353 nsblk = to_nd_namespace_blk(&ndns->dev); 1364 nsblk = to_nd_namespace_blk(&ndns->dev);
1365 if (uuid_not_set(nsblk->uuid, &ndns->dev, __func__))
1366 return ERR_PTR(-ENODEV);
1367 if (!nsblk->lbasize) {
1368 dev_dbg(&ndns->dev, "%s: sector size not set\n",
1369 __func__);
1370 return ERR_PTR(-ENODEV);
1371 }
1354 if (!nd_namespace_blk_validate(nsblk)) 1372 if (!nd_namespace_blk_validate(nsblk))
1355 return ERR_PTR(-ENODEV); 1373 return ERR_PTR(-ENODEV);
1356 } 1374 }