The autolabel operation that enables sector_size settings for namespaces will fail on label-less NVDIMMs. In that case we need to abort attempts to set the sector_size. Typically when specifying a sector_size we are also specifying 'sector' mode so the failure to set a sector_size at the raw namespace level can be ignored.
Reported-by: Maurice A. Saldivar <[email protected]> Signed-off-by: Dan Williams <[email protected]> --- ndctl/namespace.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index bbd404f4abcf..905ebadc6b8d 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -354,8 +354,30 @@ static int setup_namespace(struct ndctl_region *region, try(ndctl_namespace, set_size, ndns, p->size); } - if (p->sector_size && p->sector_size < UINT_MAX) - try(ndctl_namespace, set_sector_size, ndns, p->sector_size); + if (p->sector_size && p->sector_size < UINT_MAX) { + int i, num = ndctl_namespace_get_num_sector_sizes(ndns); + + /* + * With autolabel support we need to recheck if the + * namespace gained sector_size support late in + * namespace_reconfig(). + */ + for (i = 0; i < num; i++) + if (ndctl_namespace_get_supported_sector_size(ndns, i) + == p->sector_size) + break; + if (i < num) + try(ndctl_namespace, set_sector_size, ndns, + p->sector_size); + else if (p->mode == NDCTL_NS_MODE_SAFE) + /* pass, the btt sector_size will override */; + else if (p->sector_size != 512) { + error("%s: sector_size: %ld not supported\n", + ndctl_namespace_get_devname(ndns), + p->sector_size); + return -EINVAL; + } + } uuid_generate(uuid); _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
