Skip to contentSkip to conversation

ndctl: fix the default BTT sector size for reconfig

PATCH In review Vishal Verma 3 participants 3 messages Jan 29, 2018 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl: fix the default BTT sector size for reconfig

reconfig attempted to reuse the 'previous' value for sector-size when reconfiguring to a BTT mode or blk type namespace, but this may not always be valid (for example when coming from a memory mode namespace). Instead, when reconfiguring to BTT or blk, always default to 4096 unless a sector size is explicitly provided.

---
 ndctl/namespace.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
ndctl/namespace.c +4 -6
index c793ba3..ceb9e7a 100644
@@ -244,12 +244,10 @@ static int set_defaults(enum device_action mode)
 			error("invalid sector size: %s\n", param.sector_size);
 			rc = -EINVAL;
 		}
-	} else if (!param.reconfig
-			&& ((param.type && strcmp(param.type, "blk") == 0)
-				|| (param.mode
-					&& strcmp(param.mode, "safe") == 0))) {
-			/* default sector size for blk-type or safe-mode */
-			param.sector_size = "4096";
+	} else if (((param.type && strcmp(param.type, "blk") == 0)
+			|| (param.mode && strcmp(param.mode, "safe") == 0))) {
+		/* default sector size for blk-type or safe-mode */
+		param.sector_size = "4096";
 	}
 
 	return rc;
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 23 lines · Vishal Verma

reconfig attempted to reuse the 'previous' value for sector-size when reconfiguring to a BTT mode or blk type namespace, but this may not always be valid (for example when coming from a memory mode namespace). Instead, when reconfiguring to BTT or blk, always default to 4096 unless a sector size is explicitly provided.

---
 ndctl/namespace.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
ndctl/namespace.c +0 -0
index c793ba3..ceb9e7a 100644
@@ -244,12 +244,10 @@ static int set_defaults(enum device_action mode)
                        error("invalid sector size: %s\n", param.sector_size);
                        rc = -EINVAL;
                }

ndctl/namespace.c static int set_defaults(enum device_action mode) · line 250

Quoted 10 lines
ndctl/namespace.c +4 -6
-       } else if (!param.reconfig
-                       && ((param.type && strcmp(param.type, "blk") == 0)
-                               || (param.mode
-                                       && strcmp(param.mode, "safe") == 0))) {
-                       /* default sector size for blk-type or safe-mode */
-                       param.sector_size = "4096";
+       } else if (((param.type && strcmp(param.type, "blk") == 0)
+                       || (param.mode && strcmp(param.mode, "safe") == 0))) {
+               /* default sector size for blk-type or safe-mode */
+               param.sector_size = "4096";

Looks good to me.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Tested-by on v1 1/1
#2 lore raw
In reply to Vishal Verma
Quoted 11 lines · Vishal Verma

reconfig attempted to reuse the 'previous' value for sector-size when reconfiguring to a BTT mode or blk type namespace, but this may not always be valid (for example when coming from a memory mode namespace). Instead, when reconfiguring to BTT or blk, always default to 4096 unless a sector size is explicitly provided.

Yep, this both allows the btt namespace creation to continue and, if the user does actually specify a bogus sector size, i.e.:

# ./ndctl/ndctl create-namespace -f -e namespace0.0 --mode=sector -l0
failed to reconfigure namespace: Invalid argument

It prevents us from leaving our namespace in a zombie state where it is still there but doesn't show up in 'ndctl list'.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm