master - lvmlockctl: use inline initilizers
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=91d16fc049ba2034708...
Commit: 91d16fc049ba2034708aa6a0bab5f548040dfd3b
Parent: d01f27f41135189611d2030ec87ff5714eb259af
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 29 15:47:40 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
lvmlockctl: use inline initilizers
clang: ensure r_name[] is in all possible paths defined.
---
daemons/lvmlockd/lvmlockctl.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockctl.c b/daemons/lvmlockd/lvmlockctl.c
index 40432b5..c2a998c 100644
--- a/daemons/lvmlockd/lvmlockctl.c
+++ b/daemons/lvmlockd/lvmlockctl.c
@@ -280,13 +280,12 @@ static void format_info_line(char *line, char *r_name, char *r_type)
static void format_info(void)
{
- char line[MAX_LINE];
- char r_name[MAX_NAME+1];
- char r_type[MAX_NAME+1];
+ char line[MAX_LINE] = { 0 };
+ char r_name[MAX_NAME+1] = { 0 };
+ char r_type[MAX_NAME+1] = { 0 };
int i, j;
j = 0;
- memset(line, 0, sizeof(line));
for (i = 0; i < dump_len; i++) {
line[j++] = dump_buf[i];
4 years, 2 months
master - lvmlockctl: ensure result value is always defined
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d01f27f41135189611d...
Commit: d01f27f41135189611d2030ec87ff5714eb259af
Parent: bcfe4993e577167440be511da4ec879fac19afdb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 4 15:33:36 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
lvmlockctl: ensure result value is always defined
Ensure passed pointer gets predefined value (instead of random stack
value).
---
daemons/lvmlockd/lvmlockctl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockctl.c b/daemons/lvmlockd/lvmlockctl.c
index 0dfc3e6..40432b5 100644
--- a/daemons/lvmlockd/lvmlockctl.c
+++ b/daemons/lvmlockd/lvmlockctl.c
@@ -326,6 +326,8 @@ static int _lvmlockd_result(daemon_reply reply, int *result)
{
int reply_result;
+ *result = NO_LOCKD_RESULT;
+
if (reply.error) {
log_error("lvmlockd_result reply error %d", reply.error);
return 0;
@@ -337,7 +339,7 @@ static int _lvmlockd_result(daemon_reply reply, int *result)
}
reply_result = daemon_reply_int(reply, "op_result", NO_LOCKD_RESULT);
- if (reply_result == -1000) {
+ if (reply_result == NO_LOCKD_RESULT) {
log_error("lvmlockd_result no op_result");
return 0;
}
4 years, 2 months
master - lvmlockd: move eval of ENOENT
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bcfe4993e577167440b...
Commit: bcfe4993e577167440be511da4ec879fac19afdb
Parent: 555d6d4e62b5a10a8f52454a93e3cdc65e0d1abd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 30 12:52:19 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
lvmlockd: move eval of ENOENT
To avoid logging 'errors' for no real error state (ENOENT),
move this evaluation upward in the code.
---
lib/locking/lvmlockd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index cbe2121..4161210 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2092,7 +2092,8 @@ static int _query_lock_lv(struct cmd_context *cmd, struct volume_group *vg,
log_error("Lock query failed for LV %s/%s", vg->name, lv_name);
return 0;
} else {
- ret = (result < 0) ? 0 : 1;
+ /* ENOENT => The lv was not active/locked. */
+ ret = (result < 0 && (result != -ENOENT)) ? 0 : 1;
}
if (!ret)
@@ -2110,10 +2111,6 @@ static int _query_lock_lv(struct cmd_context *cmd, struct volume_group *vg,
daemon_reply_destroy(reply);
- /* The lv was not active/locked. */
- if (result == -ENOENT)
- return 1;
-
return ret;
}
4 years, 2 months
master - cov: check error code from mutex init
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=555d6d4e62b5a10a8f5...
Commit: 555d6d4e62b5a10a8f52454a93e3cdc65e0d1abd
Parent: d6ac039b65a371caeabb1bf2a191e609ed2cd9f8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 30 12:48:40 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
cov: check error code from mutex init
---
daemons/dmeventd/dmeventd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index ae1e6a6..4fcb381 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -2237,7 +2237,8 @@ int main(int argc, char *argv[])
_init_thread_signals();
- pthread_mutex_init(&_global_mutex, NULL);
+ if (pthread_mutex_init(&_global_mutex, NULL))
+ exit(EXIT_FAILURE);
if (!_systemd_activation && !_open_fifos(&fifos))
exit(EXIT_FIFO_FAILURE);
4 years, 2 months
master - cov: widen before calculating min_chunk_size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d6ac039b65a371caeab...
Commit: d6ac039b65a371caeabb1bf2a191e609ed2cd9f8
Parent: de43527f94c172223d25f849411f435ad359ce77
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 30 12:43:53 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
cov: widen before calculating min_chunk_size
Although we expect min_chunk_size to be 32bit value, for
large size of caches it might be useful to do calcs 64bit.
So to avoid doing shift as signed 32bit - use unsigned 64bit
from the start.
---
lib/metadata/cache_manip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 5613a22..49b3850 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -222,7 +222,7 @@ int update_cache_pool_params(struct cmd_context *cmd,
*chunk_size = get_default_allocation_cache_pool_chunk_size_CFG(cmd,
profile);
/* Use power-of-2 for min chunk size when unspecified */
- min_chunk_size = 1 << (32 - clz(min_chunk_size - 1));
+ min_chunk_size = UINT64_C(1) << (32 - clz(min_chunk_size - 1));
}
if (*chunk_size < min_chunk_size) {
/*
4 years, 2 months
master - cov: unused header file removal
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=de43527f94c172223d2...
Commit: de43527f94c172223d25f849411f435ad359ce77
Parent: c5e5ae4c95e5d02bfa5d018364954281053a9440
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 30 11:03:27 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
cov: unused header file removal
cov: unused header removed
Also ensure library header file with config settings goes first.
Move inclusion of format-text.h into layout.h
---
lib/format_text/layout.h | 3 +--
lib/label/hints.c | 3 +--
lib/label/label.c | 3 +--
lib/metadata/writecache_manip.c | 1 -
tools/pvscan.c | 1 -
5 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h
index 7ec699e..c3dfe8e 100644
--- a/lib/format_text/layout.h
+++ b/lib/format_text/layout.h
@@ -18,11 +18,10 @@
#include "lib/config/config.h"
#include "lib/metadata/metadata.h"
+#include "lib/format_text/format-text.h"
#include "lib/cache/lvmcache.h"
#include "lib/uuid/uuid.h"
-/* disk_locn and data_area_list are defined in format-text.h */
-
/*
* PV header extension versions:
* - version 1: bootloader area support
diff --git a/lib/label/hints.c b/lib/label/hints.c
index f8e8f45..f1a1519 100644
--- a/lib/label/hints.c
+++ b/lib/label/hints.c
@@ -135,11 +135,10 @@
*
*/
-#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
+#include "base/memory/zalloc.h"
#include "lib/label/label.h"
#include "lib/misc/crc.h"
-#include "lib/mm/xlate.h"
#include "lib/cache/lvmcache.h"
#include "lib/device/bcache.h"
#include "lib/commands/toolcontext.h"
diff --git a/lib/label/label.c b/lib/label/label.c
index 680630b..328e4e7 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -13,8 +13,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
+#include "base/memory/zalloc.h"
#include "lib/label/label.h"
#include "lib/misc/crc.h"
#include "lib/mm/xlate.h"
@@ -24,7 +24,6 @@
#include "lib/activate/activate.h"
#include "lib/label/hints.h"
#include "lib/metadata/metadata.h"
-#include "lib/format_text/format-text.h"
#include "lib/format_text/layout.h"
#include <sys/stat.h>
diff --git a/lib/metadata/writecache_manip.c b/lib/metadata/writecache_manip.c
index 5a5a759..0122025 100644
--- a/lib/metadata/writecache_manip.c
+++ b/lib/metadata/writecache_manip.c
@@ -21,7 +21,6 @@
#include "lib/metadata/segtype.h"
#include "lib/activate/activate.h"
#include "lib/config/defaults.h"
-#include "lib/activate/dev_manager.h"
int lv_is_writecache_origin(const struct logical_volume *lv)
{
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 312a633..1bf543c 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -20,7 +20,6 @@
#include "lib/label/hints.h"
#include <dirent.h>
-#include <sys/file.h>
struct pvscan_params {
int new_pvs_found;
4 years, 2 months
master - bcache: fix memleak on error path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c5e5ae4c95e5d02bfa5...
Commit: c5e5ae4c95e5d02bfa5d018364954281053a9440
Parent: 1bde35e596536abc176cb70506353476cd1705b1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 29 17:31:17 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
bcache: fix memleak on error path
clang: free io on error path.
---
lib/device/bcache.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 04d49f1..a7d8055 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -515,6 +515,7 @@ static bool _sync_issue(struct io_engine *ioe, enum dir d, int fd,
(unsigned long long)limit_nbytes,
(unsigned long long)extra_nbytes,
(unsigned long long)_last_byte_sector_size);
+ free(io);
return false;
}
}
4 years, 2 months
master - pvck: avoid memleak of vgname
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1bde35e596536abc176...
Commit: 1bde35e596536abc176cb70506353476cd1705b1
Parent: ac38b576f9f6daedf22a0d8472586bfe7de7c57e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 29 16:55:49 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
pvck: avoid memleak of vgname
clang: no vgname buffer leak.
---
tools/pvck.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/pvck.c b/tools/pvck.c
index 0266218..d57e026 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -788,7 +788,7 @@ static int _dump_current_text(struct device *dev,
{
char *meta_buf;
struct dm_config_tree *cft;
- const char *vgname = NULL;
+ char *vgname = NULL;
uint32_t crc;
uint32_t seqno = 0;
int mn = mda_num; /* 1 or 2 */
@@ -895,6 +895,7 @@ static int _dump_current_text(struct device *dev,
out:
free(meta_buf);
+ free(vgname);
if (bad)
return 0;
return 1;
4 years, 2 months
master - dmsetup: no memleak on failed realocation
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac38b576f9f6daedf22...
Commit: ac38b576f9f6daedf22a0d8472586bfe7de7c57e
Parent: 62ad12d0d05d8ffa26df4f1b1b6ef3b2113420b1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 29 16:30:16 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
dmsetup: no memleak on failed realocation
clang: keep old buf pointer for release on failing realloc() codepath.
---
libdm/dm-tools/dmsetup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 269f86c..d01b8f2 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -1216,7 +1216,7 @@ out:
static char *_slurp_stdin(void)
{
- char *buf, *pos;
+ char *newbuf, *buf, *pos;
size_t bufsize = DEFAULT_BUF_SIZE;
size_t total = 0;
ssize_t n = 0;
@@ -1245,10 +1245,12 @@ static char *_slurp_stdin(void)
pos += n;
if (total == bufsize - 1) {
bufsize *= 2;
- if (!(buf = realloc(buf, bufsize))) {
+ if (!(newbuf = realloc(buf, bufsize))) {
log_error("Buffer memory extension to %" PRIsize_t " bytes failed.", bufsize);
+ free(buf);
return NULL;
}
+ buf = newbuf;
}
} while (1);
4 years, 2 months
master - tests: compatible with older kernels
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=62ad12d0d05d8ffa26d...
Commit: 62ad12d0d05d8ffa26df4f1b1b6ef3b2113420b1
Parent: c0de37ab1888a53cce97007c3f4fdfb6f85ab5bf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 29 15:50:57 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 4 17:22:06 2020 +0100
tests: compatible with older kernels
Older kernels just show syscall stacktrace.
---
test/shell/dmsecuretest.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/dmsecuretest.sh b/test/shell/dmsecuretest.sh
index 0f53ea7..144b1f4 100644
--- a/test/shell/dmsecuretest.sh
+++ b/test/shell/dmsecuretest.sh
@@ -47,7 +47,7 @@ dmsetup status "$DMTEST"
# generate core file for running&sleeping binary
gcore "$PID" | tee out
# check we capture core while dmsecuretest was already sleeping
-grep "nanosleep" out
+grep "nanosleep" out || grep kernel_vsyscall out
kill "$PID" || true
wait
4 years, 2 months