summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/metadata/lv.h1
-rw-r--r--tools/commands.h2
-rw-r--r--tools/toollib.c19
-rw-r--r--tools/tools.h1
4 files changed, 19 insertions, 4 deletions
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 9f871d67c..dbf5c7461 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -61,6 +61,7 @@ struct logical_volume {
uint64_t timestamp;
unsigned new_lock_args:1;
+ unsigned process_specific:1; /* lv is identified specifically for processing */
const char *hostname;
const char *lock_args;
};
diff --git a/tools/commands.h b/tools/commands.h
index baf89b15f..5475c47c2 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -658,7 +658,7 @@ xx(lvreduce,
xx(lvremove,
"Remove logical volume(s) from the system",
- ALL_VGS_IS_DEFAULT, /* all VGs only with --select */
+ ALL_VGS_IS_DEFAULT | CONFIRM_UNLESS_SPECIFIC, /* all VGs only with --select */
"lvremove\n"
"\t[-A|--autobackup y|n]\n"
"\t[--commandprofile ProfileName]\n"
diff --git a/tools/toollib.c b/tools/toollib.c
index 9127d85cd..ed598b64a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2352,6 +2352,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct lv_list *final_lvl;
struct glv_list *glvl, *tglvl;
int do_report_ret_code = 1;
+ int lv_is_specific = 0;
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_LV);
@@ -2435,9 +2436,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (arg_is_set(cmd, all_ARG) ||
(lvargs_supplied && str_list_match_item(arg_lvnames, lvl->lv->name))) {
log_very_verbose("Processing lockd_sanlock_lv %s/%s.", vg->name, lvl->lv->name);
- } else {
+ } else
continue;
- }
}
/*
@@ -2449,15 +2449,19 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
*/
process_lv = process_all;
+ lv_is_specific = 0;
if (lvargs_supplied && str_list_match_item(arg_lvnames, lvl->lv->name)) {
/* Remove LV from list of unprocessed LV names */
str_list_del(arg_lvnames, lvl->lv->name);
process_lv = 1;
+ lv_is_specific = 1;
}
- if (!process_lv && tags_supplied && str_list_match_list(tags_in, &lvl->lv->tags, NULL))
+ if (!process_lv && tags_supplied && str_list_match_list(tags_in, &lvl->lv->tags, NULL)) {
process_lv = 1;
+ lv_is_specific = 1;
+ }
process_lv = process_lv && select_match_lv(cmd, handle, vg, lvl->lv) && _select_matches(handle);
@@ -2477,6 +2481,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
goto_out;
}
final_lvl->lv = lvl->lv;
+ final_lvl->lv->process_specific = lv_is_specific;
dm_list_add(&final_lvs, &final_lvl->list);
}
log_set_report_object_name_and_id(NULL, NULL);
@@ -3829,6 +3834,14 @@ int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
force_t force = (force_t) arg_count(cmd, force_ARG)
? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
+ if ((force == PROMPT) &&
+ !lv->process_specific &&
+ (cmd->command->flags & CONFIRM_UNLESS_SPECIFIC)) {
+ if (yes_no_prompt("Remove LV %s that was not named directly? [y/n]: ",
+ display_lvname(lv)) == 'n')
+ return ECMD_PROCESSED;
+ }
+
if (!lv_remove_with_dependencies(cmd, lv, force, 0))
return_ECMD_FAILED;
diff --git a/tools/tools.h b/tools/tools.h
index f6d224fb1..9b79919ca 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -118,6 +118,7 @@ struct arg_value_group_list {
#define ENABLE_DUPLICATE_DEVS 0x00000400
/* Command does not accept tags as args. */
#define DISALLOW_TAG_ARGS 0x00000800
+#define CONFIRM_UNLESS_SPECIFIC 0x00001000
/* a register of the lvm commands */
struct command {