]> sourceware.org Git - lvm2.git/commitdiff
Separate PV label attributes which do not need parse metadata when reporting.
authorMilan Broz <mbroz@redhat.com>
Mon, 9 Feb 2009 09:45:49 +0000 (09:45 +0000)
committerMilan Broz <mbroz@redhat.com>
Mon, 9 Feb 2009 09:45:49 +0000 (09:45 +0000)
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.)

WHATS_NEW
lib/report/columns.h
lib/report/report.c
lib/report/report.h
libdm/libdm-report.c
tools/pvdisplay.c
tools/pvresize.c
tools/reporter.c
tools/toollib.c
tools/toollib.h
tools/vgreduce.c

index d3e1996c716296c1d3621fd2cb8d2616965fb613..3454dea8b7b32e3c7b01b70ba3cea2b0339809a8 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Separate PV label attributes which do not need parse metadata when reporting.
   Remove external dependency on the 'cut' command in fsadm.
   Fix pvs segfault when pv mda attributes requested for not available PV.
   Add support for ext4 resize in fsadm.
index a8f380604d41cea09968dc3a104c5a9ae8bd15eb..18c83fababa2c74e37969c96844ccf3c8c74d654 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-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.
  *
@@ -38,21 +38,22 @@ FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.")
 FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.")
 FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.")
 
-FIELD(PVS, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.")
-FIELD(PVS, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.")
+FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.")
+FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.")
+FIELD(LABEL, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.")
+FIELD(LABEL, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.")
+FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.")
+FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")
+FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.")
+
 FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current units.")
-FIELD(PVS, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.")
-FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.")
 FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.")
 FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used", "Total amount of allocated space in current units.")
-FIELD(PVS, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.")
 FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes - see man page.")
 FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.")
 FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.")
 FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.")
 FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.")
-FIELD(PVS, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")
-FIELD(PVS, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.")
 
 FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.")
 FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.")
index 729ac489940b7a272111c8778c9954de5042a610..f603eeb7921e1870934ee8804b9b68eaebbd4203 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-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.
  *
@@ -1111,6 +1111,7 @@ static const struct dm_report_object_type _report_types[] = {
        { VGS, "Volume Group", "vg_", _obj_get_vg },
        { LVS, "Logical Volume", "lv_", _obj_get_lv },
        { PVS, "Physical Volume", "pv_", _obj_get_pv },
+       { LABEL, "Physical Volume Label", "pv_", _obj_get_pv },
        { SEGS, "Logical Volume Segment", "seg_", _obj_get_seg },
        { PVSEGS, "Physical Volume Segment", "pvseg_", _obj_get_pvseg },
        { 0, "", "", NULL },
index 5d8d569bea85bfef0be17bdd29161ea8bdc9b44a..26cc2f7b35bc48ce7e65fc96890f3314579db1f1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
 
 #include "metadata-exported.h"
 
-typedef enum { LVS = 1, PVS = 2, VGS = 4, SEGS = 8, PVSEGS = 16 } report_type_t;
+typedef enum {
+       LVS     = 1,
+       PVS     = 2,
+       VGS     = 4,
+       SEGS    = 8,
+       PVSEGS  = 16,
+       LABEL   = 32
+} report_type_t;
 
 struct field;
 struct report_handle;
index 0c5ee6d70b6b2dcce08f3bf269b8baa00859d36c..6784a11e34edbbcd207c2c1c8ae71ae985b25299 100644 (file)
@@ -365,9 +365,22 @@ static uint32_t _all_match(struct dm_report *rh, const char *field, size_t flen)
 {
        size_t prefix_len;
        const struct dm_report_object_type *t;
-
-       if (!strncasecmp(field, "all", 3) && flen == 3)
-               return rh->report_types;
+       char prefixed_all[32];
+
+       if (!strncasecmp(field, "all", 3) && flen == 3) {
+               if (strlen(rh->field_prefix)) {
+                       strcpy(prefixed_all, rh->field_prefix);
+                       strcat(prefixed_all, "all");
+                       /*
+                        * Add also prefix to receive all attributes
+                        * (e.g.LABEL/PVS use the same prefix)
+                        */
+                       return rh->report_types |
+                              _all_match(rh, prefixed_all,
+                                         strlen(prefixed_all));
+               } else
+                       return rh->report_types;
+       }
 
        for (t = rh->types; t->data_fn; t++) {
                prefix_len = strlen(t->prefix);
index 93333f4c1276dd560383b2816e038cfdf471df15..0c76910a8848731f0d8e556956eabf0770b3ab3e 100644 (file)
@@ -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);
 }
index 13c37616601df8959793c62e10d94795b2c93144..f0a6471bca46e5d624a01e86ea5d27d24d5be4ea 100644 (file)
@@ -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, &params,
+       ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, 0, &params,
                              _pvresize_single);
 
        log_print("%d physical volume(s) resized / %d physical volume(s) "
index d44f108f8eff9e4a50d7df84f4a6ff26660574dc..7943e26e2b5c8cb2236248404ce2d1e6bc5b3834 100644 (file)
@@ -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);
 }
index d8b32a565de33a609934f1fdac8a0f7f6c9e7f9d..c51bc95ed35718d8d345098c1337eb706eb3e4f5 100644 (file)
@@ -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;
index 915e3f303ad612525dd5c98348d2fcc05ad2858c..09c58f77b7cbb7b7f11d06675b458bb9e7b784e0 100644 (file)
@@ -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,
index 79bf3e09e9a6c1efb03b5afe303471f915705841..3b20a61d6f5e39318318b7d0df6acf970eb057e1 100644 (file)
@@ -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);
 
        }
This page took 0.054573 seconds and 5 git commands to generate.