#include "lib/mm/xlate.h"
#include "lib/label/label.h"
#include "lib/cache/lvmcache.h"
+#include "libdaemon/client/config-util.h"
#include <unistd.h>
#include <limits.h>
struct metadata_area *mda)
{
char desc[2048];
+ struct dm_config_tree *cft;
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
struct text_fid_context *fidtc = (struct text_fid_context *) fid->private;
struct raw_locn *rlocn_old;
fidtc->write_buf = write_buf;
fidtc->write_buf_size = write_buf_size;
fidtc->new_metadata_size = new_size;
+
+ /* Immediatelly reuse existing buffer for parsing metadata back.
+ * Such VG is then used for as precommitted VG and later committed VG.
+ *
+ * 'Lazy' creation of such VG might improve performance, but we
+ * lose important validation that written metadata can be parsed. */
+ if (!(cft = config_tree_from_string_without_dup_node_check(write_buf))) {
+ log_error("Error parsing metadata for VG %s.", vg->name);
+ goto out;
+ }
+ release_vg(vg->vg_precommitted);
+ vg->vg_precommitted = import_vg_from_config_tree(vg->cmd, vg->fid, cft);
+ dm_config_destroy(cft);
+ if (!vg->vg_precommitted)
+ goto_out;
}
if (!new_size || !write_buf) {
vg->vg_precommitted = NULL;
}
-/*
- * Update content of precommitted VG
- *
- * TODO: Optimize in the future, since lvmetad needs similar
- * config tree processing in lvmetad_vg_update().
- */
-static int _vg_update_embedded_copy(struct volume_group *vg, struct volume_group **vg_embedded)
-{
- struct dm_config_tree *cft;
-
- _vg_wipe_cached_precommitted(vg);
-
- /* Copy the VG using an export followed by import */
- if (!(cft = export_vg_to_config_tree(vg)))
- return_0;
-
- if (!(*vg_embedded = import_vg_from_config_tree(vg->cmd, vg->fid, cft))) {
- dm_config_destroy(cft);
- return_0;
- }
-
- dm_config_destroy(cft);
-
- return 1;
-}
-
int lv_has_unknown_segments(const struct logical_volume *lv)
{
struct lv_segment *seg;
}
}
- if (!_vg_update_embedded_copy(vg, &vg->vg_precommitted)) /* prepare precommited */
- return_0;
-
lockd_vg_update(vg);
return 1;