master - libdm: use size_t for buflen in _stats_group_file_regions()
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b823646aced03e49eb7...
Commit: b823646aced03e49eb7f42aa9872d7e31f3fa1a4
Parent: 833b02106d448dcec7a3e9ff23a8ec2cdc5bb3ab
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:46:21 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 10:02:45 2017 +0100
libdm: use size_t for buflen in _stats_group_file_regions()
---
libdm/libdm-stats.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 2e6022d..2a6c343 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4219,7 +4219,7 @@ static int _stats_group_file_regions(struct dm_stats *dms, uint64_t *region_ids,
dm_bitset_t regions = dm_bitset_create(NULL, dms->nr_regions);
uint64_t i, group_id = DM_STATS_GROUP_NOT_PRESENT;
char *members = NULL;
- int buflen;
+ size_t buflen;
if (!regions) {
log_error("Cannot map file: failed to allocate group bitmap.");
7 years
master - libdm: make _stats_resize_group() num_regions argument uint64_t
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=833b02106d448dcec7a...
Commit: 833b02106d448dcec7a3e9ff23a8ec2cdc5bb3ab
Parent: 722542fabb30915653a222a6dca8f34338db4e80
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:42:36 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 10:02:39 2017 +0100
libdm: make _stats_resize_group() num_regions argument uint64_t
---
libdm/libdm-stats.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 5a454fd..2e6022d 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4181,21 +4181,23 @@ int dm_stats_get_group_descriptor(const struct dm_stats *dms,
* Resize the group bitmap corresponding to group_id so that it can
* contain at least num_regions members.
*/
-static int _stats_resize_group(struct dm_stats_group *group, int num_regions)
+static int _stats_resize_group(struct dm_stats_group *group,
+ uint64_t num_regions)
{
- int last_bit = dm_bit_get_last(group->regions);
+ uint64_t last_bit = dm_bit_get_last(group->regions);
dm_bitset_t new, old;
if (last_bit >= num_regions) {
- log_error("Cannot resize group bitmap to %d with bit %d set.",
- num_regions, last_bit);
+ log_error("Cannot resize group bitmap to " FMTu64
+ " with bit " FMTu64 " set.", num_regions, last_bit);
return 0;
}
- log_very_verbose("Resizing group bitmap from %d to %d (last_bit: %d).",
+ log_very_verbose("Resizing group bitmap from " FMTu64
+ " to " FMTu64 " (last_bit: " FMTu64 ").",
group->regions[0], num_regions, last_bit);
- new = dm_bitset_create(NULL, num_regions);
+ new = dm_bitset_create(NULL, (unsigned) num_regions);
if (!new) {
log_error("Could not allocate memory for new group bitmap.");
return 0;
7 years
master - libdm: make _find_extent() nr_extents argument uint64_t
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=722542fabb30915653a...
Commit: 722542fabb30915653a222a6dca8f34338db4e80
Parent: 5e74e43896c3b35584e3edfb76fa407adbed862c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:41:33 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 10:02:35 2017 +0100
libdm: make _find_extent() nr_extents argument uint64_t
---
libdm/libdm-stats.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index b553da5..5a454fd 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4472,7 +4472,7 @@ bad:
#define MATCH_EXTENT(e, s, l) \
(((e).start == (s)) && ((e).len == (l)))
-static struct _extent *_find_extent(size_t nr_extents, struct _extent *extents,
+static struct _extent *_find_extent(uint64_t nr_extents, struct _extent *extents,
uint64_t start, uint64_t len)
{
size_t i;
@@ -4685,9 +4685,10 @@ static uint64_t *_stats_map_file_regions(struct dm_stats *dms, int fd,
*/
for (i = 0; i < *count; i++) {
if (update) {
- if ((old_ext = _find_extent(nr_kept, old_extents,
- extents[i].start,
- extents[i].len))) {
+ if ((old_ext = _find_extent((uint64_t) nr_kept,
+ old_extents,
+ extents[i].start,
+ extents[i].len))) {
regions[i] = old_ext->id;
continue;
}
7 years
master - dmfilemapd: cast return value of strto* functions when needed
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5e74e43896c3b35584e...
Commit: 5e74e43896c3b35584e3edfb76fa407adbed862c
Parent: 834574cc27851266bd288163cddcab36b4db22cb
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:32:55 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 10:02:31 2017 +0100
dmfilemapd: cast return value of strto* functions when needed
---
daemons/dmfilemapd/dmfilemapd.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index 7939c48..88f8af2 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -225,7 +225,7 @@ static int _is_open(const char *path)
while ((proc_dp = readdir(proc_d)) != NULL) {
if (!isdigit(proc_dp->d_name[0]))
continue;
- pid = strtol(proc_dp->d_name, NULL, 10);
+ pid = (pid_t) strtol(proc_dp->d_name, NULL, 10);
if (!pid)
continue;
if (_is_open_in_pid(pid, path)) {
@@ -280,7 +280,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
fm->nr_regions = 1;
/* parse <fd> */
- fm->fd = strtol(argv[0], &endptr, 10);
+ fm->fd = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse file descriptor: %s", argv[0]);
return 0;
@@ -334,7 +334,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
/* parse [<foreground>[<verbose>]] */
if (argc) {
- _foreground = strtol(argv[0], &endptr, 10);
+ _foreground = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse debug argument: %s.",
argv[0]);
@@ -343,7 +343,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
argc--;
argv++;
if (argc) {
- _verbose = strtol(argv[0], &endptr, 10);
+ _verbose = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse verbose "
"argument: %s", argv[0]);
7 years
master - dmfilemapd: use log_sys_error in _filemap_monitor_set_notify
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=834574cc27851266bd2...
Commit: 834574cc27851266bd288163cddcab36b4db22cb
Parent: bfc880994c80a798f28d51558ee120f70d65dd0f
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:29:20 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 10:01:57 2017 +0100
dmfilemapd: use log_sys_error in _filemap_monitor_set_notify
Since _filemap_monitor_set_notify() is only called after daemon
start up it should not use the _early_log() macros. Instead, use
log_sys_error to log errors from the two syscalls in the function.
---
daemons/dmfilemapd/dmfilemapd.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index 3e691e8..7939c48 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -409,13 +409,13 @@ static int _filemap_monitor_set_notify(struct filemap_monitor *fm)
* and does not fork or exec.
*/
if ((inotify_fd = inotify_init1(IN_NONBLOCK)) < 0) {
- _early_log("Failed to initialise inotify.");
+ log_sys_error("inotify_init1", "IN_NONBLOCK");
return 0;
}
if ((watch_fd = inotify_add_watch(inotify_fd, fm->path,
IN_MODIFY | IN_DELETE_SELF)) < 0) {
- _early_log("Failed to add inotify watch.");
+ log_sys_error("inotify_add_watch", fm->path);
return 0;
}
fm->inotify_fd = inotify_fd;
7 years
master - dmfilemapd: cast sysconf() return value to int
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bfc880994c80a798f28...
Commit: bfc880994c80a798f28d51558ee120f70d65dd0f
Parent: 76b6cbea60b6af6a89d3fc40486486c97df28fcc
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:28:43 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 09:57:58 2017 +0100
dmfilemapd: cast sysconf() return value to int
---
daemons/dmfilemapd/dmfilemapd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index 2c80d42..3e691e8 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -660,7 +660,7 @@ static int _daemonise(struct filemap_monitor *fm)
}
}
- for (fd = sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; fd--) {
+ for (fd = (int) sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; fd--) {
if (fd == fm->fd)
continue;
close(fd);
7 years
master - dmfilemapd: fix len type in _filemap_monitor_check_file_unlinked()
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=76b6cbea60b6af6a89d...
Commit: 76b6cbea60b6af6a89d3fc40486486c97df28fcc
Parent: 660bd4fe3e86cc68d269ad707919f040b163f164
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:26:39 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 09:57:58 2017 +0100
dmfilemapd: fix len type in _filemap_monitor_check_file_unlinked()
Make 'len' a size_t to match the return type of readlink(2).
---
daemons/dmfilemapd/dmfilemapd.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index 225335c..2c80d42 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -559,7 +559,8 @@ static int _filemap_monitor_check_file_unlinked(struct filemap_monitor *fm)
{
char path_buf[PATH_MAX];
char link_buf[PATH_MAX];
- int same, fd, len;
+ int same, fd;
+ ssize_t len;
fm->deleted = 0;
7 years
master - dmfilemapd: make filemap_monitor->nr_regions uint64_t
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=660bd4fe3e86cc68d26...
Commit: 660bd4fe3e86cc68d269ad707919f040b163f164
Parent: ac6089ee8dce83bd61d90344bf67aeef8f319f41
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:23:57 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 09:57:58 2017 +0100
dmfilemapd: make filemap_monitor->nr_regions uint64_t
---
daemons/dmfilemapd/dmfilemapd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c
index dd1db03..225335c 100644
--- a/daemons/dmfilemapd/dmfilemapd.c
+++ b/daemons/dmfilemapd/dmfilemapd.c
@@ -55,7 +55,7 @@ struct filemap_monitor {
/* monitoring heuristics */
int64_t blocks; /* allocated blocks, from stat.st_blocks */
- int64_t nr_regions;
+ uint64_t nr_regions;
int deleted;
};
7 years
master - libdm: use DM_STATS_GROUP_* constants in dm_stats_create_regions_from_fd
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac6089ee8dce83bd61d...
Commit: ac6089ee8dce83bd61d90344bf67aeef8f319f41
Parent: fe0922b8a6632456d9f20085f1c67d2ddb5b2d88
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 20:02:26 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 09:57:58 2017 +0100
libdm: use DM_STATS_GROUP_* constants in dm_stats_create_regions_from_fd
---
libdm/libdm-stats.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 290097f..b553da5 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -4777,7 +4777,8 @@ uint64_t *dm_stats_create_regions_from_fd(struct dm_stats *dms, int fd,
}
if (!(regions = _stats_map_file_regions(dms, fd, bounds, precise,
- -1, &count, ®roup)))
+ DM_STATS_GROUP_NOT_PRESENT,
+ &count, ®roup)))
return NULL;
if (!group)
7 years
master - dmsetup: simplify branching in _stats_update_file()
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fe0922b8a6632456d9f...
Commit: fe0922b8a6632456d9f20085f1c67d2ddb5b2d88
Parent: 803b1775ba06218ad193402a13e6da4b3406511a
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Wed Mar 29 18:30:16 2017 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Mar 30 09:57:58 2017 +0100
dmsetup: simplify branching in _stats_update_file()
The fallback branch in _stats_update_file() is redundant (since the
branch taken when the daemon starts successfully must jump to the
'out' label anyway): remove it and re-order the conditions to
improve readability.
---
tools/dmsetup.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 5f07ab6..d25b3bd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -5716,17 +5716,18 @@ static int _stats_update_file(CMD_ARGS)
* If starting the daemon fails, fall back to a direct update.
*/
if (!_switches[NOMONITOR_ARG]) {
- if (!dm_stats_start_filemapd(fd, group_id, abspath, mode,
- foreground, verbose)) {
- log_warn("Failed to start filemap monitoring daemon.");
- goto fallback;
- }
- goto out;
+ if (dm_stats_start_filemapd(fd, group_id, abspath, mode,
+ foreground, verbose))
+ goto out;
+
+ log_warn("Failed to start filemap monitoring daemon.");
+
+ /* fall back to one-shot update */
}
-fallback:
/*
- * --nomonitor case - perform a one-shot update directly from dmstats.
+ * --nomonitor and fall back case - perform a one-shot update directly
+ * from dmsetup.
*/
regions = dm_stats_update_regions_from_fd(dms, fd, group_id);
7 years