mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.)
This commit is contained in:
parent
284f4496c3
commit
ea0cdd28c1
@ -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.
|
||||
|
@ -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.")
|
||||
|
@ -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 },
|
||||
|
@ -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.
|
||||
*
|
||||
@ -18,7 +18,14 @@
|
||||
|
||||
#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;
|
||||
|
@ -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;
|
||||
char prefixed_all[32];
|
||||
|
||||
if (!strncasecmp(field, "all", 3) && flen == 3)
|
||||
return rh->report_types;
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) "
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user