mirror of
git://sourceware.org/git/lvm2.git
synced 2025-09-17 21:44:24 +03:00
Compare commits
11 Commits
v2_02_181
...
dev-bmr-dm
Author | SHA1 | Date | |
---|---|---|---|
|
d60364c634 | ||
|
b5ac2c458a | ||
|
181975e635 | ||
|
820843fcb6 | ||
|
d487fcfb0e | ||
|
f1e42e2186 | ||
|
3c69a7248a | ||
|
00e716b037 | ||
|
926ce7e279 | ||
|
6582cc4ff2 | ||
|
618f9ab04b |
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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]);
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -659,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);
|
||||
|
@@ -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;
|
||||
@@ -4217,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.");
|
||||
@@ -4472,7 +4474,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;
|
||||
@@ -4509,8 +4511,9 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
|
||||
{
|
||||
struct dm_stats_region *region = NULL;
|
||||
struct dm_stats_group *group = NULL;
|
||||
int64_t nr_kept, nr_old, i;
|
||||
uint64_t nr_kept, nr_old;
|
||||
struct _extent ext;
|
||||
int64_t i;
|
||||
|
||||
group = &dms->groups[group_id];
|
||||
|
||||
@@ -4569,7 +4572,7 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
|
||||
log_very_verbose("Found " FMTu64 " new extents",
|
||||
*count - nr_kept);
|
||||
|
||||
return nr_kept;
|
||||
return (int) nr_kept;
|
||||
out:
|
||||
dm_pool_abandon_object(mem);
|
||||
return -1;
|
||||
@@ -4592,15 +4595,15 @@ static uint64_t *_stats_map_file_regions(struct dm_stats *dms, int fd,
|
||||
uint64_t *count, int *regroup)
|
||||
{
|
||||
struct _extent *extents = NULL, *old_extents = NULL;
|
||||
uint64_t *regions = NULL, fail_region;
|
||||
uint64_t *regions = NULL, fail_region, i, num_bits;
|
||||
struct dm_stats_group *group = NULL;
|
||||
struct dm_pool *extent_mem = NULL;
|
||||
struct _extent *old_ext;
|
||||
char *hist_arg = NULL;
|
||||
int update, num_bits;
|
||||
struct statfs fsbuf;
|
||||
int64_t nr_kept = 0, i;
|
||||
int64_t nr_kept = 0;
|
||||
struct stat buf;
|
||||
int update;
|
||||
|
||||
update = _stats_group_id_present(dms, group_id);
|
||||
|
||||
@@ -4685,9 +4688,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;
|
||||
}
|
||||
@@ -4777,7 +4781,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)
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user