diff mbox

[ndctl,3/8] ndctl: refresh dynamic pfn attributes from a duplicate

Message ID 20160308233643.18628.30522.stgit@dwillia2-desk3.jf.intel.com (mailing list archive)
State Accepted
Commit eeee4e507566
Headers show

Commit Message

Dan Williams March 8, 2016, 11:36 p.m. UTC
When we find a duplicate of an existing ndctl_pfn instance in add_pfn,
it may have a more up to date value of the 'size' or 'resource' because
those values are only valid while the instance is active.  Copy those
updates over before throwing away the duplicate.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c |    2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/lib/libndctl.c b/lib/libndctl.c
index 91e855bf525a..dde3ef5b72e4 100644
--- a/lib/libndctl.c
+++ b/lib/libndctl.c
@@ -3880,6 +3880,8 @@  static int add_pfn(void *parent, int id, const char *pfn_base)
 	free(path);
 	ndctl_pfn_foreach(region, pfn_dup)
 		if (pfn->id == pfn_dup->id) {
+			pfn_dup->resource = pfn->resource;
+			pfn_dup->size = pfn->size;
 			free_pfn(pfn, NULL);
 			return 1;
 		}