master - cleanup: use proper activation_change_t
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a751ad703c808...
Commit: 5a751ad703c8082aaf96c53fc1e76bd8fc607235
Parent: 855175fa261c2c5de0e030615e2f274344e2d129
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 12:49:58 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:57 2013 +0200
cleanup: use proper activation_change_t
---
tools/lvchange.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 7b0a517..cc3e96b 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -212,9 +212,9 @@ static int lvchange_background_polling(struct cmd_context *cmd,
static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv)
{
- int activate;
+ activation_change_t activate;
- activate = arg_uint_value(cmd, activate_ARG, 0);
+ activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY);
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
lv = origin_from_cow(lv);
10 years, 12 months
master - cleanup: add printf attribute
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=855175fa261c2c...
Commit: 855175fa261c2c5de0e030615e2f274344e2d129
Parent: d38af2857fe86a5e0916d67aee7597e5a0dea6c8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Apr 20 20:56:07 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:05 2013 +0200
cleanup: add printf attribute
Add gcc attribute for printf for daemon_logf().
---
libdaemon/server/daemon-server.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libdaemon/server/daemon-server.h b/libdaemon/server/daemon-server.h
index f184853..eb6df43 100644
--- a/libdaemon/server/daemon-server.h
+++ b/libdaemon/server/daemon-server.h
@@ -140,7 +140,8 @@ void daemon_log_cft(log_state *s, int type, const char *prefix,
void daemon_log_multi(log_state *s, int type, const char *prefix, const char *message);
/* Log a formatted message as "type". See also daemon-log.h. */
-void daemon_logf(log_state *s, int type, const char *format, ...);
+void daemon_logf(log_state *s, int type, const char *format, ...)
+ __attribute__ ((format(printf, 3, 4)));
/*
* Configure log_state to send messages of type "type" to the log outlet
10 years, 12 months
master - cleanup: cast to len's type
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d38af2857fe86a...
Commit: d38af2857fe86a5e0916d67aee7597e5a0dea6c8
Parent: 4eb8db26ac9ddd679a32788e8d02ad1e8979e68d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Apr 20 20:55:10 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:05 2013 +0200
cleanup: cast to len's type
Cleanup different signess gcc warning.
---
daemons/clvmd/clvmd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index a64bd54..a276cbc 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -1217,7 +1217,7 @@ static int read_from_local_sock(struct local_client *thisfd)
missing_len = 0;
/* We need at least sizeof(struct clvm_header) bytes in buffer */
- if (len < sizeof(struct clvm_header) || argslen < 0 ||
+ if (len < (int)sizeof(struct clvm_header) || argslen < 0 ||
missing_len > MAX_MISSING_LEN) {
struct clvm_header reply = {
.cmd = CLVMD_CMD_REPLY,
10 years, 12 months
master - cleanup: convert set of strncat into a single printf
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4eb8db26ac9ddd...
Commit: 4eb8db26ac9ddd679a32788e8d02ad1e8979e68d
Parent: 4e1ac7faf132e83393dda628f72cdaecfc4bf9e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:24:51 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:05 2013 +0200
cleanup: convert set of strncat into a single printf
Use single snprintf for better control of used bufsize,
and also increased buffer to 128char to ensure all
chars will always fit.
---
lib/config/config.c | 34 +++++++++++-----------------------
1 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index d420d83..8acb87d 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -337,34 +337,22 @@ int config_def_get_path(char *buf, size_t buf_size, int id)
static void _get_type_name(char *buf, size_t buf_size, cfg_def_type_t type)
{
- buf[0] = '\0';
-
- if (type & CFG_TYPE_ARRAY) {
- if (type & ~CFG_TYPE_ARRAY)
- strncat(buf, " array with values of type:", buf_size);
- else {
- strncat(buf, " array", buf_size);
- return;
- }
- }
-
- if (type & CFG_TYPE_SECTION)
- strncat(buf, " section", buf_size);
- if (type & CFG_TYPE_BOOL)
- strncat(buf, " boolean", buf_size);
- if (type & CFG_TYPE_INT)
- strncat(buf, " integer", buf_size);
- if (type & CFG_TYPE_FLOAT)
- strncat(buf, " float", buf_size);
- if (type & CFG_TYPE_STRING)
- strncat(buf, " string", buf_size);
+ (void) dm_snprintf(buf, buf_size, "%s%s%s%s%s%s",
+ (type & CFG_TYPE_ARRAY) ?
+ ((type & ~CFG_TYPE_ARRAY) ?
+ " array with values of type:" : " array") : "",
+ (type & CFG_TYPE_SECTION) ? " section" : "",
+ (type & CFG_TYPE_BOOL) ? " boolean" : "",
+ (type & CFG_TYPE_INT) ? " integer" : "",
+ (type & CFG_TYPE_FLOAT) ? " float" : "",
+ (type & CFG_TYPE_STRING) ? " string" : "");
}
static void _log_type_error(const char *path, cfg_def_type_t actual,
cfg_def_type_t expected, int suppress_messages)
{
- static char actual_type_name[64];
- static char expected_type_name[64];
+ static char actual_type_name[128];
+ static char expected_type_name[128];
_get_type_name(actual_type_name, sizeof(actual_type_name), actual);
_get_type_name(expected_type_name, sizeof(expected_type_name), expected);
10 years, 12 months
master - cleanup: add some FIXMEs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e1ac7faf132e8...
Commit: 4e1ac7faf132e83393dda628f72cdaecfc4bf9e8
Parent: dfca5dac9ca3ed0ca186b9d79d6b2cacedc4ea37
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:16:08 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:05 2013 +0200
cleanup: add some FIXMEs
---
lib/activate/activate.c | 1 +
lib/device/dev-io.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index b3439ad..670b85c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -794,6 +794,7 @@ int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health)
int r;
struct dev_manager *dm;
struct dm_status_raid *status;
+ /* FIXME: find a better way for this, it is fragile */
static char *cached_dev_health = NULL;
static const struct logical_volume *cached_lv = NULL;
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 2846caf..bb50ae4 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -437,6 +437,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
}
dev_close_immediate(dev);
+ // FIXME: dev with DEV_ALLOCED is released
+ // but code is referencing it
}
if (critical_section())
10 years, 12 months
master - cleanup: explicit check for nonnull pointer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dfca5dac9ca3ed...
Commit: dfca5dac9ca3ed0ca186b9d79d6b2cacedc4ea37
Parent: dd4fdce16c82225f7b8fce0b5ce294d8f3d2e4d6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:10:19 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:05 2013 +0200
cleanup: explicit check for nonnull pointer
Since execvp requires nonnull args - add explicit check.
---
lib/misc/lvm-exec.c | 4 ++--
tools/lvmcmdline.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c
index 4b74a41..1b69635 100644
--- a/lib/misc/lvm-exec.c
+++ b/lib/misc/lvm-exec.c
@@ -54,7 +54,6 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
int status;
char buf[PATH_MAX * 2];
-
if (rstatus)
*rstatus = -1;
@@ -76,7 +75,8 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
/* FIXME Fix effect of reset_locking on cache then include this */
/* destroy_toolcontext(cmd); */
/* FIXME Use execve directly */
- execvp(argv[0], (char **) argv);
+ if (argv[0])
+ execvp(argv[0], (char **) argv);
log_sys_error("execvp", argv[0]);
_exit(errno);
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c69d20d..60aa4d9 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1499,7 +1499,7 @@ int lvm2_main(int argc, char **argv)
return -1;
if (is_static() && strcmp(base, "lvm.static") &&
- path_exists(LVM_SHARED_PATH) &&
+ path_exists(LVM_SHARED_PATH) && argv &&
!getenv("LVM_DID_EXEC")) {
if (setenv("LVM_DID_EXEC", base, 1))
log_sys_error("setenv", "LVM_DID_EXEC");
10 years, 12 months
master - cleanup: drop unused assignment
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd4fdce16c8222...
Commit: dd4fdce16c82225f7b8fce0b5ce294d8f3d2e4d6
Parent: 1951798d7225dce35baa7689a308998f27379b6f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 19 21:09:28 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:14:04 2013 +0200
cleanup: drop unused assignment
Assigned values are unused.
---
lib/activate/dev_manager.c | 2 +-
lib/metadata/raid_manip.c | 1 -
2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 00c0126..150bb35 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1610,7 +1610,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
uint32_t s;
struct seg_list *sl;
struct dm_list *snh;
- struct lv_segment *seg = first_seg(lv);
+ struct lv_segment *seg;
struct dm_tree_node *thin_node;
const char *uuid;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 707db1f..c0d38d8 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -403,7 +403,6 @@ static int _alloc_image_component(struct logical_volume *lv,
}
if (!ah) {
- first_area = 0;
log_error(INTERNAL_ERROR
"Stand-alone %s area allocation not implemented",
(type == RAID_META) ? "metadata" : "data");
10 years, 12 months
master - vgread: fix fid transfer for lvm1 and pool format
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1951798d7225dc...
Commit: 1951798d7225dce35baa7689a308998f27379b6f
Parent: 5e7eae59da2ce859e99c62b578f9164b87a1f944
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 21:36:08 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:13:57 2013 +0200
vgread: fix fid transfer for lvm1 and pool format
Assign fid as the last step before returning VG.
Make the format reader for 'lvm1' and 'pool' equal to 'lvm2' format reader.
It has caused memory corruption to lvmetad as it later calls
destroy_instance() to allocated fid. This patch should fix problems
with crashing test lvmetad-lvm1.sh.
---
WHATS_NEW | 1 +
lib/format1/format1.c | 4 ++--
lib/format_pool/format_pool.c | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5d4c7a7..c1324de 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix assignment order for vg fid for lvm1 and pool format.
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.
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index f47ed95..2864227 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -200,8 +200,6 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
if (dm_list_empty(&pvs))
goto_bad;
- vg_set_fid(vg, fid);
-
if (!_check_vgs(&pvs, vg))
goto_bad;
@@ -226,6 +224,8 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
if ((vg->status & PARTIAL_VG) && !_fix_partial_vg(vg, &pvs))
goto_bad;
+ vg_set_fid(vg, fid);
+
return vg;
bad:
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index c051968..0891524 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -122,8 +122,6 @@ static struct volume_group *_pool_vg_read(struct format_instance *fid,
if (!read_pool_pds(fid->fmt, vg_name, vg->vgmem, &pds))
goto_bad;
- vg_set_fid(vg, fid);
-
/* Setting pool seqno to 1 because the code always did this,
* although we don't think it's needed. */
vg->seqno = 1;
@@ -155,6 +153,8 @@ static struct volume_group *_pool_vg_read(struct format_instance *fid,
if (!import_pool_segments(&vg->lvs, vg->vgmem, usp, sp_count))
goto_bad;
+ vg_set_fid(vg, fid);
+
return vg;
bad:
10 years, 12 months
master - lv_manip: check remove_seg_from_segs_using_this_lv()
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e7eae59da2ce8...
Commit: 5e7eae59da2ce859e99c62b578f9164b87a1f944
Parent: 8f1dd00c3634d111be9a42524ab50b2f31962530
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 13:18:53 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:10:43 2013 +0200
lv_manip: check remove_seg_from_segs_using_this_lv()
Add missing check for result of remove_seg_from_segs_using_this_lv().
Failure is reported as internal error.
---
lib/metadata/lv_manip.c | 5 ++++-
lib/metadata/mirror.c | 3 ++-
lib/metadata/raid_manip.c | 8 +++++---
lib/metadata/thin_manip.c | 3 ++-
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a353932..7580464 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -246,6 +246,8 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv,
return 1;
}
+ log_error(INTERNAL_ERROR "Segment %s:%u is not a user of %s.",
+ seg->lv->name, seg->le, lv->name);
return 0;
}
@@ -514,7 +516,8 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
seg->lv->name, seg->le, s,
seg_lv(seg, s)->name, seg_le(seg, s));
- remove_seg_from_segs_using_this_lv(seg_lv(seg, s), seg);
+ if (!remove_seg_from_segs_using_this_lv(seg_lv(seg, s), seg))
+ return_0;
seg_lv(seg, s) = NULL;
seg_le(seg, s) = 0;
seg_type(seg, s) = AREA_UNASSIGNED;
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index fecab45..18d0d33 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -482,7 +482,8 @@ struct logical_volume *detach_mirror_log(struct lv_segment *mirrored_seg)
mirrored_seg->log_lv = NULL;
lv_set_visible(log_lv);
log_lv->status &= ~MIRROR_LOG;
- remove_seg_from_segs_using_this_lv(log_lv, mirrored_seg);
+ if (!remove_seg_from_segs_using_this_lv(log_lv, mirrored_seg))
+ return_0;
return log_lv;
}
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index f9d3861..707db1f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -195,7 +195,8 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
/* Add last metadata area to removal_list */
lvl_array[0].lv = seg_metalv(seg, 0);
lv_set_visible(seg_metalv(seg, 0));
- remove_seg_from_segs_using_this_lv(seg_metalv(seg, 0), seg);
+ if (!remove_seg_from_segs_using_this_lv(seg_metalv(seg, 0), seg))
+ return_0;
seg_metatype(seg, 0) = AREA_UNASSIGNED;
dm_list_add(removal_list, &(lvl_array[0].list));
@@ -835,8 +836,9 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
lv_set_visible(meta_lv);
/* release removes data and meta areas */
- remove_seg_from_segs_using_this_lv(data_lv, seg);
- remove_seg_from_segs_using_this_lv(meta_lv, seg);
+ if (!remove_seg_from_segs_using_this_lv(data_lv, seg) ||
+ !remove_seg_from_segs_using_this_lv(meta_lv, seg))
+ return_0;
seg_type(seg, idx) = AREA_UNASSIGNED;
seg_metatype(seg, idx) = AREA_UNASSIGNED;
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 10c8f43..1239af9 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -474,7 +474,8 @@ int extend_pool(struct logical_volume *pool_lv, const struct segment_type *segty
return_0;
/* Drop reference as attach_pool_data_lv() takes it again */
- remove_seg_from_segs_using_this_lv(data_lv, seg);
+ if (!remove_seg_from_segs_using_this_lv(data_lv, seg))
+ return_0;
if (!attach_pool_data_lv(seg, data_lv))
return_0;
10 years, 12 months
master - libdm: improve check in dm_split_lvm_name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8f1dd00c3634d1...
Commit: 8f1dd00c3634d111be9a42524ab50b2f31962530
Parent: a2b76a6f022920abd59072decfa7d3d76eeda913
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 21 12:48:24 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Apr 21 23:10:43 2013 +0200
libdm: improve check in dm_split_lvm_name
We support both type of call - with or without mem pool.
So ensure we will not use NULL vgname also when mem is given.
---
libdm/libdm-string.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-string.c b/libdm/libdm-string.c
index 5ef6334..9d667bb 100644
--- a/libdm/libdm-string.c
+++ b/libdm/libdm-string.c
@@ -92,7 +92,10 @@ static char *_unquote(char *component)
int dm_split_lvm_name(struct dm_pool *mem, const char *dmname,
char **vgname, char **lvname, char **layer)
{
- if (mem && !(*vgname = dm_pool_strdup(mem, dmname)))
+ if (mem)
+ *vgname = dm_pool_strdup(mem, dmname);
+
+ if (!*vgname)
return 0;
_unquote(*layer = _unquote(*lvname = _unquote(*vgname)));
10 years, 12 months