diff options
author | Petr Rockai <prockai@redhat.com> | 2012-02-26 08:49:40 +0000 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2012-02-26 08:49:40 +0000 |
commit | 1943ff99105c6bb3741390ebbb0a766419d65286 (patch) | |
tree | 3803b7b600eb246eda12a866f0770c1f123d25ae /lib/cache/lvmetad.c | |
parent | 98b4241b2f68f2baf0eb922e6b975b484f4a4187 (diff) | |
download | lvm2-1943ff99105c6bb3741390ebbb0a766419d65286.tar.gz lvm2-1943ff99105c6bb3741390ebbb0a766419d65286.tar.xz lvm2-1943ff99105c6bb3741390ebbb0a766419d65286.zip |
- Improve error reporting on lvmetad connection failure.
- Fix a couple of memory leaks in the lvmetad client code.
- Avoid an error in lvmetad_pv_gone when we aren't using lvmetad.
Diffstat (limited to 'lib/cache/lvmetad.c')
-rw-r--r-- | lib/cache/lvmetad.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index 1743d393..00da75d7 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -16,8 +16,8 @@ void lvmetad_init(void) const char *socket = getenv("LVM_LVMETAD_SOCKET"); if (_using_lvmetad) { /* configured by the toolcontext */ _lvmetad = lvmetad_open(socket ?: DEFAULT_RUN_DIR "/lvmetad.socket"); - if (_lvmetad.socket_fd < 0) { - log_warn("Failed to connect to lvmetad. Falling back to scanning."); + if (_lvmetad.socket_fd < 0 || _lvmetad.error) { + log_warn("Failed to connect to lvmetad: %s. Falling back to scanning.", strerror(_lvmetad.error)); _using_lvmetad = 0; } } @@ -251,6 +251,7 @@ int lvmetad_vg_update(struct volume_group *vg) reply = daemon_send_simple(_lvmetad, "vg_update", "vgname = %s", vg->name, "metadata = %b", strchr(buf, '{'), NULL); + dm_free(buf); if (!_lvmetad_handle_reply(reply, "update VG", vg->name)) return 0; @@ -496,8 +497,12 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_ " %s" "}", device->dev, info ? lvmcache_device_size(info) : 0, - fmt->name, label_sector, uuid, mdas ?: "")) + fmt->name, label_sector, uuid, mdas ?: "")) { + dm_free((char *)mdas); return_0; + } + + dm_free((char *)mdas); if (vg) { /* @@ -529,6 +534,9 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_ int lvmetad_pv_gone(dev_t device) { + if (!_using_lvmetad) + return 1; + daemon_reply reply = daemon_send_simple(_lvmetad, "pv_gone", "device = %d", device, NULL); |