From 45eeb70b02df0f196ccd851c23c42fc29d6efb39 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 23 Apr 2013 12:24:17 +0200 Subject: [PATCH] config: merge timestamps Merging multiple config files together needs to know newest (highest) timestamp of merged files. Persistent cache file is being used only in case, the config file is older then .cache file. --- WHATS_NEW | 1 + lib/config/config.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index c1324de2c..4139557b1 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Find newest timestamp of merged config files. Fix assignment order for vg fid for lvm1 and pool format. Fix memleak in dmeventd thin plugin in device list obtaining err path. Add explicit message about unsupported pvmove for thin/thinpool volumes. diff --git a/lib/config/config.c b/lib/config/config.c index e999fc697..0af57d548 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -768,6 +768,7 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft, struct dm_config_node *root = cft->root; struct dm_config_node *cn, *nextn, *oldn, *cn2; const struct dm_config_node *tn; + struct config_file *cf, *cfn; for (cn = newdata->root; cn; cn = nextn) { nextn = cn->sib; @@ -797,6 +798,16 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft, _merge_section(oldn, cn); } + /* + * Persistent filter loading is based on timestamp, + * so we need to know the newest timestamp to make right decision + * whether the .cache isn't older then any of configs + */ + if ((cf = dm_config_get_custom(cft)) && + (cfn = dm_config_get_custom(newdata)) && + cf->timestamp < cfn->timestamp) + cf->timestamp = cfn->timestamp; + return 1; }