master - cleanup: convert log_error with log_warn
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6bf6430ae94e2a...
Commit: 6bf6430ae94e2a0e8239b198e35b53abbaa3f041
Parent: 5bdbaf4ed7a0f8b8e032d4f8d76bb63f8ec071b8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 14:34:34 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:48:01 2013 +0100
cleanup: convert log_error with log_warn
Collapse 2 ifs and replace log_error() with log_warn(), since\
the reported message is not causing tools error.
(and cannot be probably triggered anyway).
---
lib/activate/dev_manager.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index e53273d..bed4d60 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -112,9 +112,9 @@ static int _info_run(const char *name, const char *dlid, struct dm_info *info,
if (!(dmt = _setup_task(mknodes ? name : NULL, dlid, 0, dmtask, major, minor)))
return_0;
- if (!with_open_count)
- if (!dm_task_no_open_count(dmt))
- log_error("Failed to disable open_count");
+ if (!with_open_count &&
+ !dm_task_no_open_count(dmt))
+ log_warn("WARNING: Failed to disable open_count.");
if (!dm_task_run(dmt))
goto_out;
10 years, 5 months
master - cleanup: convert log_sys_error to log_sys_debug
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5bdbaf4ed7a0f8...
Commit: 5bdbaf4ed7a0f8b8e032d4f8d76bb63f8ec071b8
Parent: 6c787d9b6ed9c9ef2964431881884dd3879f4dc1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 13:46:34 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:48:01 2013 +0100
cleanup: convert log_sys_error to log_sys_debug
Use debug for those error reports which do not lead to error return
call.
---
daemons/dmeventd/libdevmapper-event.c | 8 ++++----
lib/locking/file_locking.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c
index 9e8911e..1b5273d 100644
--- a/daemons/dmeventd/libdevmapper-event.c
+++ b/daemons/dmeventd/libdevmapper-event.c
@@ -425,7 +425,7 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
if (fifos->client >= 0) {
/* server is running and listening */
if (close(fifos->client))
- log_sys_error("close", fifos->client_path);
+ log_sys_debug("close", fifos->client_path);
return 1;
} else if (errno != ENXIO) {
/* problem */
@@ -507,14 +507,14 @@ static int _init_client(char *dmeventd_path, struct dm_event_fifos *fifos)
void fini_fifos(struct dm_event_fifos *fifos)
{
if (fifos->client >= 0 && close(fifos->client))
- log_sys_error("close", fifos->client_path);
+ log_sys_debug("close", fifos->client_path);
if (fifos->server >= 0) {
if (flock(fifos->server, LOCK_UN))
- log_sys_error("flock unlock", fifos->server_path);
+ log_sys_debug("flock unlock", fifos->server_path);
if (close(fifos->server))
- log_sys_error("close", fifos->server_path);
+ log_sys_debug("close", fifos->server_path);
}
}
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 3fa0a2d..1fa23b3 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -54,10 +54,10 @@ static void _undo_flock(const char *file, int fd)
!fstat(fd, &buf2) &&
is_same_inode(buf1, buf2))
if (unlink(file))
- log_sys_error("unlink", file);
+ log_sys_debug("unlink", file);
if (close(fd) < 0)
- log_sys_error("close", file);
+ log_sys_debug("close", file);
}
static int _release_lock(const char *file, int unlock)
@@ -73,7 +73,7 @@ static int _release_lock(const char *file, int unlock)
if (unlock) {
log_very_verbose("Unlocking %s", ll->res);
if (flock(ll->lf, LOCK_NB | LOCK_UN))
- log_sys_error("flock", ll->res);
+ log_sys_debug("flock", ll->res);
}
_undo_flock(ll->res, ll->lf);
@@ -141,7 +141,7 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
operation == LOCK_EX ? 'W' : 'R', nonblock ? ' ' : 'B');
do {
if ((*fd > -1) && close(*fd))
- log_sys_error("close", file);
+ log_sys_debug("close", file);
if ((*fd = open(file, O_CREAT | O_APPEND | O_RDWR, 0777)) < 0) {
log_sys_error("open", file);
@@ -162,7 +162,7 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
errno = old_errno;
log_sys_error("flock", file);
if (close(*fd))
- log_sys_error("close", file);
+ log_sys_debug("close", file);
*fd = -1;
return 0;
}
10 years, 5 months
master - cleanup: move declaration to the front
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6c787d9b6ed9c9...
Commit: 6c787d9b6ed9c9ef2964431881884dd3879f4dc1
Parent: 50e1fad86a5ca85965222d2ba9b8a7076d07cbbc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 13:43:25 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:48:01 2013 +0100
cleanup: move declaration to the front
---
daemons/lvmetad/lvmetad-core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 87374e8..7e64d9d 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -791,7 +791,7 @@ static response pv_gone(lvmetad_state *s, request r)
const char *pvid = daemon_request_str(r, "uuid", NULL);
int64_t device = daemon_request_int(r, "device", 0);
struct dm_config_tree *pvmeta;
- char *pvid_old;
+ char *pvid_old, *vgid;
DEBUGLOG(s, "pv_gone: %s / %" PRIu64, pvid, device);
@@ -807,7 +807,7 @@ static response pv_gone(lvmetad_state *s, request r)
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
- char *vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
+ vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
if (vgid && !(vgid = dm_strdup(vgid))) {
unlock_pvid_to_pvmeta(s);
10 years, 5 months
master - cleanup: use matching signed types
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=50e1fad86a5ca8...
Commit: 50e1fad86a5ca85965222d2ba9b8a7076d07cbbc
Parent: c6cfd7b2b93645a96db74f90d57bc5031704c298
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 13:42:30 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:47:51 2013 +0100
cleanup: use matching signed types
---
daemons/clvmd/clvmd.c | 2 +-
lib/metadata/mirror.c | 2 +-
libdaemon/server/daemon-log.c | 4 ++--
tools/lvconvert.c | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index d57c0fd..fc8cf6e 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1095,7 +1095,7 @@ static int verify_message(char *buf, int len)
{
struct clvm_header *h = (struct clvm_header *)buf;
- if (len < sizeof(struct clvm_header)) {
+ if (len < (int)sizeof(struct clvm_header)) {
log_error("verify_message short len %d", len);
return -1;
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index a2b2feb..6fc7674 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -847,7 +847,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
uint32_t new_area_count = mirrored_seg->area_count;
struct lv_list *lvl;
struct dm_list tmp_orphan_lvs;
- int orig_removed = num_removed;
+ uint32_t orig_removed = num_removed;
if (removed)
*removed = 0;
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index c9e133c..91900af 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -51,7 +51,7 @@ struct backend backend[] = {
void daemon_log(log_state *s, int type, const char *message) {
int i = 0;
while ( backend[i].id ) {
- if ( (s->log_config[type] & backend[i].id) == backend[i].id )
+ if ((int)(s->log_config[type] & backend[i].id) == backend[i].id )
backend[i].log( s, &s->backend_state[i], type, message );
++ i;
}
@@ -60,7 +60,7 @@ void daemon_log(log_state *s, int type, const char *message) {
static int _type_interesting(log_state *s, int type) {
int i = 0;
while ( backend[i].id ) {
- if ( (s->log_config[type] & backend[i].id) == backend[i].id )
+ if ((int)(s->log_config[type] & backend[i].id) == backend[i].id )
return 1;
++ i;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 9a542a6..6f81356 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -958,7 +958,7 @@ static void _lvconvert_mirrors_repair_ask(struct cmd_context *cmd,
* 1 = 'disk'
* 2+ = 'mirrored'
*/
-static int _get_log_count(struct logical_volume *lv)
+static uint32_t _get_log_count(struct logical_volume *lv)
{
struct logical_volume *log_lv;
@@ -1434,7 +1434,7 @@ int mirror_remove_missing(struct cmd_context *cmd,
if (!(failed_pvs = _failed_pv_list(lv->vg)))
return_0;
- if (force && _failed_mirrors_count(lv) == lv_mirror_count(lv)) {
+ if (force && _failed_mirrors_count(lv) == (int)lv_mirror_count(lv)) {
log_error("No usable images left in %s.", lv->name);
return lv_remove_with_dependencies(cmd, lv, DONT_PROMPT, 0);
}
10 years, 5 months
master - cleanup: drop extra dm_list_empty
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c6cfd7b2b93645...
Commit: c6cfd7b2b93645a96db74f90d57bc5031704c298
Parent: bfcf3edcc69243cfcef6e73e8bbcba0e60366802
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 24 19:03:29 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:52 2013 +0100
cleanup: drop extra dm_list_empty
Since dm_list_first has this check already include,
skip extra call in while().
Moreover analyzers are then sure pvl is not NULL.
---
lib/metadata/metadata.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 60be61e..d55dba1 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2798,8 +2798,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
baton.warnings = warnings;
baton.vg = vg;
- while (!dm_list_empty(&head.list)) {
- pvl = (struct pv_list *) dm_list_first(&head.list);
+ while ((pvl = (struct pv_list *) dm_list_first(&head.list))) {
dm_list_del(&pvl->list);
add_pvl_to_vgs(vg, pvl);
vg->extent_count += pvl->pv->pe_count;
10 years, 5 months
master - cleanup: fold test into printf arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bfcf3edcc69243...
Commit: bfcf3edcc69243cfcef6e73e8bbcba0e60366802
Parent: 8c96afd361686647e10f3bf70c03dea62b82bc01
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 24 18:59:46 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:52 2013 +0100
cleanup: fold test into printf arg
When arg is folded, compiler is able to check all args.
(better for security)
---
lib/metadata/metadata.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5c87ab6..60be61e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -43,9 +43,6 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
uint64_t status);
-const char _really_init[] =
- "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
-
static int _alignment_overrides_default(unsigned long data_alignment,
unsigned long default_pe_align)
{
@@ -1294,7 +1291,8 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
/* prompt */
if (pv && !is_orphan(pv) && !pp->yes &&
- yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
+ yes_no_prompt("Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ",
+ name, pv_vg_name(pv)) == 'n') {
log_error("%s: physical volume not initialized", name);
goto bad;
}
10 years, 5 months
master - cleanup: use compound literals for wipe_lv
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c96afd3616866...
Commit: 8c96afd361686647e10f3bf70c03dea62b82bc01
Parent: a1eda8ea245ec7af684fb50e7f0abf5229d9bcfb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 28 11:22:24 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:52 2013 +0100
cleanup: use compound literals for wipe_lv
Optimize and cleanup recently introduced new function wipe_lv.
Use compound literals to get nicely initialized wipe_params struct.
Pass in lv as explicit argument for wipe_lv.
Use cmd from lv structure.
Initialize only non-null members so it's easy to see what
is the special arg.
---
lib/metadata/lv_manip.c | 73 ++++++++++++++-----------------------
lib/metadata/metadata-exported.h | 5 +--
lib/metadata/mirror.c | 13 ++-----
lib/metadata/raid_manip.c | 11 +-----
lib/metadata/thin_manip.c | 13 +------
tools/lvchange.c | 13 +------
tools/lvconvert.c | 27 ++------------
7 files changed, 40 insertions(+), 115 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2480942..1fec9a5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2906,17 +2906,8 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
* wipe '1' to remove the superblock of any previous
* RAID devices. It is much quicker.
*/
- struct wipe_lv_params wp = {
- .lv = meta_lv,
- .do_zero = 1,
- .zero_sectors = 1,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
-
- if (!wipe_lv(meta_lv->vg->cmd, &wp)) {
+ if (!wipe_lv(meta_lv, (struct wipe_params)
+ { .do_zero = 1, .zero_sectors = 1 })) {
log_error("Failed to zero %s/%s",
meta_lv->vg->name, meta_lv->name);
return 0;
@@ -5382,19 +5373,19 @@ int insert_layer_for_segments_on_pv(struct cmd_context *cmd,
/*
* Initialize the LV with 'value'.
*/
-int wipe_lv(struct cmd_context *cmd, struct wipe_lv_params *wp)
+int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
{
struct device *dev;
- char *name;
+ char name[PATH_MAX];
uint64_t zero_sectors;
- if (!(wp->do_zero || wp->do_wipe_signatures))
+ if (!wp.do_zero && !wp.do_wipe_signatures)
/* nothing to do */
return 1;
- if (!lv_is_active_locally(wp->lv)) {
+ if (!lv_is_active_locally(lv)) {
log_error("Volume \"%s/%s\" is not active locally.",
- wp->lv->vg->name, wp->lv->name);
+ lv->vg->name, lv->name);
return 0;
}
@@ -5405,18 +5396,13 @@ int wipe_lv(struct cmd_context *cmd, struct wipe_lv_params *wp)
* <ejt_> k, I'll drop a fixme to that effect
* (I know the device is at least 4k, but not 32k)
*/
- if (!(name = dm_pool_alloc(cmd->mem, PATH_MAX))) {
- log_error("Name allocation failed - device not cleared");
- return 0;
- }
-
- if (dm_snprintf(name, PATH_MAX, "%s%s/%s", cmd->dev_dir,
- wp->lv->vg->name, wp->lv->name) < 0) {
- log_error("Name too long - device not cleared (%s)", wp->lv->name);
+ if (dm_snprintf(name, sizeof(name), "%s%s/%s", lv->vg->cmd->dev_dir,
+ lv->vg->name, lv->name) < 0) {
+ log_error("Name too long - device not cleared (%s)", lv->name);
return 0;
}
- sync_local_dev_names(cmd); /* Wait until devices are available */
+ sync_local_dev_names(lv->vg->cmd); /* Wait until devices are available */
if (!(dev = dev_cache_get(name, NULL))) {
log_error("%s: not found: device not cleared", name);
@@ -5426,23 +5412,23 @@ int wipe_lv(struct cmd_context *cmd, struct wipe_lv_params *wp)
if (!dev_open_quiet(dev))
return_0;
- if (wp->do_wipe_signatures) {
+ if (wp.do_wipe_signatures) {
log_verbose("Wiping known signatures on logical volume \"%s/%s\"",
- wp->lv->vg->name, wp->lv->name);
- if (!wipe_known_signatures(cmd, dev, name, wp->yes, wp->force))
+ lv->vg->name, lv->name);
+ if (!wipe_known_signatures(lv->vg->cmd, dev, name, wp.yes, wp.force))
stack;
}
- if (wp->do_zero) {
- zero_sectors = wp->zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
+ if (wp.do_zero) {
+ zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
- if (zero_sectors > wp->lv->size)
- zero_sectors = wp->lv->size;
+ if (zero_sectors > lv->size)
+ zero_sectors = lv->size;
log_verbose("Clearing start of logical volume \"%s/%s\"",
- wp->lv->vg->name, wp->lv->name);
+ lv->vg->name, lv->name);
- if (!dev_set(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp->zero_value))
+ if (!dev_set(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value))
stack;
}
@@ -5451,7 +5437,7 @@ int wipe_lv(struct cmd_context *cmd, struct wipe_lv_params *wp)
if (!dev_close_immediate(dev))
stack;
- wp->lv->status &= ~LV_NOSCAN;
+ lv->status &= ~LV_NOSCAN;
return 1;
}
@@ -6094,16 +6080,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if ((!seg_is_thin(lp) ||
(lv_is_thin_volume(lv) && !lp->snapshot &&
!first_seg(first_seg(lv)->pool_lv)->zero_new_blocks))) {
- struct wipe_lv_params wp = {
- .lv = lv,
- .do_zero = lp->zero,
- .zero_sectors = 0,
- .zero_value = 0,
- .do_wipe_signatures = lp->wipe_signatures,
- .yes = lp->yes,
- .force = lp->force
- };
- if (!wipe_lv(cmd, &wp)) {
+ if (!wipe_lv(lv, (struct wipe_params)
+ {
+ .do_zero = lp->zero,
+ .do_wipe_signatures = lp->wipe_signatures,
+ .yes = lp->yes,
+ .force = lp->force
+ })) {
log_error("Aborting. Failed to wipe %s.",
lp->snapshot ? "snapshot exception store" :
"start of new LV");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c274649..ece5f53 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -622,8 +622,7 @@ struct logical_volume *lv_create_empty(const char *name,
alloc_policy_t alloc,
struct volume_group *vg);
-struct wipe_lv_params {
- struct logical_volume *lv;
+struct wipe_params {
int do_zero; /* should we do zeroing of LV start? */
uint64_t zero_sectors; /* sector count to zero */
int zero_value; /* zero-out with this value */
@@ -633,7 +632,7 @@ struct wipe_lv_params {
};
/* Zero out LV and/or wipe signatures */
-int wipe_lv(struct cmd_context *cmd, struct wipe_lv_params *params);
+int wipe_lv(struct logical_volume *lv, struct wipe_params params);
int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag);
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 83ba486..a2b2feb 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -340,16 +340,9 @@ static int _init_mirror_log(struct cmd_context *cmd,
str_list_del(&log_lv->tags, sl->str);
if (activation()) {
- struct wipe_lv_params wp = {
- .lv = log_lv,
- .do_zero = 1,
- .zero_sectors = log_lv->size,
- .zero_value = in_sync ? -1 : 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
- if (!wipe_lv(cmd, &wp)) {
+ if (!wipe_lv(log_lv, (struct wipe_params)
+ { .do_zero = 1, .zero_sectors = log_lv->size,
+ .zero_value = in_sync ? -1 : 0 })) {
log_error("Aborting. Failed to wipe mirror log.");
goto deactivate_and_revert_new_lv;
}
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index d1bb330..a29ea85 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -170,15 +170,6 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
static int _clear_lv(struct logical_volume *lv)
{
int was_active = lv_is_active_locally(lv);
- struct wipe_lv_params wp = {
- .lv = lv,
- .do_zero = 1,
- .zero_sectors = 1,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
if (test_mode())
return 1;
@@ -196,7 +187,7 @@ static int _clear_lv(struct logical_volume *lv)
* wipe the first sector to remove the superblock of any previous
* RAID devices. It is much quicker.
*/
- if (!wipe_lv(lv->vg->cmd, &wp)) {
+ if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1, .zero_sectors = 1 })) {
log_error("Failed to zero %s", lv->name);
return 0;
}
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 4ee4411..b3fedcf 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -467,21 +467,10 @@ int create_pool(struct logical_volume *pool_lv, const struct segment_type *segty
*
* FIXME: implement lazy clearing when activation is disabled
*/
-
- struct wipe_lv_params wp = {
- .lv = pool_lv,
- .do_zero = 1,
- .zero_sectors = 0,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
-
/* pool_lv is a new LV so the VG lock protects us */
if (!activate_lv_local(pool_lv->vg->cmd, pool_lv) ||
/* Clear 4KB of metadata device for new thin-pool. */
- !wipe_lv(pool_lv->vg->cmd, &wp)) {
+ !wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe pool metadata %s.",
pool_lv->name);
goto bad;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 59a554c..a0e350f 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -479,17 +479,8 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
(seg_is_raid(seg)) ? "metadata" : "log",
lvl->lv->name);
- struct wipe_lv_params wp = {
- .lv = lvl->lv,
- .do_zero = 1,
- .zero_sectors = lvl->lv->size,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
-
- if (!wipe_lv(cmd, &wp)) {
+ if (!wipe_lv(lvl->lv, (struct wipe_params)
+ { .do_zero = 1, .zero_sectors = lvl->lv->size })) {
log_error("Unable to reset sync status for %s",
lv->name);
if (!deactivate_lv(cmd, lvl->lv))
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 34c8de2..9a542a6 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1847,22 +1847,10 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
if (!lp->zero || !(lv->status & LVM_WRITE))
log_warn("WARNING: \"%s\" not zeroed", lv->name);
- else {
- struct wipe_lv_params wp = {
- .lv = lv,
- .do_zero = 1,
- .zero_sectors = 0,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
-
- if (!wipe_lv(cmd, &wp)) {
+ else if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe snapshot "
"exception store.");
return 0;
- }
}
if (!deactivate_lv(cmd, lv)) {
@@ -2506,17 +2494,8 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
- struct wipe_lv_params wp = {
- .lv = metadata_lv,
- .do_zero = 1,
- .zero_sectors = 0,
- .zero_value = 0,
- .do_wipe_signatures = 0,
- .yes = 0,
- .force = PROMPT
- };
- if (!wipe_lv(cmd, &wp)) {
+ if (!wipe_lv(metadata_lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe thin metadata lv.");
return 0;
}
10 years, 5 months
master - toollib: drop init of ret
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a1eda8ea245ec7...
Commit: a1eda8ea245ec7af684fb50e7f0abf5229d9bcfb
Parent: 8724c0fcebcc35df980e6819e5c531f213fe2767
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 22 22:27:32 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:52 2013 +0100
toollib: drop init of ret
Keep the ret uninitialized, so we get compiler warning, when tried
to use this value instead of ret_max as function return value.
---
tools/toollib.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 90a7cb8..654384d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -190,7 +190,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
process_single_lv_fn_t process_single_lv)
{
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
unsigned process_all = 0;
unsigned process_lv = 0;
unsigned tags_supplied = 0;
@@ -302,7 +302,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
{
int opt = 0;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
struct dm_list *tags_arg;
struct dm_list *vgnames; /* VGs to process */
@@ -724,7 +724,7 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
process_single_pv_fn_t process_single_pv)
{
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
struct pv_list *pvl;
dm_list_iterate_items(pvl, &vg->pvs) {
@@ -810,7 +810,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
{
int opt = 0;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE) && !lvmetad_active();
struct pv_list *pvl;
@@ -1803,7 +1803,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv, void *han
struct device *dev;
int ret_max = ECMD_PROCESSED;
- int ret = 0;
+ int ret;
int opt = 0;
if (argc) {
10 years, 5 months
master - snapshot: move code of old snapshot merge
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8724c0fcebcc35...
Commit: 8724c0fcebcc35df980e6819e5c531f213fe2767
Parent: b3679590dfb9839196c36ac74b86377ae2a10f8e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 26 12:09:41 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:28 2013 +0100
snapshot: move code of old snapshot merge
Move code for merging old snapshot into its own function.
---
tools/lvconvert.c | 68 ++++++++++++++++++++++++++++------------------------
1 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 051463b..34c8de2 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1884,31 +1884,59 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
return 1;
}
-static int lvconvert_merge(struct cmd_context *cmd,
- struct logical_volume *lv,
- struct lvconvert_params *lp)
+static int _lvconvert_merge_old_snapshot(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct lvconvert_params *lp)
{
int r = 0;
int merge_on_activate = 0;
struct logical_volume *origin = origin_from_cow(lv);
struct lv_segment *snap_seg = find_snapshot(lv);
struct lvinfo info;
+ percent_t snap_percent;
/* Check if merge is possible */
+ if (!lv_is_cow(lv)) {
+ log_error("\"%s\" is not a mergeable logical volume.",
+ lv->name);
+ return 0;
+ }
+
if (lv_is_merging_cow(lv)) {
- log_error("Snapshot %s is already merging", lv->name);
+ log_error("Snapshot %s is already merging.", lv->name);
return 0;
}
+
if (lv_is_merging_origin(origin)) {
log_error("Snapshot %s is already merging into the origin.",
find_snapshot(origin)->cow->name);
return 0;
}
+
if (lv_is_virtual_origin(origin)) {
log_error("Snapshot %s has virtual origin.", lv->name);
return 0;
}
+ if (lv_is_external_origin(origin_from_cow(lv))) {
+ log_error("Cannot merge snapshot \"%s\" into "
+ "the read-only external origin \"%s\".",
+ lv->name, origin_from_cow(lv)->name);
+ return 0;
+ }
+
+ if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0)
+ && info.exists && info.live_table &&
+ (!lv_snapshot_percent(lv, &snap_percent) ||
+ snap_percent == PERCENT_INVALID)) {
+ log_error("Unable to merge invalidated snapshot LV \"%s\".",
+ lv->name);
+ return 0;
+ }
+
+ if (!archive(lv->vg))
+ return_0;
+
/*
* Prevent merge with open device(s) as it would likely lead
* to application/filesystem failure. Merge on origin's next
@@ -1955,7 +1983,7 @@ static int lvconvert_merge(struct cmd_context *cmd,
/* Perform merge */
if (!suspend_lv(cmd, origin)) {
- log_error("Failed to suspend origin %s", origin->name);
+ log_error("Failed to suspend origin %s.", origin->name);
vg_revert(lv->vg);
goto out;
}
@@ -1967,7 +1995,7 @@ static int lvconvert_merge(struct cmd_context *cmd,
}
if (!resume_lv(cmd, origin)) {
- log_error("Failed to reactivate origin %s", origin->name);
+ log_error("Failed to reactivate origin %s.", origin->name);
goto out;
}
@@ -1978,6 +2006,7 @@ static int lvconvert_merge(struct cmd_context *cmd,
log_print_unless_silent("Merging of volume %s started.", lv->name);
out:
backup(lv->vg);
+
return r;
}
@@ -2588,8 +2617,6 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
{
struct lvconvert_params *lp = handle;
struct dm_list *failed_pvs;
- struct lvinfo info;
- percent_t snap_percent;
if (lv->status & LOCKED) {
log_error("Cannot convert locked LV %s", lv->name);
@@ -2634,29 +2661,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
if (lp->merge) {
- if (!lv_is_cow(lv)) {
- log_error("\"%s\" is not a mergeable logical volume",
- lv->name);
- return ECMD_FAILED;
- }
- if (lv_is_external_origin(origin_from_cow(lv))) {
- log_error("Cannot merge snapshot \"%s\" into "
- "the read-only external origin \"%s\".",
- lv->name, origin_from_cow(lv)->name);
- return ECMD_FAILED;
- }
- if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0)
- && info.exists && info.live_table &&
- (!lv_snapshot_percent(lv, &snap_percent) ||
- snap_percent == PERCENT_INVALID)) {
- log_error("Unable to merge invalidated snapshot LV \"%s\"", lv->name);
- return ECMD_FAILED;
- }
- if (!archive(lv->vg))
- return_ECMD_FAILED;
-
- if (!lvconvert_merge(cmd, lv, lp)) {
- log_error("Unable to merge LV \"%s\" into its origin.", lv->name);
+ if (!_lvconvert_merge_old_snapshot(cmd, lv, lp)) {
+ log_print_unless_silent("Unable to merge LV \"%s\" into its origin.", lv->name);
return ECMD_FAILED;
}
} else if (lp->snapshot) {
10 years, 5 months
master - dmeventd: simplify error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b3679590dfb983...
Commit: b3679590dfb9839196c36ac74b86377ae2a10f8e
Parent: 6dae2373034ce3fc11f226c963d81a670043191a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 25 14:24:25 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Nov 28 12:45:02 2013 +0100
dmeventd: simplify error path
Use common 'bad:' label for exit error path where
fifo is closed before exit().
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/dmeventd.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 564419f..1f1cde1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.84 -
====================================
+ Close fifos before exiting in dmeventd restart() error path.
Move printf format string directly into dm_asprintf args list.
Catch invalid use of string sort values when reporting numerical fields.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 301c5f5..f2d6671 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1848,20 +1848,18 @@ static void restart(void)
if (!dm_event_get_version(&fifos, &version)) {
fprintf(stderr, "WARNING: Could not communicate with existing dmeventd.\n");
- fini_fifos(&fifos);
- exit(EXIT_FAILURE);
+ goto bad;
}
if (version < 1) {
fprintf(stderr, "WARNING: The running dmeventd instance is too old.\n"
"Protocol version %d (required: 1). Action cancelled.\n",
version);
- exit(EXIT_FAILURE);
+ goto bad;
}
- if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0)) {
- exit(EXIT_FAILURE);
- }
+ if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
+ goto bad;
message = msg.data;
message = strchr(message, ' ');
@@ -1876,13 +1874,13 @@ static void restart(void)
if (!(_initial_registrations = dm_malloc(sizeof(char*) * (count + 1)))) {
fprintf(stderr, "Memory allocation registration failed.\n");
- exit(EXIT_FAILURE);
+ goto bad;
}
for (i = 0; i < count; ++i) {
if (!(_initial_registrations[i] = dm_strdup(message))) {
fprintf(stderr, "Memory allocation for message failed.\n");
- exit(EXIT_FAILURE);
+ goto bad;
}
message += strlen(message) + 1;
}
@@ -1890,7 +1888,7 @@ static void restart(void)
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0)) {
fprintf(stderr, "Old dmeventd refused to die.\n");
- exit(EXIT_FAILURE);
+ goto bad;
}
/*
@@ -1904,6 +1902,11 @@ static void restart(void)
}
fini_fifos(&fifos);
+
+ return;
+bad:
+ fini_fifos(&fifos);
+ exit(EXIT_FAILURE);
}
static void usage(char *prog, FILE *file)
10 years, 5 months