master - polldaemon: Re-initialise lvmcache properly on fork (fixes RHBZ 1073670).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f12ee43f2eaba5...
Commit: f12ee43f2eaba5d38b1925a5a34b1746c1d66985
Parent: 2f279797f526494887a6163ead9e83e4823c8c94
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Mar 19 16:23:43 2014 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Mar 19 16:25:12 2014 +0100
polldaemon: Re-initialise lvmcache properly on fork (fixes RHBZ 1073670).
---
test/shell/pvmove-background.sh | 24 ++++++++++++++++++++++++
tools/toollib.c | 1 +
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/test/shell/pvmove-background.sh b/test/shell/pvmove-background.sh
new file mode 100644
index 0000000..0f657be
--- /dev/null
+++ b/test/shell/pvmove-background.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2014 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
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Check pvmove behavior when it's progress and machine is rebooted
+
+. lib/test
+
+aux prepare_vg 3
+
+lvcreate -l1 -n $lv1 $vg "$dev1"
+
+lvs -o +devices | grep $dev1
+pvmove -i 1 -b "$dev1" "$dev2"
+sleep 5 # arbitrary...
+lvs -o +devices | not grep "pvmove"
+lvs -o +devices | grep "$dev2"
diff --git a/tools/toollib.c b/tools/toollib.c
index 91b0559..2bc0be3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -91,6 +91,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
if (!skip_lvm) {
+ lvmcache_destroy(cmd, 1);
reset_locking();
if (!lvmcache_init())
/* FIXME Clean up properly here */
9 years, 8 months
master - WHATS_NEW: commit 5eef269
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2f279797f52649...
Commit: 2f279797f526494887a6163ead9e83e4823c8c94
Parent: 000e81a999a456a6db2de1aef70a147b00fb7491
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Mar 19 09:49:09 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Mar 19 09:49:09 2014 +0100
WHATS_NEW: commit 5eef269
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b7040d7..f07d2a9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -16,6 +16,7 @@ Version 2.02.106 -
Use VG read lock during 'pvscan --cache -aay' autoactivation.
Issue a VG refresh before autoactivation only if the PV has changed/is new.
Add flag to lvmetad protocol to indicate the PV scanned has changed/is new.
+ Also add vgname to lvmetad protocol when referencing VGs for PVs scanned.
Add man page for lvm2-activation-generator.
Don't print an error and accept empty value for global/thin_disabled_features.
Update API for internal function build_dm_uuid().
9 years, 8 months
master - cleanup: add cmd_context reference to struct cft_check_handle
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=000e81a999a456...
Commit: 000e81a999a456a6db2de1aef70a147b00fb7491
Parent: b6eb2ac10ab509a74f83b9333ff195b63d64d8ef
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Mar 19 08:45:05 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Mar 19 08:45:05 2014 +0100
cleanup: add cmd_context reference to struct cft_check_handle
So we have all things needed to do a configuration check packaged
in one handle. It makes function calls inside a bit more readable.
---
lib/commands/toolcontext.c | 3 +-
lib/config/config.c | 56 +++++++++++++++++++++----------------------
lib/config/config.h | 3 +-
tools/dumpconfig.c | 5 ++-
4 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index e620884..899666c 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -269,8 +269,9 @@ static int _check_config(struct cmd_context *cmd)
}
cmd->cft_check_handle->cft = cmd->cft;
+ cmd->cft_check_handle->cmd = cmd;
- if (!config_def_check(cmd, cmd->cft_check_handle) &&
+ if (!config_def_check(cmd->cft_check_handle) &&
find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL)) {
log_error("LVM configuration invalid.");
return 0;
diff --git a/lib/config/config.c b/lib/config/config.c
index 38d3f0b..ba1e280 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -537,17 +537,18 @@ static void _log_type_error(const char *path, cfg_def_type_t actual,
actual_type_name, expected_type_name);
}
-static int _config_def_check_node_single_value(const char *rp, const struct dm_config_value *v,
- const cfg_def_item_t *def, int suppress_messages)
+static int _config_def_check_node_single_value(struct cft_check_handle *handle,
+ const char *rp, const struct dm_config_value *v,
+ const cfg_def_item_t *def)
{
/* Check empty array first if present. */
if (v->type == DM_CFG_EMPTY_ARRAY) {
if (!(def->type & CFG_TYPE_ARRAY)) {
- _log_type_error(rp, CFG_TYPE_ARRAY, def->type, suppress_messages);
+ _log_type_error(rp, CFG_TYPE_ARRAY, def->type, handle->suppress_messages);
return 0;
}
if (!(def->flags & CFG_ALLOW_EMPTY)) {
- log_warn_suppress(suppress_messages,
+ log_warn_suppress(handle->suppress_messages,
"Configuration setting \"%s\" invalid. Empty value not allowed.", rp);
return 0;
}
@@ -557,20 +558,20 @@ static int _config_def_check_node_single_value(const char *rp, const struct dm_c
switch (v->type) {
case DM_CFG_INT:
if (!(def->type & CFG_TYPE_INT) && !(def->type & CFG_TYPE_BOOL)) {
- _log_type_error(rp, CFG_TYPE_INT, def->type, suppress_messages);
+ _log_type_error(rp, CFG_TYPE_INT, def->type, handle->suppress_messages);
return 0;
}
break;
case DM_CFG_FLOAT:
if (!(def->type & CFG_TYPE_FLOAT)) {
- _log_type_error(rp, CFG_TYPE_FLOAT, def->type, suppress_messages);
+ _log_type_error(rp, CFG_TYPE_FLOAT, def->type, handle-> suppress_messages);
return 0;
}
break;
case DM_CFG_STRING:
if (def->type & CFG_TYPE_BOOL) {
if (!dm_config_value_is_bool(v)) {
- log_warn_suppress(suppress_messages,
+ log_warn_suppress(handle->suppress_messages,
"Configuration setting \"%s\" invalid. "
"Found string value \"%s\", "
"expected boolean value: 0/1, \"y/n\", "
@@ -579,7 +580,7 @@ static int _config_def_check_node_single_value(const char *rp, const struct dm_c
return 0;
}
} else if (!(def->type & CFG_TYPE_STRING)) {
- _log_type_error(rp, CFG_TYPE_STRING, def->type, suppress_messages);
+ _log_type_error(rp, CFG_TYPE_STRING, def->type, handle->suppress_messages);
return 0;
}
break;
@@ -609,7 +610,7 @@ static int _config_def_check_node_value(struct cft_check_handle *handle,
}
do {
- if (!_config_def_check_node_single_value(rp, v, def, handle->suppress_messages))
+ if (!_config_def_check_node_single_value(handle, rp, v, def))
return 0;
v = v->next;
} while (v);
@@ -619,8 +620,7 @@ static int _config_def_check_node_value(struct cft_check_handle *handle,
static int _config_def_check_node(struct cft_check_handle *handle,
const char *vp, char *pvp, char *rp, char *prp,
- size_t buf_size, struct dm_config_node *cn,
- struct dm_hash_table *ht)
+ size_t buf_size, struct dm_config_node *cn)
{
cfg_def_item_t *def;
int sep = vp != pvp; /* don't use '/' separator for top-level node */
@@ -632,7 +632,7 @@ static int _config_def_check_node(struct cft_check_handle *handle,
}
- if (!(def = (cfg_def_item_t *) dm_hash_lookup(ht, vp))) {
+ if (!(def = (cfg_def_item_t *) dm_hash_lookup(handle->cmd->cft_def_hash, vp))) {
/* If the node is not a section but a setting, fail now. */
if (cn->v) {
log_warn_suppress(handle->suppress_messages,
@@ -645,7 +645,7 @@ static int _config_def_check_node(struct cft_check_handle *handle,
/* Modify virtual path vp in situ and replace the key name with a '#'. */
/* The real path without '#' is still stored in rp variable. */
pvp[sep] = '#', pvp[sep + 1] = '\0';
- if (!(def = (cfg_def_item_t *) dm_hash_lookup(ht, vp))) {
+ if (!(def = (cfg_def_item_t *) dm_hash_lookup(handle->cmd->cft_def_hash, vp))) {
log_warn_suppress(handle->suppress_messages,
"Configuration section \"%s\" unknown.", rp);
cn->id = -1;
@@ -678,8 +678,7 @@ static int _config_def_check_node(struct cft_check_handle *handle,
static int _config_def_check_tree(struct cft_check_handle *handle,
const char *vp, char *pvp, char *rp, char *prp,
- size_t buf_size, struct dm_config_node *root,
- struct dm_hash_table *ht)
+ size_t buf_size, struct dm_config_node *root)
{
struct dm_config_node *cn;
int valid, r = 1;
@@ -687,10 +686,10 @@ static int _config_def_check_tree(struct cft_check_handle *handle,
for (cn = root->child; cn; cn = cn->sib) {
if ((valid = _config_def_check_node(handle, vp, pvp, rp, prp,
- buf_size, cn, ht)) && !cn->v) {
+ buf_size, cn)) && !cn->v) {
len = strlen(rp);
valid = _config_def_check_tree(handle, vp, pvp + strlen(pvp),
- rp, prp + len, buf_size - len, cn, ht);
+ rp, prp + len, buf_size - len, cn);
}
if (!valid)
r = 0;
@@ -699,7 +698,7 @@ static int _config_def_check_tree(struct cft_check_handle *handle,
return r;
}
-int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle)
+int config_def_check(struct cft_check_handle *handle)
{
cfg_def_item_t *def;
struct dm_config_node *cn;
@@ -724,7 +723,7 @@ int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle)
return handle->status[root_CFG_SECTION] & CFG_VALID;
/* Nothing to do if checks are disabled and also not forced. */
- if (!handle->force_check && !find_config_tree_bool(cmd, config_checks_CFG, NULL))
+ if (!handle->force_check && !find_config_tree_bool(handle->cmd, config_checks_CFG, NULL))
return 1;
/* Clear 'used' and 'valid' status flags. */
@@ -736,19 +735,19 @@ int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle)
* sections and settings with full path as a key.
* If section name is variable, use '#' as a substitute.
*/
- if (!cmd->cft_def_hash) {
- if (!(cmd->cft_def_hash = dm_hash_create(64))) {
+ if (!handle->cmd->cft_def_hash) {
+ if (!(handle->cmd->cft_def_hash = dm_hash_create(64))) {
log_error("Failed to create configuration definition hash.");
r = 0; goto out;
}
for (id = 1; id < CFG_COUNT; id++) {
def = cfg_def_get_item_p(id);
if (!_cfg_def_make_path(vp, CFG_PATH_MAX_LEN, def->id, def, 0)) {
- dm_hash_destroy(cmd->cft_def_hash);
- cmd->cft_def_hash = NULL;
+ dm_hash_destroy(handle->cmd->cft_def_hash);
+ handle->cmd->cft_def_hash = NULL;
r = 0; goto out;
}
- if (!dm_hash_insert(cmd->cft_def_hash, vp, def)) {
+ if (!dm_hash_insert(handle->cmd->cft_def_hash, vp, def)) {
log_error("Failed to insert configuration to hash.");
r = 0;
goto out;
@@ -772,16 +771,14 @@ int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle)
if (!cn->v) {
/* top level node: vp=vp, rp=rp */
if (!_config_def_check_node(handle, vp, vp, rp, rp,
- CFG_PATH_MAX_LEN,
- cn, cmd->cft_def_hash)) {
+ CFG_PATH_MAX_LEN, cn)) {
r = 0; continue;
}
rplen = strlen(rp);
if (!_config_def_check_tree(handle,
vp, vp + strlen(vp),
rp, rp + rplen,
- CFG_PATH_MAX_LEN - rplen,
- cn, cmd->cft_def_hash))
+ CFG_PATH_MAX_LEN - rplen, cn))
r = 0;
} else {
log_error_suppress(handle->suppress_messages,
@@ -1478,6 +1475,7 @@ static int _check_profile(struct cmd_context *cmd, struct profile *profile)
return 0;
}
+ handle->cmd = cmd;
handle->cft = profile->cft;
handle->source = CONFIG_PROFILE;
/* the check is compulsory - allow only profilable items in a profile config! */
@@ -1485,7 +1483,7 @@ static int _check_profile(struct cmd_context *cmd, struct profile *profile)
/* provide warning messages only if config/checks=1 */
handle->suppress_messages = !find_config_tree_bool(cmd, config_checks_CFG, NULL);
- r = config_def_check(cmd, handle);
+ r = config_def_check(handle);
dm_pool_free(cmd->libmem, handle);
return r;
diff --git a/lib/config/config.h b/lib/config/config.h
index 5bfa345..e5bcab8 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -165,6 +165,7 @@ int load_pending_profiles(struct cmd_context *cmd);
/* configuration check handle for each instance of the validation check */
struct cft_check_handle {
+ struct cmd_context *cmd; /* command context */
struct dm_config_tree *cft; /* the tree for which the check is done */
config_source_t source; /* configuration source */
unsigned force_check:1; /* force check even if disabled by config/checks setting */
@@ -174,7 +175,7 @@ struct cft_check_handle {
};
int config_def_get_path(char *buf, size_t buf_size, int id);
-int config_def_check(struct cmd_context *cmd, struct cft_check_handle *handle);
+int config_def_check(struct cft_check_handle *handle);
int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings);
int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index d9aebd9..7404462 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -47,6 +47,7 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, s
log_error("Configuration check handle allocation failed.");
return NULL;
}
+ handle->cmd = cmd;
handle->cft = cft;
if (cft == cmd->cft)
cmd->cft_check_handle = handle;
@@ -67,7 +68,7 @@ static int _do_def_check(struct cmd_context *cmd, struct dm_config_tree *cft,
handle->skip_if_checked = 1;
handle->suppress_messages = 1;
- config_def_check(cmd, handle);
+ config_def_check(handle);
*cft_check_handle = handle;
return 1;
@@ -155,7 +156,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
cft_check_handle->skip_if_checked = 1;
cft_check_handle->suppress_messages = 0;
- if (config_def_check(cmd, cft_check_handle)) {
+ if (config_def_check(cft_check_handle)) {
log_print("LVM configuration valid.");
goto out;
} else {
9 years, 8 months
master - cleanup: indent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b6eb2ac10ab509...
Commit: b6eb2ac10ab509a74f83b9333ff195b63d64d8ef
Parent: 852a2b98be2c83a3ddb31396f49854a3d14cf6ed
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 00:24:09 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:58:02 2014 +0100
cleanup: indent
---
lib/metadata/metadata.c | 4 ++--
tools/pvdisplay.c | 16 ++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index c79f223..279043b 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4157,7 +4157,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
uint64_t status_flags, uint32_t misc_flags)
{
struct volume_group *vg = NULL;
- int consistent = 1;
+ int consistent = 1;
int consistent_in;
uint32_t failure = 0;
int already_locked;
@@ -4279,7 +4279,7 @@ bad:
* *consistent = 1.
*/
struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
- const char *vgid, uint32_t flags)
+ const char *vgid, uint32_t flags)
{
uint64_t status = UINT64_C(0);
uint32_t lock_flags = LCK_VG_READ;
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 198267c..34ec3d5 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -36,18 +36,18 @@ static int _pvdisplay_single(struct cmd_context *cmd,
return ret;
}
- /*
+ /*
* Replace possibly incomplete PV structure with new one
* allocated in vg_read_internal() path.
*/
- if (!(pvl = find_pv_in_vg(vg, pv_name))) {
- log_error("Unable to find \"%s\" in volume group \"%s\"",
- pv_name, vg->name);
- ret = ECMD_FAILED;
- goto out;
- }
-
- pv = pvl->pv;
+ if (!(pvl = find_pv_in_vg(vg, pv_name))) {
+ log_error("Unable to find \"%s\" in volume group \"%s\"",
+ pv_name, vg->name);
+ ret = ECMD_FAILED;
+ goto out;
+ }
+
+ pv = pvl->pv;
}
if (is_orphan(pv))
9 years, 8 months
master - pvscan: cleanup updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=852a2b98be2c83...
Commit: 852a2b98be2c83a3ddb31396f49854a3d14cf6ed
Parent: 3d7eaf9226d6e425721f12da5ff4cd47209324df
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 00:19:01 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:58:02 2014 +0100
pvscan: cleanup updates
Simplify code:
remove unneeded assignments
use unsigned values for length
---
tools/pvscan.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index cb2f3f9..6a74ac0 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -18,8 +18,8 @@
#include "lvmetad.h"
#include "lvmcache.h"
-int pv_max_name_len = 0;
-int vg_max_name_len = 0;
+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,
@@ -34,7 +34,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
/* short listing? */
if (arg_count(cmd, short_ARG) > 0) {
- log_print_unless_silent("%s", pv_dev_name(pv));
+ log_print_unless_silent("%s", pvdevname);
return;
}
@@ -331,10 +331,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
uint64_t size_total = 0;
uint64_t size_new = 0;
-
- int len = 0;
- pv_max_name_len = 0;
- vg_max_name_len = 0;
+ unsigned len;
if (arg_count(cmd, cache_ARG))
return _pvscan_lvmetad(cmd, argc, argv);
@@ -429,18 +426,15 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
free_pv_fid(pvl->pv);
}
- if (!pvs_found) {
+ if (!pvs_found)
log_print_unless_silent("No matching physical volumes found");
- unlock_vg(cmd, VG_GLOBAL);
- return ECMD_PROCESSED;
- }
-
- 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));
+ 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));
unlock_vg(cmd, VG_GLOBAL);
9 years, 8 months
master - pvscan: fix report of long pv names
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3d7eaf9226d6e4...
Commit: 3d7eaf9226d6e425721f12da5ff4cd47209324df
Parent: caf93eb1cb74050658dcf1816254ae3666aa3818
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 00:17:36 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:58:01 2014 +0100
pvscan: fix report of long pv names
pvscan --uuid was broken since it was using only 128 char buffers
without checking any write size, so any longer device path leads to
crash.
Also ansure format is properly aligned into columns with this option.
---
WHATS_NEW | 1 +
tools/pvscan.c | 57 ++++++++++++++++++++++++-------------------------------
2 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2492598..b7040d7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix memory corruption when pvscan reports long pv names.
Do not report internal orphan VG names when reporting pvdisplay/pvscan.
Fix pvdisplay -c man page referencing KB instead of sectors.
Skip redundant synchronization calls on local clvmd.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 5db627a..cb2f3f9 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -25,12 +25,12 @@ static void _pvscan_display_single(struct cmd_context *cmd,
struct physical_volume *pv,
void *handle __attribute__((unused)))
{
- char uuid[64] __attribute__((aligned(8)));
- unsigned vg_name_len = 0;
-
- char pv_tmp_name[NAME_LEN] = { 0 };
- char vg_tmp_name[NAME_LEN] = { 0 };
- char vg_name_this[NAME_LEN] = { 0 };
+ /* 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 char *pvdevname = pv_dev_name(pv);
/* short listing? */
if (arg_count(cmd, short_ARG) > 0) {
@@ -49,46 +49,39 @@ static void _pvscan_display_single(struct cmd_context *cmd,
/* return; */
}
- vg_name_len = strlen(pv_vg_name(pv)) + 1;
-
if (arg_count(cmd, uuid_ARG)) {
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
stack;
return;
}
- sprintf(pv_tmp_name, "%-*s with UUID %s",
- pv_max_name_len - 2, pv_dev_name(pv), uuid);
- } else {
- sprintf(pv_tmp_name, "%s", pv_dev_name(pv));
+ if (dm_snprintf(pv_tmp_name, sizeof(pv_tmp_name), "%-*s with UUID %s",
+ pv_max_name_len - 2, pvdevname, uuid) < 0) {
+ log_error("Invalid PV name with uuid.");
+ return;
+ }
+ pvdevname = pv_tmp_name;
+ pv_len += suffix;
}
- if (is_orphan(pv)) {
+ if (is_orphan(pv))
log_print_unless_silent("PV %-*s %-*s %s [%s]",
- pv_max_name_len, pv_tmp_name,
+ pv_len, pvdevname,
vg_max_name_len, " ",
pv->fmt ? pv->fmt->name : " ",
display_size(cmd, pv_size(pv)));
- return;
- }
-
- if (pv_status(pv) & EXPORTED_VG) {
- strncpy(vg_name_this, pv_vg_name(pv), vg_name_len);
- log_print_unless_silent("PV %-*s is in exported VG %s "
- "[%s / %s free]",
- pv_max_name_len, pv_tmp_name,
- vg_name_this,
+ else if (pv_status(pv) & EXPORTED_VG)
+ log_print_unless_silent("PV %-*s is in exported VG %s [%s / %s free]",
+ pv_len, pvdevname, pv_vg_name(pv),
+ 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)));
+ else
+ log_print_unless_silent("PV %-*s VG %-*s %s [%s / %s free]",
+ pv_len, pvdevname,
+ 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;
- }
-
- sprintf(vg_tmp_name, "%s", pv_vg_name(pv));
- log_print_unless_silent("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
- pv_tmp_name, vg_max_name_len, vg_tmp_name,
- 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)));
}
#define REFRESH_BEFORE_AUTOACTIVATION_RETRIES 5
9 years, 8 months
master - cleanup: simplify pv name print
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=caf93eb1cb7405...
Commit: caf93eb1cb74050658dcf1816254ae3666aa3818
Parent: 506091be70b3ebaed02c5d9c1c8fa991f4382182
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 00:01:00 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:58:01 2014 +0100
cleanup: simplify pv name print
pv_vg_name() now already hides orphans.
---
lib/metadata/metadata.c | 2 +-
lib/metadata/pv_manip.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index ff14e16..c79f223 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1408,7 +1408,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
log_warn("WARNING: Forcing physical volume creation on "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
- !is_orphan(pv) ? pv_vg_name(pv) : "",
+ pv_vg_name(pv),
!is_orphan(pv) ? "\"" : "");
}
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index cb19be2..3613515 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -716,7 +716,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
log_warn("WARNING: Wiping physical volume label from "
"%s%s%s%s", name,
!is_orphan(pv) ? " of volume group \"" : "",
- !is_orphan(pv) ? pv_vg_name(pv) : "",
+ pv_vg_name(pv),
!is_orphan(pv) ? "\"" : "");
}
9 years, 8 months
master - pv_vg_name: do not expose internal orphans to lvm2 users
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=506091be70b3eb...
Commit: 506091be70b3ebaed02c5d9c1c8fa991f4382182
Parent: 5b69bfb6f867944e7831a653f6aa4b17853fbbe5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 18 23:54:46 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:57:59 2014 +0100
pv_vg_name: do not expose internal orphans to lvm2 users
Check for orphan VG name and return just empty string,
Use internally pv->vg_name if the real orphan name is needed.
---
WHATS_NEW | 1 +
lib/display/display.c | 2 +-
lib/metadata/metadata.c | 2 +-
lib/metadata/pv.c | 3 ++-
lib/metadata/pv_manip.c | 2 +-
5 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index adf446a..2492598 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Do not report internal orphan VG names when reporting pvdisplay/pvscan.
Fix pvdisplay -c man page referencing KB instead of sectors.
Skip redundant synchronization calls on local clvmd.
Use correct PATH_MAX for locking dir path.
diff --git a/lib/display/display.c b/lib/display/display.c
index 66acb88..d2450dd 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -362,7 +362,7 @@ void pvdisplay_colons(const struct physical_volume *pv)
}
log_print("%s:%s:%" PRIu64 ":-1:%" PRIu64 ":%" PRIu64 ":-1:%" PRIu32 ":%u:%u:%u:%s",
- pv_dev_name(pv), pv->vg_name, pv->size,
+ pv_dev_name(pv), pv_vg_name(pv), pv->size,
/* FIXME pv->pv_number, Derive or remove? */
pv->status, /* FIXME Support old or new format here? */
pv->status & ALLOCATABLE_PV, /* FIXME remove? */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index b5e2ed6..ff14e16 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3947,7 +3947,7 @@ int pv_write(struct cmd_context *cmd __attribute__((unused)),
if (!allow_non_orphan &&
(!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count)) {
log_error("Assertion failed: can't _pv_write non-orphan PV "
- "(in VG %s)", pv->vg_name);
+ "(in VG %s)", pv_vg_name(pv));
return 0;
}
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c
index 45acef4..774cedb 100644
--- a/lib/metadata/pv.c
+++ b/lib/metadata/pv.c
@@ -69,7 +69,8 @@ struct device *pv_dev(const struct physical_volume *pv)
const char *pv_vg_name(const struct physical_volume *pv)
{
- return pv_field(pv, vg_name);
+ /* Avoid exposing internal orphan names to users */
+ return (!is_orphan(pv)) ? pv_field(pv, vg_name) : "";
}
const char *pv_dev_name(const struct physical_volume *pv)
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index d0c3b44..cb19be2 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -558,7 +558,7 @@ int pv_resize_single(struct cmd_context *cmd,
uint64_t size = 0;
int r = 0;
const char *pv_name = pv_dev_name(pv);
- const char *vg_name = pv_vg_name(pv);
+ const char *vg_name = pv->vg_name;
struct volume_group *old_vg = vg;
int vg_needs_pv_write = 0;
9 years, 8 months
master - pvdisplay: fix man to refer to sectors, not KB
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5b69bfb6f86794...
Commit: 5b69bfb6f867944e7831a653f6aa4b17853fbbe5
Parent: 52525bde04e72245224546caaacde2a3b15cad9d
Author: Thomas Fehr <fehr(a)suse.de>
AuthorDate: Tue Mar 18 09:24:01 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:49:32 2014 +0100
pvdisplay: fix man to refer to sectors, not KB
The PV size is displayed in sectors, not kilobytes
for 'pvdisplay -c'
Signed-off-by: Thomas Fehr <fehr(a)suse.de>
Acked-by: Hannes Reinecke <hare(a)suse.de>
---
WHATS_NEW | 1 +
man/pvdisplay.8.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 08d5b1d..adf446a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix pvdisplay -c man page referencing KB instead of sectors.
Skip redundant synchronization calls on local clvmd.
Use correct PATH_MAX for locking dir path.
Do not check for backups when when its creation is disabled.
diff --git a/man/pvdisplay.8.in b/man/pvdisplay.8.in
index 03c12c4..13c26b5 100644
--- a/man/pvdisplay.8.in
+++ b/man/pvdisplay.8.in
@@ -65,7 +65,7 @@ The values are:
* physical volume device name
* volume group name
-* physical volume size in kilobytes
+* physical volume size in sectors
* internal physical volume number (obsolete)
* physical volume status
* physical volume (not) allocatable
9 years, 8 months
master - pvdisplay: use log_print_unless_silent for info messages
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=52525bde04e722...
Commit: 52525bde04e72245224546caaacde2a3b15cad9d
Parent: 013f5f4550816b0ac0d7f7a92ce763624b351319
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 19 00:35:27 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 19 00:48:39 2014 +0100
pvdisplay: use log_print_unless_silent for info messages
---
tools/pvdisplay.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 35fb75b..198267c 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -63,12 +63,12 @@ static int _pvdisplay_single(struct cmd_context *cmd,
}
if (pv_status(pv) & EXPORTED_VG)
- log_print("Physical volume \"%s\" of volume group \"%s\" "
- "is exported", pv_name, pv_vg_name(pv));
+ log_print_unless_silent("Physical volume \"%s\" of volume group \"%s\" "
+ "is exported", pv_name, pv_vg_name(pv));
if (is_orphan(pv))
- log_print("\"%s\" is a new physical volume of \"%s\"",
- pv_name, display_size(cmd, size));
+ log_print_unless_silent("\"%s\" is a new physical volume of \"%s\"",
+ pv_name, display_size(cmd, size));
if (arg_count(cmd, colon_ARG)) {
pvdisplay_colons(pv);
9 years, 8 months