master - thin: fix resource leak in err path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2b76a6f022920...
Commit: a2b76a6f022920abd59072decfa7d3d76eeda913
Parent: 17a691505467cd5a73059fe5ca22fe50dafd345a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 12:19:25 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:10:30 2013 +0200
thin: fix resource leak in err path
If the devices list could not have been obtained, FILE* was leaked.
---
WHATS_NEW | 1 +
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b016b8e..5d4c7a7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix memleak in dmeventd thin plugin in device list obtaining err path.
Add explicit message about unsupported pvmove for thin/thinpool volumes.
Fix lvmetad error path in lvmetad_vg_lookup() for null vgname.
Fix clvmd _cluster_request() return code in memory fail path.
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index ba72c4a..95ab27a 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -246,7 +246,7 @@ static void _umount(struct dm_task *dmt, const char *device)
{
static const char mountinfo[] = "/proc/self/mountinfo";
static const size_t MINORS = 4096;
- FILE *minfo;
+ FILE *minfo = NULL;
char buffer[4096];
char target[PATH_MAX];
struct dm_info info;
@@ -288,10 +288,10 @@ static void _umount(struct dm_task *dmt, const char *device)
}
}
- if (fclose(minfo))
+out:
+ if (minfo && fclose(minfo))
syslog(LOG_ERR, "Failed to close %s\n", mountinfo);
-out:
if (minors)
dm_bitset_destroy(minors);
dmeventd_lvm2_lock();
9 years, 9 months
master - thin: explicitly avoid pvmove operation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=17a691505467cd...
Commit: 17a691505467cd5a73059fe5ca22fe50dafd345a
Parent: 78a42bac157edba2b68bdfd77ea5c3096845aceb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 08:49:17 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:09:11 2013 +0200
thin: explicitly avoid pvmove operation
So far we do not support pvmove for thin volumes
and thin pools.
---
WHATS_NEW | 1 +
tools/pvmove.c | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 819fea4..b016b8e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add explicit message about unsupported pvmove for thin/thinpool volumes.
Fix lvmetad error path in lvmetad_vg_lookup() for null vgname.
Fix clvmd _cluster_request() return code in memory fail path.
Add writemostly/writebehind support for RAID1
diff --git a/tools/pvmove.c b/tools/pvmove.c
index a733049..5c51c5f 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -248,6 +248,13 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
log_print_unless_silent("Skipping mirror image LV %s", lv->name);
continue;
}
+ if (lv_is_thin_volume(lv) || lv_is_thin_pool(lv)) {
+ lv_skipped = 1;
+ log_print_unless_silent("Skipping thin%s LV %s",
+ lv_is_thin_pool(lv) ? "-pool" : "",
+ lv->name);
+ continue;
+ }
if (lv->status & LOCKED) {
lv_skipped = 1;
log_print_unless_silent("Skipping locked LV %s", lv->name);
9 years, 9 months
master - thin: fix cut&paste bug
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=78a42bac157edb...
Commit: 78a42bac157edba2b68bdfd77ea5c3096845aceb
Parent: 24f8daa13d82869fbe088f7edf3c95c11660b186
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:03:38 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:07:00 2013 +0200
thin: fix cut&paste bug
Use proper external_lv.
(In release fix)
---
lib/display/display.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/display/display.c b/lib/display/display.c
index c766674..26bc384 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -595,7 +595,7 @@ int lvdisplay_full(struct cmd_context *cmd,
seg->origin->name);
if (seg->external_lv)
log_print("LV External origin name %s",
- seg->origin->name);
+ seg->external_lv->name);
if (inkernel)
thin_active = lv_thin_percent(lv, 0, &thin_percent);
} else if (lv_is_thin_pool(lv)) {
9 years, 9 months
master - raid: test for target_pvs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=24f8daa13d8286...
Commit: 24f8daa13d82869fbe088f7edf3c95c11660b186
Parent: 9e24d563c6e281a582bf1a98673305ce88d6cd05
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 12:53:04 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:07:00 2013 +0200
raid: test for target_pvs
If target_pvs is NULL do not call lv_is_on_pvs()
---
lib/metadata/raid_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 38ea2c2..f9d3861 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -934,7 +934,7 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
seg_metalv(seg, s)->name, seg_lv(seg, s)->name);
} else {
/* Conditions for second pass */
- if (!lv_is_on_pvs(seg_lv(seg, s), target_pvs) ||
+ if (!target_pvs || !lv_is_on_pvs(seg_lv(seg, s), target_pvs) ||
!lv_is_on_pvs(seg_metalv(seg, s), target_pvs))
continue;
9 years, 9 months
master - raid: read segment only for known LV
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9e24d563c6e281...
Commit: 9e24d563c6e281a582bf1a98673305ce88d6cd05
Parent: 4ca6a4105db63344abe3e62eaa0cbcfcb23c47f9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 08:47:59 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:07:00 2013 +0200
raid: read segment only for known LV
Avoid reading first_seg() on unknown LV and find it only when needed.
---
tools/pvmove.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 575f296..a733049 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -207,7 +207,6 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
/* Find segments to be moved and set up mirrors */
dm_list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
- seg = first_seg(lv);
if (lv == lv_mirr)
continue;
if (lv_name) {
@@ -220,14 +219,15 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
log_print_unless_silent("Skipping snapshot-related LV %s", lv->name);
continue;
}
- if (seg_is_raid(seg)) {
- lv_skipped = 1;
- log_print_unless_silent("Skipping %s LV %s",
- seg->segtype->ops->name(seg),
- lv->name);
- continue;
- }
if (lv_is_raid_type(lv)) {
+ seg = first_seg(lv);
+ if (seg_is_raid(seg)) {
+ lv_skipped = 1;
+ log_print_unless_silent("Skipping %s LV %s",
+ seg->segtype->ops->name(seg),
+ lv->name);
+ continue;
+ }
lv_skipped = 1;
log_print_unless_silent("Skipping RAID sub-LV %s",
lv->name);
9 years, 9 months
master - thin: lvcreate better support for AAY
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4ca6a4105db633...
Commit: 4ca6a4105db63344abe3e62eaa0cbcfcb23c47f9
Parent: f787b575b52fcbfa8327d083eae4f2baf296b1cf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 12 11:51:46 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:06:23 2013 +0200
thin: lvcreate better support for AAY
Test rather for changes which are deactivating.
---
lib/metadata/lv_manip.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fc316e8..a353932 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4773,9 +4773,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
goto deactivate_and_revert_new_lv;
}
}
- if (((lp->activate == CHANGE_AY) ||
- (lp->activate == CHANGE_AE) ||
- (lp->activate == CHANGE_ALY))) {
+ if ((lp->activate != CHANGE_AN) && (lp->activate != CHANGE_ALN)) {
/* At this point send message to kernel thin mda */
pool_lv = lv_is_thin_pool(lv) ? lv : first_seg(lv)->pool_lv;
if (!update_pool_lv(pool_lv, 1)) {
9 years, 9 months
master - lvmetad: fix error paths
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f787b575b52fcb...
Commit: f787b575b52fcbfa8327d083eae4f2baf296b1cf
Parent: 377e06b0f8ea10c222a0d38472dbbb05fde1f2d3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:19:54 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:04:53 2013 +0200
lvmetad: fix error paths
Also add missing goto out on error.
Error path missed return NULL leading to double free of enc_value.
---
WHATS_NEW | 1 +
lib/cache/lvmetad.c | 4 +++-
lib/config/config.c | 1 +
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 95b6e13..819fea4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix lvmetad error path in lvmetad_vg_lookup() for null vgname.
Fix clvmd _cluster_request() return code in memory fail path.
Add writemostly/writebehind support for RAID1
Add lv_change_activate() for common activation code in vg/lvchange.
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 4ea3dbd..348827d 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -343,8 +343,10 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
reply = _lvmetad_send("vg_lookup", "uuid = %s", uuid, NULL);
diag_name = uuid;
} else {
- if (!vgname)
+ if (!vgname) {
log_error(INTERNAL_ERROR "VG name required (VGID not available)");
+ goto out;
+ }
log_debug_lvmetad("Asking lvmetad for VG %s", vgname);
reply = _lvmetad_send("vg_lookup", "name = %s", vgname, NULL);
diag_name = vgname;
diff --git a/lib/config/config.c b/lib/config/config.c
index d1cf590..d420d83 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -967,6 +967,7 @@ static struct dm_config_value *_get_def_array_values(struct dm_config_tree *cft,
if (!(v = dm_config_create_value(cft))) {
log_error("Failed to create default config array value for %s.", def->name);
dm_free(enc_value);
+ return NULL;
}
if (oldv)
oldv->next = v;
9 years, 9 months
master - lvmetad: cleanup
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=377e06b0f8ea10...
Commit: 377e06b0f8ea10c222a0d38472dbbb05fde1f2d3
Parent: bee3f4b930dc38142b218d0e097388ffa36c586c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 20:52:38 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:02:43 2013 +0200
lvmetad: cleanup
Move individual assignments to simplier structure setup.
---
daemons/lvmetad/lvmetad-core.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index bbad69c..4f7bf59 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -1168,23 +1168,24 @@ static void usage(char *prog, FILE *file)
int main(int argc, char *argv[])
{
signed char opt;
- daemon_state s = { .private = NULL };
lvmetad_state ls;
int _socket_override = 1;
+ daemon_state s = {
+ .daemon_fini = fini,
+ .daemon_init = init,
+ .handler = handler,
+ .name = "lvmetad",
+ .pidfile = LVMETAD_PIDFILE,
+ .private = &ls,
+ .protocol = "lvmetad",
+ .protocol_version = 1,
+ .socket_path = getenv("LVM_LVMETAD_SOCKET"),
+ };
- s.name = "lvmetad";
- s.private = &ls;
- s.daemon_init = init;
- s.daemon_fini = fini;
- s.handler = handler;
- s.socket_path = getenv("LVM_LVMETAD_SOCKET");
if (!s.socket_path) {
_socket_override = 0;
s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
}
- s.pidfile = LVMETAD_PIDFILE;
- s.protocol = "lvmetad";
- s.protocol_version = 1;
ls.log_config = "";
// use getopt_long
@@ -1216,9 +1217,9 @@ int main(int argc, char *argv[])
if (!_socket_override) {
fprintf(stderr, "A socket path (-s) is required in foreground mode.");
exit(2);
- } else {
- s.pidfile = NULL;
}
+
+ s.pidfile = NULL;
}
daemon_start(s);
9 years, 9 months
master - dmeventd: cleanup
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bee3f4b930dc38...
Commit: bee3f4b930dc38142b218d0e097388ffa36c586c
Parent: 8184a57c2b18d606fb533a87319768c90000e308
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 20:50:46 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:02:43 2013 +0200
dmeventd: cleanup
Drop unneeded reset of data pointer to NULL, since this if() code path
is executed when data is NULL.
---
daemons/dmeventd/dmeventd.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index c3d9671..95fb837 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1454,10 +1454,8 @@ static int _do_process_request(struct dm_event_daemon_message *msg)
msg->cmd == DM_EVENT_CMD_DIE ? "DYING" : "HELLO",
DM_EVENT_PROTOCOL_VERSION);
dm_free(answer);
- } else {
+ } else
msg->size = 0;
- msg->data = NULL;
- }
} else if (msg->cmd != DM_EVENT_CMD_ACTIVE && !_parse_message(&message_data)) {
stack;
ret = -EINVAL;
9 years, 9 months
master - dmeventd: prevent double free
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8184a57c2b18d6...
Commit: 8184a57c2b18d606fb533a87319768c90000e308
Parent: 5ea466673af377328a7ed50d6fb24e66a478b44b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 20:49:57 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:02:36 2013 +0200
dmeventd: prevent double free
Since device.name is relased on more places, mark already
released name with NULL.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/dmeventd.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 6e45a4c..afaf266 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Prevent double free error after dmeventd call of _fill_device_data().
Update dmevent structure message_data to simplify/fix error path handling.
Validate passed params to dm_get_status_raid/thin/thin_pool().
Fix 'dmsetup splitname -o' to not fail if used without '-c' switch (1.02.68).
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 35a2b25..c3d9671 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -411,6 +411,8 @@ static int _fill_device_data(struct thread_status *ts)
fail:
dm_task_destroy(dmt);
dm_free(ts->device.name);
+ ts->device.name = NULL;
+
return 0;
}
9 years, 9 months