@@ -534,6 +534,7 @@ static int validate_namespace_options(struct ndctl_region *region,
unsigned long long size_align, units = 1, resource;
struct ndctl_pfn *pfn = NULL;
struct ndctl_dax *dax = NULL;
+ bool default_size = false;
unsigned int ways;
int rc = 0;
@@ -548,10 +549,13 @@ static int validate_namespace_options(struct ndctl_region *region,
p->size = __parse_size64(param.size, &units);
else if (ndns)
p->size = ndctl_namespace_get_size(ndns);
+ else
+ default_size = true;
/*
* Validate available capacity in the create case, in the
- * reconfigure case the capacity is already allocated.
+ * reconfigure case the capacity is already allocated. A default
+ * size will be established from available capacity.
*/
if (!ndns) {
rc = validate_available_capacity(region, p);
@@ -719,6 +723,21 @@ static int validate_namespace_options(struct ndctl_region *region,
return -EINVAL;
}
+ /*
+ * Catch attempts to create sub-16M namespaces to match the
+ * kernel's restriction (see nd_namespace_store())
+ */
+ if (p->size < SZ_16M && p->mode != NDCTL_NS_MODE_RAW) {
+ if (default_size) {
+ debug("%s: insufficient capacity for mode: %s\n",
+ region_name, util_nsmode_name(p->mode));
+ return -EAGAIN;
+ }
+ error("'--size=' must be >= 16MiB for '%s' mode\n",
+ util_nsmode_name(p->mode));
+ return -EINVAL;
+ }
+
if (param.sector_size) {
struct ndctl_btt *btt;
int num, i;
The kernel enforces a minimum size for any "claimed" namespace i.e. any namespace that is wrapped in an address abstraction like the btt or devdax. The "no such device or address" default print is confusing, so replace with an explicit error message. Reported-by: Jane Chu <jane.chu@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- ndctl/namespace.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)