|
Jeff Moyer |
2c91dc |
From fe626a8a8a1b1bc94ea95c693ec672109909e3dc Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Redhairer Li <redhairer.li@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Thu, 28 Jan 2021 22:03:39 +0800
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 008/217] ndctl/namespace: Fix disable-namespace accounting
|
|
Jeff Moyer |
2c91dc |
relative to seed devices
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Seed namespaces are included in "ndctl disable-namespace all". However
|
|
Jeff Moyer |
2c91dc |
since the user never "creates" them it is surprising to see
|
|
Jeff Moyer |
2c91dc |
"disable-namespace" report 1 more namespace relative to the number that
|
|
Jeff Moyer |
2c91dc |
have been created. Catch attempts to disable a zero-sized namespace:
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Before:
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.0",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.1",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1.1"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.2",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1.2"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
disabled 4 namespaces
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
After:
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.0",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.3",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1.3"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
"dev":"namespace1.1",
|
|
Jeff Moyer |
2c91dc |
"size":"492.00 MiB (515.90 MB)",
|
|
Jeff Moyer |
2c91dc |
"blockdev":"pmem1.1"
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
disabled 3 namespaces
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Redhairer Li <redhairer.li@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/linux-nvdimm/20210128140339.3080-1-redhairer.li@intel.com/
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
ndctl/lib/libndctl.c | 10 ++++++++--
|
|
Jeff Moyer |
2c91dc |
ndctl/namespace.c | 8 ++++----
|
|
Jeff Moyer |
2c91dc |
ndctl/region.c | 2 +-
|
|
Jeff Moyer |
2c91dc |
3 files changed, 13 insertions(+), 7 deletions(-)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
|
|
Jeff Moyer |
2c91dc |
index 36fb6fe..2f6d806 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/lib/libndctl.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/lib/libndctl.c
|
|
Jeff Moyer |
2c91dc |
@@ -4602,6 +4602,7 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
const char *bdev = NULL;
|
|
Jeff Moyer |
2c91dc |
char path[50];
|
|
Jeff Moyer |
2c91dc |
int fd;
|
|
Jeff Moyer |
2c91dc |
+ unsigned long long size = ndctl_namespace_get_size(ndns);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
if (pfn && ndctl_pfn_is_enabled(pfn))
|
|
Jeff Moyer |
2c91dc |
bdev = ndctl_pfn_get_block_device(pfn);
|
|
Jeff Moyer |
2c91dc |
@@ -4631,8 +4632,13 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
devname, bdev, strerror(errno));
|
|
Jeff Moyer |
2c91dc |
return -errno;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
- } else
|
|
Jeff Moyer |
2c91dc |
- ndctl_namespace_disable_invalidate(ndns);
|
|
Jeff Moyer |
2c91dc |
+ } else {
|
|
Jeff Moyer |
2c91dc |
+ if (size == 0)
|
|
Jeff Moyer |
2c91dc |
+ /* No disable necessary due to no capacity allocated */
|
|
Jeff Moyer |
2c91dc |
+ return 1;
|
|
Jeff Moyer |
2c91dc |
+ else
|
|
Jeff Moyer |
2c91dc |
+ ndctl_namespace_disable_invalidate(ndns);
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
return 0;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
|
|
Jeff Moyer |
2c91dc |
index 0c8df9f..1feb74d 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/namespace.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/namespace.c
|
|
Jeff Moyer |
2c91dc |
@@ -1125,7 +1125,7 @@ static int namespace_prep_reconfig(struct ndctl_region *region,
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_namespace_disable_safe(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
ndctl_namespace_set_enforce_mode(ndns, NDCTL_NS_MODE_RAW);
|
|
Jeff Moyer |
2c91dc |
@@ -1431,7 +1431,7 @@ static int dax_clear_badblocks(struct ndctl_dax *dax)
|
|
Jeff Moyer |
2c91dc |
return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_namespace_disable_safe(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
error("%s: unable to disable namespace: %s\n", devname,
|
|
Jeff Moyer |
2c91dc |
strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
@@ -1455,7 +1455,7 @@ static int pfn_clear_badblocks(struct ndctl_pfn *pfn)
|
|
Jeff Moyer |
2c91dc |
return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_namespace_disable_safe(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
error("%s: unable to disable namespace: %s\n", devname,
|
|
Jeff Moyer |
2c91dc |
strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
@@ -1478,7 +1478,7 @@ static int raw_clear_badblocks(struct ndctl_namespace *ndns)
|
|
Jeff Moyer |
2c91dc |
return -ENXIO;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_namespace_disable_safe(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc) {
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0) {
|
|
Jeff Moyer |
2c91dc |
error("%s: unable to disable namespace: %s\n", devname,
|
|
Jeff Moyer |
2c91dc |
strerror(-rc));
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
diff --git a/ndctl/region.c b/ndctl/region.c
|
|
Jeff Moyer |
2c91dc |
index 3edb9b3..4552c4a 100644
|
|
Jeff Moyer |
2c91dc |
--- a/ndctl/region.c
|
|
Jeff Moyer |
2c91dc |
+++ b/ndctl/region.c
|
|
Jeff Moyer |
2c91dc |
@@ -70,7 +70,7 @@ static int region_action(struct ndctl_region *region, enum device_action mode)
|
|
Jeff Moyer |
2c91dc |
case ACTION_DISABLE:
|
|
Jeff Moyer |
2c91dc |
ndctl_namespace_foreach(region, ndns) {
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_namespace_disable_safe(ndns);
|
|
Jeff Moyer |
2c91dc |
- if (rc)
|
|
Jeff Moyer |
2c91dc |
+ if (rc < 0)
|
|
Jeff Moyer |
2c91dc |
return rc;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
rc = ndctl_region_disable_invalidate(region);
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|