summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-08-21 14:08:21 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-02-03 17:40:31 +0100
commitd06899123e08281e8afb0ef1caa34afaf4c52e00 (patch)
treefd88c1f86f459b232584a226d52d3715e1370d20
parent096662e217d296cd97593addd8cf0b760916c1b4 (diff)
downloadlvm2-d06899123e08281e8afb0ef1caa34afaf4c52e00.tar.gz
cmd: add '-r|--removed' switch and wire it up in cmd_context and processing_handle
This patch adds "include_dead_entities" field to struct cmd_context to make it possible for the command to switch between original funcionality where no dead entities are processed and functionality where dead entities are taken into account (and reported or processed further). The switch between these modes is done using the '-r|--removed' switch on command line. The include_dead_entities state is then passed to process_each_* fns using the "include_dead_entities" field within struct processing_handle.
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--tools/args.h1
-rw-r--r--tools/lvmcmdline.c1
-rw-r--r--tools/reporter.c5
-rw-r--r--tools/toollib.c1
-rw-r--r--tools/toollib.h1
6 files changed, 10 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 5fda9a9b5..627af649a 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -128,6 +128,7 @@ struct cmd_context {
unsigned threaded:1; /* set if running within a thread e.g. clvmd */
unsigned independent_metadata_areas:1; /* active formats have MDAs outside PVs */
unsigned unknown_system_id:1;
+ unsigned include_dead_entities:1; /* also process/report/display dead entities */
unsigned include_foreign_vgs:1; /* report/display cmds can reveal foreign VGs */
unsigned include_shared_vgs:1; /* report/display cmds can reveal lockd VGs */
unsigned include_active_foreign_vgs:1; /* cmd should process foreign VGs with active LVs */
diff --git a/tools/args.h b/tools/args.h
index 991d25085..3210a2b24 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -194,6 +194,7 @@ arg(partial_ARG, 'P', "partial", NULL, 0)
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL, 0)
arg(quiet_ARG, 'q', "quiet", NULL, ARG_COUNTABLE)
arg(readahead_ARG, 'r', "readahead", readahead_arg, 0)
+arg(removed_ARG, 'r', "removed", NULL, 0)
arg(resizefs_ARG, 'r', "resizefs", NULL, 0)
arg(reset_ARG, 'R', "reset", NULL, 0)
arg(regionsize_ARG, 'R', "regionsize", size_mb_arg, 0)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 29c1c7eac..828426df2 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1101,6 +1101,7 @@ static int _get_settings(struct cmd_context *cmd)
cmd->ignore_clustered_vgs = arg_is_set(cmd, ignoreskippedcluster_ARG);
cmd->include_foreign_vgs = arg_is_set(cmd, foreign_ARG) ? 1 : 0;
cmd->include_shared_vgs = arg_is_set(cmd, shared_ARG) ? 1 : 0;
+ cmd->include_dead_entities = arg_is_set(cmd, removed_ARG) ? 1 : 0;
/*
* This is set to zero by process_each which wants to print errors
diff --git a/tools/reporter.c b/tools/reporter.c
index 171ca10ec..febd69b41 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -65,6 +65,10 @@ static int _do_info_and_status(struct cmd_context *cmd,
unsigned use_layer = lv_is_thin_pool(lv) ? 1 : 0;
status->lv = lv;
+
+ if (lv_is_dead(lv))
+ return 1;
+
if (do_status) {
if (!(status->seg_status.mem = dm_pool_create("reporter_pool", 1024)))
return_0;
@@ -866,6 +870,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
}
handle.internal_report_for_select = 0;
+ handle.include_dead_entities = cmd->include_dead_entities;
handle.custom_handle = report_handle;
switch (report_type) {
diff --git a/tools/toollib.c b/tools/toollib.c
index c89d8e5c5..8d480312d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1804,6 +1804,7 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)
* *The internal report for select is only needed for non-reporting tools!*
*/
handle->internal_report_for_select = arg_is_set(cmd, select_ARG);
+ handle->include_dead_entities = cmd->include_dead_entities;
return handle;
}
diff --git a/tools/toollib.h b/tools/toollib.h
index fc502b9cd..7dc26f43b 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -70,6 +70,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm);
*/
struct processing_handle {
int internal_report_for_select;
+ int include_dead_entities;
struct selection_handle *selection_handle;
void *custom_handle;
};