Skip to contentSkip to conversation

namespace/create: Don't create multiple namespace unless greedy

PATCH Superseded Santosh Sivaraj 2 participants 2 messages Dec 4, 2019 libnvdimm: non-volatile memory device

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 namespace/create: Don't create multiple namespace unless greedy

From: Vaibhav Jain <[email protected]>

Currently create-namespace creates two namespaces with the '-f' option even without the greedy flag. This behavior got introduced by c75f7236d. The earlier behaviour was to create one namespace even with the '-f' flag. The earlier behavior:

$ sudo ./ndctl/ndctl create-namespace -s 16M -f
[sudo] password for santosh:
{
  "dev":"namespace1.14",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"03f6b921-7684-4736-b2be-87f021996e52",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem1.14"
}

After greedy option was introduced:

$ sudo ./ndctl/ndctl create-namespace -s 16M -f
{
  "dev":"namespace1.8",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"1a9d6610-558b-454e-8b95-76c6201798cb",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem1.8"
}
{
  "dev":"namespace0.3",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"eed9d28b-69a2-4c7c-9503-24e8aee87b1e",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem0.3"
}

If no region or '-c' flag is specified bail out if the creation was successful.

Fixes c75f7236d (ndctl/namespace: add a --continue option to create namespaces greedily)
---
 ndctl/namespace.c | 2 ++
 1 file changed, 2 insertions(+)
ndctl/namespace.c +2 -0
index 7fb0007..8098456 100644
@@ -1392,6 +1392,8 @@ static int do_xaction_namespace(const char *namespace,
 				if (force) {
 					if (rc)
 						saved_rc = rc;
+					else if (!param.region)
+							return rc;
 					continue;
 				}
 				return rc;
Signature · 4 lines
2.23.0
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#1 lore raw
Quoted 59 lines · Santosh Sivaraj

From: Vaibhav Jain <[email protected]>

Currently create-namespace creates two namespaces with the '-f' option even without the greedy flag. This behavior got introduced by c75f7236d. The earlier behaviour was to create one namespace even with the '-f' flag. The earlier behavior:

$ sudo ./ndctl/ndctl create-namespace -s 16M -f
[sudo] password for santosh:
{
  "dev":"namespace1.14",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"03f6b921-7684-4736-b2be-87f021996e52",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem1.14"
}

After greedy option was introduced:

$ sudo ./ndctl/ndctl create-namespace -s 16M -f
{
  "dev":"namespace1.8",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"1a9d6610-558b-454e-8b95-76c6201798cb",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem1.8"
}
{
  "dev":"namespace0.3",
  "mode":"fsdax",
  "map":"dev",
  "size":"14.00 MiB (14.68 MB)",
  "uuid":"eed9d28b-69a2-4c7c-9503-24e8aee87b1e",
  "sector_size":512,
  "align":65536,
  "blockdev":"pmem0.3"
}

If no region or '-c' flag is specified bail out if the creation was successful.

Fixes c75f7236d (ndctl/namespace: add a --continue option to create namespaces greedily)
---
 ndctl/namespace.c | 2 ++
 1 file changed, 2 insertions(+)
ndctl/namespace.c +0 -0
index 7fb0007..8098456 100644

ndctl/namespace.c static int do_xaction_namespace(const char *namespace, · line 1396

Quoted 5 lines
ndctl/namespace.c +2 -0
@@ -1392,6 +1392,8 @@ static int do_xaction_namespace(const char *namespace,
                                if (force) {
                                        if (rc)
                                                saved_rc = rc;
+                                       else if (!param.region)
+                                                       return rc;

I see the bug, but the fix looks wrong to me. --force has no meaning in this case. I'd rather just clean-up --force to be ignored when neither "-c" nor "-e" are specified.
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]