From 04d9f13fa609446f856409d97dd9264b6718b925 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 10 May 2024 00:25:39 +0200 Subject: [PATCH] lvconvert: vdo control for signature wiping When converting volumes to be used for thin-pool with VDO, allow users to control wipesingature behaviour. By default volumes should be checked against signature, and if they are present, we promt user whether he wants to process with conversion and lose i.e. filesystem present on such volume. Users that want to bypass prompt in script can use either --yes or they can disable wipe signature -Wn. --- tools/lvconvert.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 674bfe537..4899bc56c 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -123,6 +123,14 @@ static int _striped_type_requested(const char *type_str) return (!strcmp(type_str, SEG_TYPE_NAME_STRIPED) || _linear_type_requested(type_str)); } +static int _get_wipe_signatures(struct cmd_context *cmd) +{ + /* use option from cmdline and fallback to lvm.conf settings */ + return arg_is_set(cmd, wipesignatures_ARG) ? + arg_int_value(cmd, wipesignatures_ARG, 0) : + find_config_tree_bool(cmd, allocation_wipe_signatures_when_zeroing_new_lvs_CFG, NULL); +} + static int _read_conversion_type(struct cmd_context *cmd, struct lvconvert_params *lp) { @@ -3104,7 +3112,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd, struct vdo_convert_params vcp = { .activate = CHANGE_AN, .do_zero = 1, - .do_wipe_signatures = 1, + .do_wipe_signatures = _get_wipe_signatures(cmd), .force = arg_count(cmd, force_ARG), .yes = arg_count(cmd, yes_ARG), }; @@ -5523,7 +5531,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd, arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0)), vg->extent_size), .do_zero = arg_int_value(cmd, zero_ARG, 1), - .do_wipe_signatures = 1, + .do_wipe_signatures = _get_wipe_signatures(cmd), .yes = arg_count(cmd, yes_ARG), .force = arg_count(cmd, force_ARG) };