master - cov: avoid selfrecursive inclusion of toolcontext.h
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=06a4a356dbd320e23bd...
Commit: 06a4a356dbd320e23bd95e1feb045e91c63f3d51
Parent: fdd76da33dabcb6bd696f22413a692b9900d5bcc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:50:25 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: avoid selfrecursive inclusion of toolcontext.h
---
lib/filters/filter-md.c | 1 +
lib/label/label.h | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
index 4c3f23d..2214986 100644
--- a/lib/filters/filter-md.c
+++ b/lib/filters/filter-md.c
@@ -16,6 +16,7 @@
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/filters/filter.h"
+#include "lib/commands/toolcontext.h"
#ifdef __linux__
diff --git a/lib/label/label.h b/lib/label/label.h
index a353a67..447fc86 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -19,7 +19,6 @@
#include "lib/uuid/uuid.h"
#include "lib/device/device.h"
#include "lib/device/bcache.h"
-#include "lib/commands/toolcontext.h"
#define LABEL_ID "LABELONE"
#define LABEL_SIZE SECTOR_SIZE /* Think very carefully before changing this */
@@ -27,6 +26,9 @@
#define LABEL_SCAN_SIZE (LABEL_SCAN_SECTORS << SECTOR_SHIFT)
struct labeller;
+struct dev_filter;
+struct cmd_context;
+struct logical_volume;
/* On disk - 32 bytes */
struct label_header {
5 years, 5 months
master - cov: pvscan ensure sigle_devs list is always initialized
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c4f39decc8d6fb213af...
Commit: c4f39decc8d6fb213af21f16d99b460362ce295f
Parent: 43e4bfe428cb4e8a953a74aeca5b1942ce6f55a4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:57:32 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: pvscan ensure sigle_devs list is always initialized
---
tools/pvscan.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 613a4c4..d110a6b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -620,6 +620,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
int add_errors = 0;
int ret = ECMD_PROCESSED;
+ dm_list_init(&single_devs);
dm_list_init(&found_vgnames);
if (arg_is_set(cmd, major_ARG) + arg_is_set(cmd, minor_ARG))
@@ -664,8 +665,6 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
/* Creates a list of dev names from /dev, sysfs, etc; does not read any. */
dev_cache_scan();
- dm_list_init(&single_devs);
-
while (argc--) {
pv_name = *argv++;
if (pv_name[0] == '/') {
5 years, 5 months
master - cov: drop uneeded header files
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fdd76da33dabcb6bd69...
Commit: fdd76da33dabcb6bd696f22413a692b9900d5bcc
Parent: c4f39decc8d6fb213af21f16d99b460362ce295f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 15:08:09 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: drop uneeded header files
---
device_mapper/libdm-deptree.c | 1 -
lib/activate/activate.c | 1 -
lib/device/bcache.c | 1 -
lib/device/dev-cache.c | 1 -
lib/device/dev-io.c | 1 -
lib/format_text/format-text.c | 2 --
lib/label/label.c | 1 -
lib/locking/file_locking.c | 1 -
lib/metadata/vdo_manip.c | 2 --
lib/metadata/vg.c | 1 -
lib/mirror/mirrored.c | 1 -
11 files changed, 0 insertions(+), 13 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 26251f8..5c5f12f 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -21,7 +21,6 @@
#include <stdarg.h>
#include <string.h>
-#include <sys/param.h>
#include <sys/utsname.h>
#define MAX_TARGET_PARAMSIZE 500000
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ead3b8d..93448d3 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -28,7 +28,6 @@
#include "lib/config/config.h"
#include "lib/metadata/segtype.h"
#include "lib/misc/sharedlib.h"
-#include "lib/cache/lvmcache.h"
#include "lib/metadata/metadata.h"
#include <limits.h>
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 8b2c7f8..5e957fe 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -31,7 +31,6 @@
#include <libaio.h>
#include <unistd.h>
#include <linux/fs.h>
-#include <sys/ioctl.h>
#include <sys/user.h>
#define SECTOR_SHIFT 9L
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index f83ccda..9b141fe 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -25,7 +25,6 @@
#include <libudev.h>
#endif
#include <unistd.h>
-#include <sys/param.h>
#include <dirent.h>
struct dev_iter {
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index a3643c4..dc95131 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -17,7 +17,6 @@
#include "lib/device/device.h"
#include "lib/metadata/metadata.h"
#include "lib/mm/memlock.h"
-#include "lib/locking/locking.h"
#include <limits.h>
#include <sys/stat.h>
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 99945b1..5d8355e 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -28,10 +28,8 @@
#include "lib/mm/xlate.h"
#include "lib/label/label.h"
#include "lib/cache/lvmcache.h"
-#include "lib/mm/memlock.h"
#include <unistd.h>
-#include <sys/param.h>
#include <limits.h>
#include <dirent.h>
#include <ctype.h>
diff --git a/lib/label/label.c b/lib/label/label.c
index 6c074d6..22b6bc2 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -28,7 +28,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/time.h>
#include <sys/types.h>
/* FIXME Allow for larger labels? Restricted to single sector currently */
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 8e08b08..8f808c8 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -16,7 +16,6 @@
#include "lib/misc/lib.h"
#include "lib/locking/locking.h"
#include "locking_types.h"
-#include "lib/activate/activate.h"
#include "lib/config/config.h"
#include "lib/config/defaults.h"
#include "lib/misc/lvm-string.h"
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index c0446ad..b5bbbe2 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -21,8 +21,6 @@
#include "lib/metadata/segtype.h"
#include "lib/activate/activate.h"
#include "lib/config/defaults.h"
-#include "lib/metadata/lv_alloc.h"
-#include "lib/misc/lvm-signal.h"
#include "lib/misc/lvm-exec.h"
const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state)
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index a9cb541..aca4fe7 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -18,7 +18,6 @@
#include "lib/display/display.h"
#include "lib/activate/activate.h"
#include "lib/commands/toolcontext.h"
-#include "lib/cache/lvmcache.h"
#include "lib/format_text/archiver.h"
struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 1ca4037..7fa8714 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -16,7 +16,6 @@
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/commands/toolcontext.h"
-#include "lib/metadata/metadata.h"
#include "lib/metadata/segtype.h"
#include "lib/display/display.h"
#include "lib/format_text/text_export.h"
5 years, 5 months
master - cov: ignore error of vsnprintf
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=43e4bfe428cb4e8a953...
Commit: 43e4bfe428cb4e8a953a74aeca5b1942ce6f55a4
Parent: 84f00f50584b0c1c0464a414c71cd112e4d30c22
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 17:37:30 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: ignore error of vsnprintf
---
device_mapper/vdo/status.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/device_mapper/vdo/status.c b/device_mapper/vdo/status.c
index 6ae7b84..53dfe4d 100644
--- a/device_mapper/vdo/status.c
+++ b/device_mapper/vdo/status.c
@@ -154,7 +154,7 @@ static void _set_error(struct dm_vdo_status_parse_result *result, const char *fm
va_list ap;
va_start(ap, fmt);
- vsnprintf(result->error, sizeof(result->error), fmt, ap);
+ (void) vsnprintf(result->error, sizeof(result->error), fmt, ap);
va_end(ap);
}
5 years, 5 months
master - cov: add missing error path check for label_scan_open
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=84f00f50584b0c1c046...
Commit: 84f00f50584b0c1c0464a414c71cd112e4d30c22
Parent: b57e73a0f1376ea114451c0172f0ef0adbd3123f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:39:28 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: add missing error path check for label_scan_open
---
lib/label/label.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 3901a86..6c074d6 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1067,7 +1067,11 @@ int label_read_sector(struct device *dev, uint64_t read_sector)
block_sector = block_num * BCACHE_BLOCK_SIZE_IN_SECTORS;
start_sector = read_sector % BCACHE_BLOCK_SIZE_IN_SECTORS;
- label_scan_open(dev);
+ if (!label_scan_open(dev)) {
+ log_error("Error opening device %s for prefetch %llu sector.",
+ dev_name(dev), (unsigned long long)block_num);
+ return false;
+ }
bcache_prefetch(scan_bcache, dev->bcache_fd, block_num);
5 years, 5 months
master - cov: make sure label scans valid lvinfo
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b57e73a0f1376ea1144...
Commit: b57e73a0f1376ea114451c0172f0ef0adbd3123f
Parent: 70950bbd977020593b19ac704fd7571b4b2826cd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:29:09 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: make sure label scans valid lvinfo
---
lib/label/label.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 9fe11f6..3901a86 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -970,7 +970,9 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
struct device *dev;
dev_t devt;
- lv_info(cmd, lv, 0, &lvinfo, 0, 0);
+ if (!lv_info(cmd, lv, 0, &lvinfo, 0, 0))
+ return;
+
devt = MKDEV(lvinfo.major, lvinfo.minor);
if ((dev = dev_cache_get_by_devt(cmd, devt, NULL)))
label_scan_invalidate(dev);
5 years, 5 months
master - cov: log failing unlink
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=70950bbd977020593b1...
Commit: 70950bbd977020593b19ac704fd7571b4b2826cd
Parent: f1ac130dc10ba22eaafd31e906b347a12b8cea16
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:21:01 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: log failing unlink
---
tools/pvscan.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 6e80e3c..613a4c4 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -225,7 +225,8 @@ static void _online_pvid_file_remove_devno(int major, int minor)
if (!strncmp(buf, buf_in, strlen(buf))) {
log_debug("Unlink pv online %s %s", buf, path);
- unlink(path);
+ if (unlink(path))
+ log_sys_debug("unlink", path);
break;
}
}
@@ -248,7 +249,8 @@ static void _online_pvid_files_remove(void)
memset(path, 0, sizeof(path));
snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, de->d_name);
- unlink(path);
+ if (unlink(path))
+ log_sys_debug("unlink", path);
}
if (closedir(dir))
log_sys_debug("closedir", _pvs_online_dir);
5 years, 5 months
master - cov: check closedir result
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f1ac130dc10ba22eaaf...
Commit: f1ac130dc10ba22eaafd31e906b347a12b8cea16
Parent: 668c9d0762fc6736a1e9372785544eda6a939806
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:19:49 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: check closedir result
Log problems around failing closedir().
---
tools/pvscan.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index da63074..6e80e3c 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -229,7 +229,8 @@ static void _online_pvid_file_remove_devno(int major, int minor)
break;
}
}
- closedir(dir);
+ if (closedir(dir))
+ log_sys_debug("closedir", _pvs_online_dir);
}
static void _online_pvid_files_remove(void)
@@ -249,7 +250,8 @@ static void _online_pvid_files_remove(void)
snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, de->d_name);
unlink(path);
}
- closedir(dir);
+ if (closedir(dir))
+ log_sys_debug("closedir", _pvs_online_dir);
}
static void _online_pvid_file_create(struct device *dev)
@@ -338,10 +340,12 @@ static int _online_pvid_files_missing(void)
while ((de = readdir(dir))) {
if (de->d_name[0] == '.')
continue;
- closedir(dir);
+ if (closedir(dir))
+ log_sys_debug("closedir", _pvs_online_dir);
return 0;
}
- closedir(dir);
+ if (closedir(dir))
+ log_sys_debug("closedir", _pvs_online_dir);
return 1;
}
5 years, 5 months
master - cov: check dm_strncpy result
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=668c9d0762fc6736a1e...
Commit: 668c9d0762fc6736a1e9372785544eda6a939806
Parent: b1ff52ca146f58938c07f6c6855bc860453059e6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:16:14 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: check dm_strncpy result
---
device_mapper/vdo/status.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/device_mapper/vdo/status.c b/device_mapper/vdo/status.c
index c86c911..6ae7b84 100644
--- a/device_mapper/vdo/status.c
+++ b/device_mapper/vdo/status.c
@@ -207,7 +207,11 @@ bool dm_vdo_status_parse(struct dm_pool *mem, const char *input,
_set_error(result, "out of memory");
goto bad;
}
- dm_strncpy(s->device, b, te - b + 1);
+
+ if (!dm_strncpy(s->device, b, te - b + 1)) {
+ _set_error(result, "copy device");
+ goto bad;
+ }
b = _eat_space(te, e);
5 years, 5 months
master - cov: check dev_close_immediate
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b1ff52ca146f58938c0...
Commit: b1ff52ca146f58938c07f6c6855bc860453059e6
Parent: 251366146727aac97af5de2eef855860d14910ca
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 15 16:06:35 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 15 17:49:44 2018 +0200
cov: check dev_close_immediate
Function can report log_error() on fail path.
---
lib/device/dev-cache.c | 4 ++--
lib/device/dev-io.c | 6 ++++--
tools/pvscan.c | 3 ++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 59e00ae..f83ccda 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1302,8 +1302,8 @@ static int _check_for_open_devices(int close_immediate)
log_error("Device '%s' has been left open (%d remaining references).",
dev_name(dev), dev->open_count);
num_open++;
- if (close_immediate)
- dev_close_immediate(dev);
+ if (close_immediate && !dev_close_immediate(dev))
+ stack;
}
}
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index d4210a5..a3643c4 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -504,7 +504,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
/* dev_close_immediate will decrement this */
dev->open_count++;
- dev_close_immediate(dev);
+ if (!dev_close_immediate(dev))
+ return_0;
// FIXME: dev with DEV_ALLOCED is released
// but code is referencing it
}
@@ -585,7 +586,8 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
if (!(dev->flags & DEV_REGULAR) &&
((fstat(dev->fd, &buf) < 0) || (buf.st_rdev != dev->dev))) {
log_error("%s: fstat failed: Has device name changed?", name);
- dev_close_immediate(dev);
+ if (!dev_close_immediate(dev))
+ stack;
return 0;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index fd75362..da63074 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -284,7 +284,8 @@ static void _online_pvid_file_create(struct device *dev)
/* We don't care about syncing, these files are not even persistent. */
- close(fd);
+ if (close(fd))
+ log_sys_debug("close", path);
}
static int _online_pvid_file_exists(const char *pvid)
5 years, 5 months