ndctl: fix the default BTT sector size for reconfig
Vishal Verma
maintainerPATCH 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
@@ -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
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.
Cc Dan Williams <[email protected]>Reported-by Ross Zwisler <[email protected]>Tested-by Dave Jiang <[email protected]>Reviewed-by Dave Jiang <[email protected]>Signed-off-by Vishal Verma <[email protected]>--- ndctl/namespace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)ndctl/namespace.c +0
-0@@ -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
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.
Cc Dan Williams <[email protected]>Reported-by Ross Zwisler <[email protected]>Tested-by Dave Jiang <[email protected]>Reviewed-by Dave Jiang <[email protected]>Signed-off-by Vishal Verma <[email protected]>
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