return r;
}
-size_t export_vg_to_buffer(struct volume_group *vg, char **buf)
+static size_t _export_vg_to_buffer(struct volume_group *vg, char **buf)
{
return text_vg_export_raw(vg, "", buf);
}
char *buf = NULL;
struct dm_config_tree *vg_cft;
- if (!export_vg_to_buffer(vg, &buf)) {
+ if (!_export_vg_to_buffer(vg, &buf)) {
log_error("Could not format metadata for VG %s.", vg->name);
return NULL;
}
return vg;
}
+#define MAX_DESC_LEN 2048
+
+static char *_build_desc_write(struct cmd_context *cmd, struct volume_group *vg)
+{
+ size_t len = strlen(cmd->cmd_line) + 32;
+ char *desc;
+
+ if (len > MAX_DESC_LEN)
+ len = MAX_DESC_LEN;
+
+ if (!(desc = zalloc(len)))
+ return_NULL;
+
+ vg->write_count++;
+
+ if (vg->write_count == 1)
+ dm_snprintf(desc, len, "Write from %s.", cmd->cmd_line);
+ else
+ dm_snprintf(desc, len, "Write[%u] from %s.", vg->write_count, cmd->cmd_line);
+
+ return desc;
+}
+
/*
* VG metadata updates:
*
new_buf = fidtc->raw_metadata_buf;
new_size = fidtc->raw_metadata_buf_size;
} else {
- new_size = text_vg_export_raw(vg, "", &new_buf);
+ char *desc = _build_desc_write(fid->fmt->cmd, vg);
+ new_size = text_vg_export_raw(vg, desc, &new_buf);
fidtc->raw_metadata_buf = new_buf;
fidtc->raw_metadata_buf_size = new_size;
+ free(desc);
}
if (!new_size || !new_buf) {
/*
* For internal metadata caching.
*/
-size_t export_vg_to_buffer(struct volume_group *vg, char **buf);
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft,
struct format_instance *fid);
struct lvmcache_vginfo *vginfo;
uint32_t seqno; /* Metadata sequence number */
unsigned skip_validate_lock_args : 1;
+ uint32_t write_count; /* count the number of vg_write calls */
/*
* The parsed committed (on-disk) copy of this VG; is NULL if this VG is committed
vgcreate $SHARED "$vg" "${DEVICES[@]}"
lvcreate -n $lv -l 1 -i5 -I256 $vg
+pvck --dump metadata "$dev1" > meta1
+grep "description = " meta1 > desc1
+grep "Write from lvcreate" desc1
+
pvchange -x n "$dev1"
pvchange -x y "$dev1"
vgchange -a n $vg