@@ -422,8 +422,10 @@ static int write_label_index(struct ndctl_dimm *dimm,
NDCTL_EXPORT int ndctl_dimm_init_labels(struct ndctl_dimm *dimm,
enum ndctl_namespace_version v)
{
+ struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm);
struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm);
struct nvdimm_data *ndd = &dimm->ndd;
+ struct ndctl_region *region;
int i;
if (!ndd->cmd_read) {
@@ -432,6 +434,16 @@ NDCTL_EXPORT int ndctl_dimm_init_labels(struct ndctl_dimm *dimm,
return -EINVAL;
}
+ ndctl_region_foreach(bus, region) {
+ struct ndctl_dimm *match;
+
+ ndctl_dimm_foreach_in_region(region, match)
+ if (match == dimm) {
+ region_flag_refresh(region);
+ break;
+ }
+ }
+
for (i = 0; i < 2; i++) {
int rc;
@@ -152,6 +152,7 @@ struct ndctl_region {
int btts_init;
int pfns_init;
int daxs_init;
+ int refresh_type;
unsigned long long size;
char *region_path;
char *region_buf;
@@ -2400,10 +2401,20 @@ NDCTL_EXPORT int ndctl_region_enable(struct ndctl_region *region)
return -ENXIO;
}
+ if (region->refresh_type) {
+ region->refresh_type = 0;
+ region_set_type(region, region->region_buf);
+ }
+
dbg(ctx, "%s: enabled\n", devname);
return 0;
}
+void region_flag_refresh(struct ndctl_region *region)
+{
+ region->refresh_type = 1;
+}
+
NDCTL_EXPORT void ndctl_region_cleanup(struct ndctl_region *region)
{
free_stale_namespaces(region);
@@ -101,6 +101,8 @@ struct ndctl_dimm {
int format[0];
};
+void region_flag_refresh(struct ndctl_region *region);
+
/**
* struct ndctl_ctx - library user context to find "nd" instances
*
Given that init_labels can change a region from hosting namespaces with an 'nstype' of ND_DEVICE_NAMESPACE_IO to ND_DEVICE_NAMESPACE_PMEM, arrange for ndctl_dimm_init_labels() to trigger the region to refresh these attributes when it is next enabled. Reported-by: Ryon Jensen <ryon.jensen@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- ndctl/lib/dimm.c | 12 ++++++++++++ ndctl/lib/libndctl.c | 11 +++++++++++ ndctl/lib/private.h | 2 ++ 3 files changed, 25 insertions(+)