master - lvmetad.8.in: update man page with timeout info
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c15649b3af94e4...
Commit: c15649b3af94e4af573ada0f30e35f7d1fee5321
Parent: f67a52677bdc95209c7adfa4575c833bed1659f1
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Oct 20 13:33:29 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Oct 20 15:45:21 2015 +0200
lvmetad.8.in: update man page with timeout info
---
man/lvmetad.8.in | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/man/lvmetad.8.in b/man/lvmetad.8.in
index cdaf198..2acfd8b 100644
--- a/man/lvmetad.8.in
+++ b/man/lvmetad.8.in
@@ -10,6 +10,8 @@ lvmetad \(em LVM metadata cache daemon
.IR pidfile_path ]
.RB [ \-s
.IR socket_path ]
+.RB [ \-t
+.IR timeout_value ]
.RB [ \-f ]
.RB [ \-h ]
.RB [ \-V ]
@@ -97,6 +99,10 @@ Path to the socket file. This overrides both the built-in default
\fBLVM_LVMETAD_SOCKET\fP. To communicate successfully with lvmetad,
all LVM2 processes should use the same socket path.
.TP
+.B \-t \fItimeout_value
+The daemon may shutdown after being idle for the given time (in seconds). When the
+option is omitted or the value given is zero the daemon never shutdowns on idle.
+.TP
.B \-V
Display the version of lvmetad daemon.
.SH ENVIRONMENT VARIABLES
8 years, 1 month
master - lvmetad: add optional timeout option
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f67a52677bdc95...
Commit: f67a52677bdc95209c7adfa4575c833bed1659f1
Parent: 392248186e56fb216e49a2fee0caad5a506e3dd1
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Oct 20 13:24:50 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Oct 20 15:45:14 2015 +0200
lvmetad: add optional timeout option
---
WHATS_NEW | 1 +
daemons/lvmetad/lvmetad-core.c | 40 ++++++++++++++++++++++++++++++++++++----
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 763896e..983b2b4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Add optional shutdown when idle support for lvmetad.
Fix missing in-sync progress info while lvconvert used with lvmpolld.
Add report/compact_output_cols to lvm.conf to define report cols to compact.
Do not change logging in lvm2 library when it's already set.
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 89aaaf8..7ec3a3a 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012-2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
@@ -24,6 +24,7 @@
#include "lvm-version.h"
#include <assert.h>
+#include <errno.h>
#include <pthread.h>
#define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket"
@@ -123,6 +124,7 @@ struct vg_info {
#define VGFL_INVALID 0x00000001
typedef struct {
+ daemon_idle *idle;
log_state *log; /* convenience */
const char *log_config;
@@ -1592,6 +1594,9 @@ static int init(daemon_state *s)
/* if (ls->initial_registrations)
_process_initial_registrations(ds->initial_registrations); */
+ if (ls->idle)
+ ls->idle->is_idle = 1;
+
return 1;
}
@@ -1614,21 +1619,39 @@ static int fini(daemon_state *s)
return 1;
}
+static int process_timeout_arg(const char *str, unsigned *max_timeouts)
+{
+ char *endptr;
+ unsigned long l;
+
+ errno = 0;
+ l = strtoul(str, &endptr, 10);
+ if (errno || *endptr || l >= UINT_MAX)
+ return 0;
+
+ *max_timeouts = (unsigned) l;
+
+ return 1;
+}
+
static void usage(const char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
- "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path]\n\n"
+ "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path] [-t secs]\n\n"
" -V Show version of lvmetad\n"
" -h Show this help information\n"
" -f Don't fork, run in the foreground\n"
" -l Logging message level (-l {all|wire|debug})\n"
" -p Set path to the pidfile\n"
- " -s Set path to the socket to listen on\n\n", prog);
+ " -s Set path to the socket to listen on\n"
+ " -t Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog);
}
int main(int argc, char *argv[])
{
signed char opt;
+ struct timeval timeout;
+ daemon_idle di = { .ptimeout = &timeout };
lvmetad_state ls = { .log_config = "" };
daemon_state s = {
.daemon_fini = fini,
@@ -1643,7 +1666,7 @@ int main(int argc, char *argv[])
};
// use getopt_long
- while ((opt = getopt(argc, argv, "?fhVl:p:s:")) != EOF) {
+ while ((opt = getopt(argc, argv, "?fhVl:p:s:t:")) != EOF) {
switch (opt) {
case 'h':
usage(argv[0], stdout);
@@ -1663,6 +1686,15 @@ int main(int argc, char *argv[])
case 's': // --socket
s.socket_path = optarg;
break;
+ case 't':
+ if (!process_timeout_arg(optarg, &di.max_timeouts)) {
+ fprintf(stderr, "Invalid value of timeout parameter.\n");
+ exit(EXIT_FAILURE);
+ }
+ /* 0 equals to wait indefinitely */
+ if (di.max_timeouts)
+ s.idle = ls.idle = &di;
+ break;
case 'V':
printf("lvmetad version: " LVM_VERSION "\n");
exit(1);
8 years, 1 month
master - tests: add test for missing mirror in-sync info
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=392248186e56fb...
Commit: 392248186e56fb216e49a2fee0caad5a506e3dd1
Parent: 33465066c5eddaa6169814d645d543e5673bc2a6
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Oct 20 11:55:51 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Oct 20 12:19:02 2015 +0200
tests: add test for missing mirror in-sync info
---
test/shell/lvconvert-mirror.sh | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh
index 844f8e9..029112c 100644
--- a/test/shell/lvconvert-mirror.sh
+++ b/test/shell/lvconvert-mirror.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2010-2013 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2010-2015 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -313,4 +313,11 @@ lvconvert --mirrorlog disk $vg/$lv1 "$dev3:0-1"
check mirror $vg $lv1 "$dev3"
lvremove -ff $vg
+# bz1272175: check lvconvert reports progress while waiting for mirror
+# to get synced
+lvcreate -l2 -n $lv1 $vg
+lvconvert --type mirror -i1 -m1 $vg/$lv1 | tee out
+grep -e "$vg/$lv1: Converted:" out || fail "Missing sync info in foreground mode"
+lvremove -ff $vg
+
vgremove -ff $vg
8 years, 1 month
master - polldaemon: fix missing mirror in-sync info with lvmpolld
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=33465066c5edda...
Commit: 33465066c5eddaa6169814d645d543e5673bc2a6
Parent: a5c4c4efbd18809320f49d7ed60c58883140259c
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Mon Oct 19 16:56:45 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Oct 20 12:18:55 2015 +0200
polldaemon: fix missing mirror in-sync info with lvmpolld
CONVERTING status flag is a tricky one. It's not set when converting
a non-mirror LV type to the mirror type, i.e.: linear -> two leg mirror.
Also the conversion itself is instant and doesn't require to be polled.
When mirror reaches sync state there's no final update on VG metadata
for lvmpolld to be made thereby report_progress in fact doesn't report
percentage of mirror being converted but percentage of mirror
being in sync. Perhaps we should reword the lvconvert output here.
On the other hand CONVERTING is set while we upconvert the mirror
from i.e. two leg mirror to four leg mirror. In such case the operation
is required to be polled so that lvmpolld can cleanup temporary
conversion log when the conversion is over.
Ignore CONVERTING lv_type for the moment and match LVs only by uuids
during 'mirror conversion'/'waiting for a sync to finish'.
---
WHATS_NEW | 1 +
tools/polldaemon.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f973f11..763896e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Fix missing in-sync progress info while lvconvert used with lvmpolld.
Add report/compact_output_cols to lvm.conf to define report cols to compact.
Do not change logging in lvm2 library when it's already set.
Check for enough space in thin-pool in command before creating new thin.
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index cee1983..ccfaa7d 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -412,7 +412,12 @@ static int report_progress(struct cmd_context *cmd, struct poll_operation_id *id
if (lv && id->uuid && strcmp(id->uuid, (char *)&lv->lvid))
lv = NULL;
- if (lv && parms->lv_type && !(lv->status & parms->lv_type))
+
+ /*
+ * CONVERTING is set only during mirror upconversion but we may need to
+ * read LV's progress info even when it's not converting (linear->mirror)
+ */
+ if (lv && (parms->lv_type ^ CONVERTING) && !(lv->status & parms->lv_type))
lv = NULL;
if (!lv) {
8 years, 1 month
master - conf: clarify compact output settings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5c4c4efbd1880...
Commit: a5c4c4efbd18809320f49d7ed60c58883140259c
Parent: 83d475626a4d9ecaa2084f349cb2cee4f0f3a719
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 20 11:01:09 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 20 11:01:09 2015 +0200
conf: clarify compact output settings
---
conf/example.conf.in | 21 ++++++++++++---------
lib/config/config_settings.h | 21 ++++++++++++---------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index e96f03f..b8c0407 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1494,19 +1494,22 @@ activation {
# report {
# Configuration option report/compact_output.
- # Do not print empty report fields.
- # Fields that don't have a value set for any of the rows reported are
- # skipped and not printed. Compact output is applicable only if
- # report/buffered is enabled.
+ # Do not print empty values for all report fields.
+ # If enabled, all fields that don't have a value set for any of the
+ # rows reported are skipped and not printed. Compact output is
+ # applicable only if report/buffered is enabled. If you need to
+ # compact only specified fields, use compact_output=0 and define
+ # report/compact_output_cols configuration setting instead.
# This configuration option has an automatic default value.
# compact_output = 0
# Configuration option report/compact_output_cols.
- # Do not print empty values for given report fields.
- # The same as compact_output setting, but the compaction is not done
- # globally for all fields in report but only for given fields. If both
- # compact_output and compact_output_cols is used at the same time,
- # the compact_output setting prevails.
+ # Do not print empty values for specified report fields.
+ # If defined, specified fields that don't have a value set for any
+ # of the rows reported are skipped and not printed. Compact output
+ # is applicable only if report/buffered is enabled. If you need to
+ # compact all fields, use compact_output=1 instead in which case
+ # the compact_output_cols setting is then ignored.
# This configuration option has an automatic default value.
# compact_output_cols = ""
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 1a261a2..dd2b407 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1416,17 +1416,20 @@ cfg(disk_area_size_CFG, "size", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_
cfg(disk_area_id_CFG, "id", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL, NULL)
cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_COMPACT_OUTPUT, vsn(2, 2, 115), NULL, 0, NULL,
- "Do not print empty report fields.\n"
- "Fields that don't have a value set for any of the rows reported are\n"
- "skipped and not printed. Compact output is applicable only if\n"
- "report/buffered is enabled.\n")
+ "Do not print empty values for all report fields.\n"
+ "If enabled, all fields that don't have a value set for any of the\n"
+ "rows reported are skipped and not printed. Compact output is\n"
+ "applicable only if report/buffered is enabled. If you need to\n"
+ "compact only specified fields, use compact_output=0 and define\n"
+ "report/compact_output_cols configuration setting instead.\n")
cfg(report_compact_output_cols_CFG, "compact_output_cols", report_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMPACT_OUTPUT_COLS, vsn(2, 2, 133), NULL, 0, NULL,
- "Do not print empty values for given report fields.\n"
- "The same as compact_output setting, but the compaction is not done\n"
- "globally for all fields in report but only for given fields. If both\n"
- "compact_output and compact_output_cols is used at the same time,\n"
- "the compact_output setting prevails.\n")
+ "Do not print empty values for specified report fields.\n"
+ "If defined, specified fields that don't have a value set for any\n"
+ "of the rows reported are skipped and not printed. Compact output\n"
+ "is applicable only if report/buffered is enabled. If you need to\n"
+ "compact all fields, use compact_output=1 instead in which case\n"
+ "the compact_output_cols setting is then ignored.\n")
cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_ALIGNED, vsn(1, 0, 0), NULL, 0, NULL,
"Align columns in report output.\n")
8 years, 1 month
master - pvscan: use process_each_pv
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=83d475626a4d9e...
Commit: 83d475626a4d9ecaa2084f349cb2cee4f0f3a719
Parent: 1ea7e2634d67a7628508a677668a00f748aee0b0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Oct 19 13:58:43 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Oct 19 16:15:51 2015 -0500
pvscan: use process_each_pv
The old code made two loops through the PVs: in the first
loop it found the max PV and VG name lengths, and in the
second loop it printed each PV using the name lengths as
field widths for aligning columns.
The new code uses process_each_pv() which makes one loop
through the PVs. In the *first* call to pvscan_single(),
the max name lengths are found by looping through the
lvmcache entries which have been populated by the generic
process_each code prior to calling any _single functions.
Subsequent calls to pvscan_single() reuse the max lengths
that were found by the first call.
---
lib/cache/lvmcache.c | 24 +++++++
lib/cache/lvmcache.h | 4 +
tools/pvscan.c | 178 ++++++++++++++++++++++----------------------------
3 files changed, 107 insertions(+), 99 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index c495fa7..1bc4241 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -2358,3 +2358,27 @@ int lvmcache_contains_lock_type_sanlock(struct cmd_context *cmd)
return 0;
}
+void lvmcache_get_max_name_lengths(struct cmd_context *cmd,
+ unsigned *pv_max_name_len,
+ unsigned *vg_max_name_len)
+{
+ struct lvmcache_vginfo *vginfo;
+ struct lvmcache_info *info;
+ unsigned len;
+
+ *vg_max_name_len = 0;
+ *pv_max_name_len = 0;
+
+ dm_list_iterate_items(vginfo, &_vginfos) {
+ len = strlen(vginfo->vgname);
+ if (*vg_max_name_len < len)
+ *vg_max_name_len = len;
+
+ dm_list_iterate_items(info, &vginfo->infos) {
+ len = strlen(dev_name(info->dev));
+ if (*pv_max_name_len < len)
+ *pv_max_name_len = len;
+ }
+ }
+}
+
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 76b9b10..ccf3eb4 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -190,4 +190,8 @@ void lvmcache_set_preferred_duplicates(const char *vgid);
int lvmcache_contains_lock_type_sanlock(struct cmd_context *cmd);
+void lvmcache_get_max_name_lengths(struct cmd_context *cmd,
+ unsigned *pv_max_name_len, unsigned *vg_max_name_len);
+
+
#endif
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3adb91c..460b74d 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -18,56 +18,66 @@
#include "lvmetad.h"
#include "lvmcache.h"
-unsigned pv_max_name_len = 0;
-unsigned vg_max_name_len = 0;
-
-static void _pvscan_display_single(struct cmd_context *cmd,
- struct physical_volume *pv,
- void *handle __attribute__((unused)))
+struct pvscan_params {
+ int new_pvs_found;
+ int pvs_found;
+ uint64_t size_total;
+ uint64_t size_new;
+ unsigned pv_max_name_len;
+ unsigned vg_max_name_len;
+ unsigned pv_tmp_namelen;
+ char *pv_tmp_name;
+};
+
+static int _pvscan_display_single(struct cmd_context *cmd,
+ struct physical_volume *pv,
+ struct pvscan_params *params)
{
/* XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXXXX */
char uuid[40] __attribute__((aligned(8)));
- const unsigned suffix = sizeof(uuid) + 10;
- char pv_tmp_name[pv_max_name_len + suffix];
- unsigned pv_len = pv_max_name_len;
+ const unsigned suffix_len = sizeof(uuid) + 10;
+ unsigned pv_len;
const char *pvdevname = pv_dev_name(pv);
/* short listing? */
if (arg_count(cmd, short_ARG) > 0) {
log_print_unless_silent("%s", pvdevname);
- return;
+ return ECMD_PROCESSED;
}
- if (arg_count(cmd, verbose_ARG) > 1) {
- /* FIXME As per pv_display! Drop through for now. */
- /* pv_show(pv); */
+ if (!params->pv_max_name_len) {
+ lvmcache_get_max_name_lengths(cmd, ¶ms->pv_max_name_len, ¶ms->vg_max_name_len);
- /* FIXME - Moved to Volume Group structure */
- /* log_print("system ID %s", pv->vg->system_id); */
+ params->pv_max_name_len += 2;
+ params->vg_max_name_len += 2;
+ params->pv_tmp_namelen = params->pv_max_name_len + suffix_len;
- /* log_print(" "); */
- /* return; */
+ if (!(params->pv_tmp_name = dm_pool_alloc(cmd->mem, params->pv_tmp_namelen)))
+ return ECMD_FAILED;
}
+ pv_len = params->pv_max_name_len;
+ memset(params->pv_tmp_name, 0, params->pv_tmp_namelen);
+
if (arg_count(cmd, uuid_ARG)) {
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
stack;
- return;
+ return ECMD_FAILED;
}
- if (dm_snprintf(pv_tmp_name, sizeof(pv_tmp_name), "%-*s with UUID %s",
- pv_max_name_len - 2, pvdevname, uuid) < 0) {
+ if (dm_snprintf(params->pv_tmp_name, params->pv_tmp_namelen, "%-*s with UUID %s",
+ params->pv_max_name_len - 2, pvdevname, uuid) < 0) {
log_error("Invalid PV name with uuid.");
- return;
+ return ECMD_FAILED;
}
- pvdevname = pv_tmp_name;
- pv_len += suffix;
+ pvdevname = params->pv_tmp_name;
+ pv_len += suffix_len;
}
if (is_orphan(pv))
log_print_unless_silent("PV %-*s %-*s %s [%s]",
pv_len, pvdevname,
- vg_max_name_len, " ",
+ params->vg_max_name_len, " ",
pv->fmt ? pv->fmt->name : " ",
display_size(cmd, pv_size(pv)));
else if (pv_status(pv) & EXPORTED_VG)
@@ -78,10 +88,36 @@ static void _pvscan_display_single(struct cmd_context *cmd,
else
log_print_unless_silent("PV %-*s VG %-*s %s [%s / %s free]",
pv_len, pvdevname,
- vg_max_name_len, pv_vg_name(pv),
+ params->vg_max_name_len, pv_vg_name(pv),
pv->fmt ? pv->fmt->name : " ",
display_size(cmd, (uint64_t) pv_pe_count(pv) * pv_pe_size(pv)),
display_size(cmd, (uint64_t) (pv_pe_count(pv) - pv_pe_alloc_count(pv)) * pv_pe_size(pv)));
+ return ECMD_PROCESSED;
+}
+
+static int _pvscan_single(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, struct processing_handle *handle)
+{
+ struct pvscan_params *params = (struct pvscan_params *)handle->custom_handle;
+
+ if ((arg_count(cmd, exported_ARG) && !(pv_status(pv) & EXPORTED_VG)) ||
+ (arg_count(cmd, novolumegroup_ARG) && (!is_orphan(pv)))) {
+ return ECMD_PROCESSED;
+
+ }
+
+ params->pvs_found++;
+
+ if (is_orphan(pv)) {
+ params->new_pvs_found++;
+ params->size_new += pv_size(pv);
+ params->size_total += pv_size(pv);
+ } else {
+ params->size_total += (uint64_t) pv_pe_count(pv) * pv_pe_size(pv);
+ }
+
+ _pvscan_display_single(cmd, pv, params);
+ return ECMD_PROCESSED;
}
#define REFRESH_BEFORE_AUTOACTIVATION_RETRIES 5
@@ -327,16 +363,9 @@ out:
int pvscan(struct cmd_context *cmd, int argc, char **argv)
{
- int new_pvs_found = 0;
- int pvs_found = 0;
-
- struct dm_list *pvslist;
- struct pv_list *pvl;
- struct physical_volume *pv;
-
- uint64_t size_total = 0;
- uint64_t size_new = 0;
- unsigned len;
+ struct pvscan_params params = { 0 };
+ struct processing_handle *handle = NULL;
+ int ret;
if (arg_count(cmd, cache_long_ARG))
return _pvscan_lvmetad(cmd, argc, argv);
@@ -377,80 +406,31 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
if (cmd->full_filter->wipe)
cmd->full_filter->wipe(cmd->full_filter);
- lvmcache_destroy(cmd, 1, 0);
- /* populate lvmcache */
- if (!lvmetad_vg_list_to_lvmcache(cmd))
- stack;
-
- log_verbose("Walking through all physical volumes");
- if (!(pvslist = get_pvs(cmd))) {
- unlock_vg(cmd, VG_GLOBAL);
- return_ECMD_FAILED;
- }
-
- /* eliminate exported/new if required */
- dm_list_iterate_items(pvl, pvslist) {
- pv = pvl->pv;
-
- if ((arg_count(cmd, exported_ARG)
- && !(pv_status(pv) & EXPORTED_VG)) ||
- (arg_count(cmd, novolumegroup_ARG) && (!is_orphan(pv)))) {
- dm_list_del(&pvl->list);
- free_pv_fid(pv);
- continue;
- }
+ lvmcache_destroy(cmd, 1, 0);
- /* Also check for MD use? */
-/*******
- if (MAJOR(pv_create_kdev_t(pv[p]->pv_name)) != MD_MAJOR) {
- log_warn
- ("WARNING: physical volume \"%s\" belongs to a meta device",
- pv[p]->pv_name);
- }
- if (MAJOR(pv[p]->pv_dev) != MD_MAJOR)
- continue;
-********/
- pvs_found++;
-
- if (is_orphan(pv)) {
- new_pvs_found++;
- size_new += pv_size(pv);
- size_total += pv_size(pv);
- } else
- size_total += (uint64_t) pv_pe_count(pv) * pv_pe_size(pv);
+ if (!(handle = init_processing_handle(cmd))) {
+ log_error("Failed to initialize processing handle.");
+ ret = ECMD_FAILED;
+ goto out;
}
- /* find maximum pv name length */
- pv_max_name_len = vg_max_name_len = 0;
- dm_list_iterate_items(pvl, pvslist) {
- pv = pvl->pv;
- len = strlen(pv_dev_name(pv));
- if (pv_max_name_len < len)
- pv_max_name_len = len;
- len = strlen(pv_vg_name(pv));
- if (vg_max_name_len < len)
- vg_max_name_len = len;
- }
- pv_max_name_len += 2;
- vg_max_name_len += 2;
+ handle->custom_handle = ¶ms;
- dm_list_iterate_items(pvl, pvslist) {
- _pvscan_display_single(cmd, pvl->pv, NULL);
- free_pv_fid(pvl->pv);
- }
+ ret = process_each_pv(cmd, argc, argv, NULL, 0, handle, _pvscan_single);
- if (!pvs_found)
+ if (!params.pvs_found)
log_print_unless_silent("No matching physical volumes found");
else
log_print_unless_silent("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]",
- pvs_found,
- display_size(cmd, size_total),
- pvs_found - new_pvs_found,
- display_size(cmd, (size_total - size_new)),
- new_pvs_found, display_size(cmd, size_new));
+ params.pvs_found,
+ display_size(cmd, params.size_total),
+ params.pvs_found - params.new_pvs_found,
+ display_size(cmd, (params.size_total - params.size_new)),
+ params.new_pvs_found, display_size(cmd, params.size_new));
+out:
unlock_vg(cmd, VG_GLOBAL);
- return ECMD_PROCESSED;
+ return ret;
}
8 years, 1 month
master - conf: regenerate
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1ea7e2634d67a7...
Commit: 1ea7e2634d67a7628508a677668a00f748aee0b0
Parent: 23d9b17a7b06d8e6f89b2c3e9ef9f59462436458
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Oct 19 10:01:14 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Oct 19 10:01:14 2015 +0200
conf: regenerate
---
conf/example.conf.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index dddede0..e96f03f 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -389,8 +389,8 @@ allocation {
# This configuration option does not have a default value defined.
# Configuration section allocation/cache_settings.
- # Individual settings for policies.
- # See the help for individual policies for more info.
+ # Settings for the cache policy.
+ # See documentation for individual cache policies for more info.
# This configuration section has an automatic default value.
# cache_settings {
# }
8 years, 1 month
master - cleanup: typo in comment: compact_output_fields should be compact-output_cols
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=23d9b17a7b06d8...
Commit: 23d9b17a7b06d8e6f89b2c3e9ef9f59462436458
Parent: c3bfe07f2ad393963af5b7138bccc622e6561c8f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Oct 19 09:59:05 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Oct 19 09:59:05 2015 +0200
cleanup: typo in comment: compact_output_fields should be compact-output_cols
---
conf/example.conf.in | 2 +-
lib/config/config_settings.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index e1afed6..dddede0 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1505,7 +1505,7 @@ activation {
# Do not print empty values for given report fields.
# The same as compact_output setting, but the compaction is not done
# globally for all fields in report but only for given fields. If both
- # compact_output and compact_output_fields is used at the same time,
+ # compact_output and compact_output_cols is used at the same time,
# the compact_output setting prevails.
# This configuration option has an automatic default value.
# compact_output_cols = ""
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index cefc579..1a261a2 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1425,7 +1425,7 @@ cfg(report_compact_output_cols_CFG, "compact_output_cols", report_CFG_SECTION, C
"Do not print empty values for given report fields.\n"
"The same as compact_output setting, but the compaction is not done\n"
"globally for all fields in report but only for given fields. If both\n"
- "compact_output and compact_output_fields is used at the same time,\n"
+ "compact_output and compact_output_cols is used at the same time,\n"
"the compact_output setting prevails.\n")
cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_ALIGNED, vsn(1, 0, 0), NULL, 0, NULL,
8 years, 1 month
master - config: add report/compact_output_cols to control which columns to compact in report output
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c3bfe07f2ad393...
Commit: c3bfe07f2ad393963af5b7138bccc622e6561c8f
Parent: 508f0f5a21af8decf32944e01ecf17c0059a9c9f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 16 16:25:51 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 16 17:05:54 2015 +0200
config: add report/compact_output_cols to control which columns to compact in report output
The new report/compact_output_cols setting has exactly the same effect
as report/compact_output setting. The difference is that with the new
setting it's possible to define which cols should be compacted exactly
in contrast to all cols in case of report/compact_output.
In case both compact_output and compact_output_cols is enabled/set,
the compact_output prevails.
For example:
$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols=""
$ lvs vg
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lvol0 vg -wi-a----- 4.00m
---
$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"
$ lvs vg
LV VG Attr LSize Log Cpy%Sync Convert
lvol0 vg -wi-a----- 4.00m
---
$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=1
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"
$ lvs vg
LV VG Attr LSize
lvol0 vg -wi-a----- 4.00m
---
WHATS_NEW | 1 +
conf/example.conf.in | 9 +++++++++
lib/config/config_settings.h | 7 +++++++
lib/config/defaults.h | 2 ++
libdm/libdevmapper.h | 2 +-
tools/reporter.c | 11 ++++++++---
6 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c089228..f973f11 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.133 -
======================================
+ Add report/compact_output_cols to lvm.conf to define report cols to compact.
Do not change logging in lvm2 library when it's already set.
Check for enough space in thin-pool in command before creating new thin.
Make libblkid detect all copies of the same signature if use_blkid_wiping=1.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index c0afcb7..e1afed6 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1501,6 +1501,15 @@ activation {
# This configuration option has an automatic default value.
# compact_output = 0
+ # Configuration option report/compact_output_cols.
+ # Do not print empty values for given report fields.
+ # The same as compact_output setting, but the compaction is not done
+ # globally for all fields in report but only for given fields. If both
+ # compact_output and compact_output_fields is used at the same time,
+ # the compact_output setting prevails.
+ # This configuration option has an automatic default value.
+ # compact_output_cols = ""
+
# Configuration option report/aligned.
# Align columns in report output.
# This configuration option has an automatic default value.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 9cc444f..cefc579 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1421,6 +1421,13 @@ cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILA
"skipped and not printed. Compact output is applicable only if\n"
"report/buffered is enabled.\n")
+cfg(report_compact_output_cols_CFG, "compact_output_cols", report_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMPACT_OUTPUT_COLS, vsn(2, 2, 133), NULL, 0, NULL,
+ "Do not print empty values for given report fields.\n"
+ "The same as compact_output setting, but the compaction is not done\n"
+ "globally for all fields in report but only for given fields. If both\n"
+ "compact_output and compact_output_fields is used at the same time,\n"
+ "the compact_output setting prevails.\n")
+
cfg(report_aligned_CFG, "aligned", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_ALIGNED, vsn(1, 0, 0), NULL, 0, NULL,
"Align columns in report output.\n")
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index cd5d121..8ab1fde 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -201,6 +201,8 @@
#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
#define DEFAULT_TIME_FORMAT "%Y-%m-%d %T %z"
+#define DEFAULT_COMPACT_OUTPUT_COLS ""
+
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 1a2036b..fcbf7cf 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2552,7 +2552,7 @@ int dm_report_compact_fields(struct dm_report *rh);
* The same as dm_report_compact_fields, but for selected fields only.
* The "fields" arg is comma separated list of field names (the same format
* as used for "output_fields" arg in dm_report_init fn).
-*/
+ */
int dm_report_compact_given_fields(struct dm_report *rh, const char *fields);
/*
diff --git a/tools/reporter.c b/tools/reporter.c
index 8f7a272..6c93739 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -618,6 +618,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
unsigned args_are_pvs;
int lv_info_needed, lv_segment_status_needed;
int lock_global = 0;
+ const char *fields_to_compact;
aligned = find_config_tree_bool(cmd, report_aligned_CFG, NULL);
buffered = find_config_tree_bool(cmd, report_buffered_CFG, NULL);
@@ -817,9 +818,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
}
- if (find_config_tree_bool(cmd, report_compact_output_CFG, NULL) &&
- !dm_report_compact_fields(report_handle))
- log_error("Failed to compact report output.");
+ if (find_config_tree_bool(cmd, report_compact_output_CFG, NULL)) {
+ if (!dm_report_compact_fields(report_handle))
+ log_error("Failed to compact report output.");
+ } else if ((fields_to_compact = find_config_tree_str_allow_empty(cmd, report_compact_output_cols_CFG, NULL))) {
+ if (!dm_report_compact_given_fields(report_handle, fields_to_compact))
+ log_error("Failed to compact given columns in report output.");
+ }
dm_report_output(report_handle);
8 years, 1 month
master - libdm: add dm_report_compact_given_fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=508f0f5a21af8d...
Commit: 508f0f5a21af8decf32944e01ecf17c0059a9c9f
Parent: df34fcdafd20ac195e588a06c8fc5a904fa71669
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 16 15:50:13 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 16 17:05:54 2015 +0200
libdm: add dm_report_compact_given_fields
dm_report_compact_given_fields is the same as dm_report_compact_fields,
but it processes only given fields, not all the fields in the report
like dm_report_compact_field does.
---
WHATS_NEW_DM | 1 +
libdm/.exported_symbols.DM_1_02_110 | 1 +
libdm/libdevmapper.h | 7 ++++
libdm/libdm-report.c | 62 +++++++++++++++++++++++++++++++++-
4 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index dffcd34..9818846 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Add dm_report_compact_given_fields to remove given empty fields from report.
Use libdm status parsing and local mem raid dmeventd plugin.
Use local mem pool and lock only lvm2 execution for mirror dmeventd plugin.
Lock protect only lvm2 execution for snapshot and thin dmeventd plugin.
diff --git a/libdm/.exported_symbols.DM_1_02_110 b/libdm/.exported_symbols.DM_1_02_110
new file mode 100644
index 0000000..71d04a9
--- /dev/null
+++ b/libdm/.exported_symbols.DM_1_02_110
@@ -0,0 +1 @@
+dm_report_compact_given_fields
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 8077867..1a2036b 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2549,6 +2549,13 @@ int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_outp
int dm_report_compact_fields(struct dm_report *rh);
/*
+ * The same as dm_report_compact_fields, but for selected fields only.
+ * The "fields" arg is comma separated list of field names (the same format
+ * as used for "output_fields" arg in dm_report_init fn).
+*/
+int dm_report_compact_given_fields(struct dm_report *rh, const char *fields);
+
+/*
* Returns 1 if there is no data waiting to be output.
*/
int dm_report_is_empty(struct dm_report *rh);
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 681ad04..b2e70d5 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -81,6 +81,7 @@ struct dm_report {
#define FLD_ASCENDING 0x00004000
#define FLD_DESCENDING 0x00008000
#define FLD_COMPACTED 0x00010000
+#define FLD_COMPACT_ONE 0x00020000
struct field_properties {
struct dm_list list;
@@ -2013,7 +2014,7 @@ out:
return r;
}
-int dm_report_compact_fields(struct dm_report *rh)
+static int _do_report_compact_fields(struct dm_report *rh, int global)
{
struct dm_report_field *field;
struct field_properties *fp;
@@ -2036,7 +2037,9 @@ int dm_report_compact_fields(struct dm_report *rh)
* in next step...
*/
dm_list_iterate_items(fp, &rh->field_props) {
- if (!(fp->flags & FLD_HIDDEN))
+ if (fp->flags & FLD_HIDDEN)
+ continue;
+ if (global || (fp->flags & FLD_COMPACT_ONE))
fp->flags |= (FLD_COMPACTED | FLD_HIDDEN);
}
@@ -2065,6 +2068,61 @@ int dm_report_compact_fields(struct dm_report *rh)
return 1;
}
+int dm_report_compact_fields(struct dm_report *rh)
+{
+ return _do_report_compact_fields(rh, 1);
+}
+
+static int _field_to_compact_match(struct dm_report *rh, const char *field, size_t flen)
+{
+ struct field_properties *fp;
+ uint32_t f;
+ int implicit;
+
+ if ((_get_field(rh, field, flen, &f, &implicit))) {
+ dm_list_iterate_items(fp, &rh->field_props) {
+ if ((fp->implicit == implicit) && (fp->field_num == f)) {
+ fp->flags |= FLD_COMPACT_ONE;
+ break;
+ }
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+static int _parse_fields_to_compact(struct dm_report *rh, const char *fields)
+{
+ const char *ws; /* Word start */
+ const char *we = fields; /* Word end */
+
+ if (!fields)
+ return 1;
+
+ while (*we) {
+ while (*we && *we == ',')
+ we++;
+ ws = we;
+ while (*we && *we != ',')
+ we++;
+ if (!_field_to_compact_match(rh, ws, (size_t) (we - ws))) {
+ log_error("dm_report: Unrecognized field: %.*s", (int) (we - ws), ws);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+int dm_report_compact_given_fields(struct dm_report *rh, const char *fields)
+{
+ if (!_parse_fields_to_compact(rh, fields))
+ return_0;
+
+ return _do_report_compact_fields(rh, 0);
+}
+
int dm_report_object(struct dm_report *rh, void *object)
{
return _do_report_object(rh, object, 1, NULL);
8 years, 1 month