diff mbox series

[ndctl,v2,14/26] ndctl/namespace: Handle 'create-namespace' in label-less mode

Message ID 156426363655.531577.4504452379578995249.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Superseded
Headers show
Series Improvements for namespace creation/interrogation | expand

Commit Message

Dan Williams July 27, 2019, 9:40 p.m. UTC
A common confusion with ndctl is that 'create-namespace' does not work
in the label-less case. In the label-less case there is no capacity to
allocate as the size if already hard-coded by the region boundary.

However, users typically do something like the following in the
label-less case:

    # ndctl list
    {
      "dev":"namespace1.0",
      "mode":"raw",
      "size":"127.00 GiB (136.37 GB)",
      "sector_size":512,
      "blockdev":"pmem1"
    }

    # ndctl destroy-namespace namespace1.0 -f
    destroyed 1 namespace

    # ndctl create-namespace
    failed to create namespace: Resource temporarily unavailable

In other words they destroy the raw mode namespace that they don't want,
and seek to create a new default configuration namespace. Since there is
no "available_capacity" in the label-less case the 'create' attempt
fails.

Fix this by recognizing that the user wants a default sized namespace
and just reconfigure the raw namespace.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/namespace.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Michal Suchanek Aug. 21, 2019, 12:56 p.m. UTC | #1
Hello,

this patch is marked as superseded in the patchwork.

What is the intended replacement?

Thanks

Michal

On Sat, 27 Jul 2019 14:40:36 -0700
Dan Williams <dan.j.williams@intel.com> wrote:

> A common confusion with ndctl is that 'create-namespace' does not work
> in the label-less case. In the label-less case there is no capacity to
> allocate as the size if already hard-coded by the region boundary.
> 
> However, users typically do something like the following in the
> label-less case:
> 
>     # ndctl list
>     {
>       "dev":"namespace1.0",
>       "mode":"raw",
>       "size":"127.00 GiB (136.37 GB)",
>       "sector_size":512,
>       "blockdev":"pmem1"
>     }
> 
>     # ndctl destroy-namespace namespace1.0 -f
>     destroyed 1 namespace
> 
>     # ndctl create-namespace
>     failed to create namespace: Resource temporarily unavailable
> 
> In other words they destroy the raw mode namespace that they don't want,
> and seek to create a new default configuration namespace. Since there is
> no "available_capacity" in the label-less case the 'create' attempt
> fails.
> 
> Fix this by recognizing that the user wants a default sized namespace
> and just reconfigure the raw namespace.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  ndctl/namespace.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 58fec194ab94..e5a2b1341cdb 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -837,9 +837,13 @@ static int namespace_create(struct ndctl_region *region)
>  		return -EAGAIN;
>  	}
>  
> -	available = ndctl_region_get_max_available_extent(region);
> -	if (available == ULLONG_MAX)
> -		available = ndctl_region_get_available_size(region);
> +	if (ndctl_region_get_nstype(region) == ND_DEVICE_NAMESPACE_IO)
> +		available = ndctl_region_get_size(region);
> +	else {
> +		available = ndctl_region_get_max_available_extent(region);
> +		if (available == ULLONG_MAX)
> +			available = ndctl_region_get_available_size(region);
> +	}
>  	if (!available || p.size > available) {
>  		debug("%s: insufficient capacity size: %llx avail: %llx\n",
>  			devname, p.size, available);
Verma, Vishal L Aug. 21, 2019, 6:03 p.m. UTC | #2
On Wed, 2019-08-21 at 14:56 +0200, Michal Suchánek wrote:
> Hello,
> 
> this patch is marked as superseded in the patchwork.
> 
> What is the intended replacement?
> 

Hi Michal,

The patch was superseded by v3 of the series, and is present in the
latest release (v66):

7966c92 ndctl/namespace: Handle 'create-namespace' in label-less mode

	-Vishal
Michal Suchanek Aug. 21, 2019, 6:19 p.m. UTC | #3
On Wed, 21 Aug 2019 18:03:18 +0000
"Verma, Vishal L" <vishal.l.verma@intel.com> wrote:

> On Wed, 2019-08-21 at 14:56 +0200, Michal Suchánek wrote:
> > Hello,
> > 
> > this patch is marked as superseded in the patchwork.
> > 
> > What is the intended replacement?
> >   
> 
> Hi Michal,
> 
> The patch was superseded by v3 of the series, and is present in the
> latest release (v66):
> 
> 7966c92 ndctl/namespace: Handle 'create-namespace' in label-less mode
> 
> 	-Vishal

I see, it was already merged as part of updated series. Missed that.

Thanks

Michal
diff mbox series

Patch

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 58fec194ab94..e5a2b1341cdb 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -837,9 +837,13 @@  static int namespace_create(struct ndctl_region *region)
 		return -EAGAIN;
 	}
 
-	available = ndctl_region_get_max_available_extent(region);
-	if (available == ULLONG_MAX)
-		available = ndctl_region_get_available_size(region);
+	if (ndctl_region_get_nstype(region) == ND_DEVICE_NAMESPACE_IO)
+		available = ndctl_region_get_size(region);
+	else {
+		available = ndctl_region_get_max_available_extent(region);
+		if (available == ULLONG_MAX)
+			available = ndctl_region_get_available_size(region);
+	}
 	if (!available || p.size > available) {
 		debug("%s: insufficient capacity size: %llx avail: %llx\n",
 			devname, p.size, available);