diff options
author | Milan Broz <mbroz@redhat.com> | 2009-02-09 09:45:49 +0000 |
---|---|---|
committer | Milan Broz <mbroz@redhat.com> | 2009-02-09 09:45:49 +0000 |
commit | ea0cdd28c1cdf282b535e059a2f94510c84387d9 (patch) | |
tree | 30e0b64578f0c67ca42448794df3115233b8c981 /tools | |
parent | 284f4496c3eead8a0f676f3b69aff6458b76bc06 (diff) | |
download | lvm2-ea0cdd28c1cdf282b535e059a2f94510c84387d9.tar.gz lvm2-ea0cdd28c1cdf282b535e059a2f94510c84387d9.tar.xz lvm2-ea0cdd28c1cdf282b535e059a2f94510c84387d9.zip |
Separate PV label attributes which do not need parse metadata when reporting.
When reporting explicitly label attributes (pv_uuid for example), we do not
need to read metadata.
This patch separate the label fileds and removes scan_vgs_for_pvs
in process_each_pv() if not needed.
(There should be no user visible change in output.)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pvdisplay.c | 2 | ||||
-rw-r--r-- | tools/pvresize.c | 2 | ||||
-rw-r--r-- | tools/reporter.c | 32 | ||||
-rw-r--r-- | tools/toollib.c | 8 | ||||
-rw-r--r-- | tools/toollib.h | 6 | ||||
-rw-r--r-- | tools/vgreduce.c | 4 |
6 files changed, 38 insertions, 16 deletions
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c index 93333f4c..0c76910a 100644 --- a/tools/pvdisplay.c +++ b/tools/pvdisplay.c @@ -110,6 +110,6 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - return process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, NULL, + return process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, 0, NULL, _pvdisplay_single); } diff --git a/tools/pvresize.c b/tools/pvresize.c index 13c37616..f0a6471b 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -226,7 +226,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv) params.done = 0; params.total = 0; - ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, ¶ms, + ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, 0, ¶ms, _pvresize_single); log_print("%d physical volume(s) resized / %d physical volume(s) " diff --git a/tools/reporter.c b/tools/reporter.c index d44f108f..7943e26e 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -158,6 +158,15 @@ out: return ret; } +static int _label_single(struct cmd_context *cmd, struct volume_group *vg, + struct physical_volume *pv, void *handle) +{ + if (!report_object(handle, vg, NULL, pv, NULL, NULL)) + return ECMD_FAILED; + + return ECMD_PROCESSED; +} + static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, int consistent __attribute((unused)), @@ -211,7 +220,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, columns_as_rows = find_config_tree_int(cmd, "report/columns_as_rows", DEFAULT_REP_COLUMNS_AS_ROWS); - args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0; + args_are_pvs = (report_type == PVS || + report_type == LABEL || + report_type == PVSEGS) ? 1 : 0; switch (report_type) { case LVS: @@ -238,6 +249,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, "report/vgs_cols_verbose", DEFAULT_VGS_COLS_VERB); break; + case LABEL: case PVS: keys = find_config_tree_str(cmd, "report/pvs_sort", DEFAULT_PVS_SORT); @@ -333,7 +345,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type |= LVS; if (report_type & PVSEGS) report_type |= PVS; - if ((report_type & LVS) && (report_type & PVS) && !args_are_pvs) { + if ((report_type & LVS) && (report_type & (PVS | LABEL)) && !args_are_pvs) { log_error("Can't report LV and PV fields at the same time"); dm_report_free(report_handle); return ECMD_FAILED; @@ -341,8 +353,10 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, /* Change report type if fields specified makes this necessary */ if ((report_type & PVSEGS) || - ((report_type & PVS) && (report_type & LVS))) + ((report_type & (PVS | LABEL)) && (report_type & LVS))) report_type = PVSEGS; + else if ((report_type & LABEL) && (report_type & VGS)) + report_type = PVS; else if (report_type & PVS) report_type = PVS; else if (report_type & SEGS) @@ -359,10 +373,14 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle, &_vgs_single); break; + case LABEL: + r = process_each_pv(cmd, argc, argv, NULL, LCK_NONE, + 1, report_handle, &_label_single); + break; case PVS: if (args_are_pvs) r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, - report_handle, &_pvs_single); + 0, report_handle, &_pvs_single); else r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle, &_pvs_in_vg); @@ -374,7 +392,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, case PVSEGS: if (args_are_pvs) r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, - report_handle, &_pvsegs_single); + 0, report_handle, &_pvsegs_single); else r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle, &_pvsegs_in_vg); @@ -411,7 +429,7 @@ int pvs(struct cmd_context *cmd, int argc, char **argv) if (arg_count(cmd, segments_ARG)) type = PVSEGS; else - type = PVS; + type = LABEL; return _report(cmd, argc, argv, type); } diff --git a/tools/toollib.c b/tools/toollib.c index d8b32a56..c51bc95e 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -621,7 +621,8 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle, } int process_each_pv(struct cmd_context *cmd, int argc, char **argv, - struct volume_group *vg, uint32_t lock_type, void *handle, + struct volume_group *vg, uint32_t lock_type, + int scan_label_only, void *handle, int (*process_single) (struct cmd_context * cmd, struct volume_group * vg, struct physical_volume * pv, @@ -690,7 +691,8 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, * PV on the system. */ if (!scanned && is_orphan(pv)) { - if (!scan_vgs_for_pvs(cmd)) { + if (!scan_label_only && + !scan_vgs_for_pvs(cmd)) { stack; ret_max = ECMD_FAILED; continue; diff --git a/tools/toollib.h b/tools/toollib.h index 915e3f30..09c58f77 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -34,11 +34,13 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int consistent, void *handle)); int process_each_pv(struct cmd_context *cmd, int argc, char **argv, - struct volume_group *vg, uint32_t lock_type, void *handle, + struct volume_group *vg, uint32_t lock_type, + int scan_label_only, void *handle, int (*process_single) (struct cmd_context * cmd, struct volume_group * vg, struct physical_volume * pv, void *handle)); + int process_each_segment_in_pv(struct cmd_context *cmd, struct volume_group *vg, struct physical_volume *pv, diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 79bf3e09..3b20a61d 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -584,7 +584,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) /* FIXME: Pass private struct through to all these functions */ /* and update in batch here? */ - ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, NULL, + ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, 0, NULL, _vgreduce_single); } |