summaryrefslogtreecommitdiff
path: root/tools/lvcreate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lvcreate.c')
-rw-r--r--tools/lvcreate.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 4a1534cc2..ff620f456 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -792,6 +792,8 @@ static int _lvcreate_params(struct cmd_context *cmd,
mirror_default_cfg = (arg_uint_value(cmd, stripes_ARG, 1) > 1)
? global_raid10_segtype_default_CFG : global_mirror_segtype_default_CFG;
segtype_str = find_config_tree_str(cmd, mirror_default_cfg, NULL);
+ } else if (arg_is_set(cmd, integrity_ARG)) {
+ segtype_str = SEG_TYPE_NAME_INTEGRITY;
} else
segtype_str = SEG_TYPE_NAME_STRIPED;
@@ -826,6 +828,8 @@ static int _lvcreate_params(struct cmd_context *cmd,
readahead_ARG,\
setactivationskip_ARG,\
test_ARG,\
+ integrity_ARG,\
+ integritysettings_ARG,\
type_ARG
#define CACHE_POOL_ARGS \
@@ -1225,6 +1229,11 @@ static int _lvcreate_params(struct cmd_context *cmd,
}
}
+ if (seg_is_integrity(lp) || seg_is_raid(lp)) {
+ if (!get_integrity_options(cmd, &lp->integrity_arg, &lp->integrity_meta_name, &lp->integrity_settings))
+ return 0;
+ }
+
lcp->pv_count = argc;
lcp->pvs = argv;
@@ -1582,6 +1591,13 @@ static int _check_zero_parameters(struct cmd_context *cmd, struct lvcreate_param
if (seg_is_thin(lp))
return 1;
+ if (seg_is_integrity(lp)) {
+ if (lp->zero && !is_change_activating(lp->activate)) {
+ log_error("Zeroing integrity is not compatible with inactive creation (-an).");
+ return 0;
+ }
+ }
+
/* If there is some problem, buffer will not be empty */
if (dm_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s",
lp->origin_name ? "origin " : "",
@@ -1709,6 +1725,24 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
lp->pool_name ? : "with generated name", lp->vg_name, lp->segtype->name);
}
+ /*
+ * Create an LV to hold integrity metadata when:
+ *
+ * . The user wants external (not internal) metadata. External
+ * is indicated by: no option set (external is default), or
+ * --integrity y|external.
+ *
+ * . The user did not specify an existing metadata LV with
+ * --integritymetadata, saved as lp->integrity_meta_name.
+ */
+ if (seg_is_integrity(lp) && !lp->integrity_meta_name &&
+ (!lp->integrity_arg ||
+ !strcmp(lp->integrity_arg, "external") ||
+ !strcmp(lp->integrity_arg, "y"))) {
+ if (!lv_create_integrity_metadata(cmd, vg, lp))
+ goto_out;
+ }
+
if (vg->lock_type && !strcmp(vg->lock_type, "sanlock")) {
if (!handle_sanlock_lv(cmd, vg)) {
log_error("No space for sanlock lock, extend the internal lvmlock LV.");
@@ -1782,5 +1816,9 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
_destroy_lvcreate_params(&lp);
destroy_processing_handle(cmd, handle);
+
+ if (lp.zero_data_sectors)
+ zero_lv_name(cmd, lp.vg_name, lp.lv_name, lp.zero_data_sectors);
+
return ret;
}