master - cache: prepare status checking for layer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a24eae6e82f365...
Commit: a24eae6e82f365c66f4faeabc975ead0c476916b
Parent: bf157ed833f8732c4e264422bd8be46fdf75673a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 21:52:27 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:23:13 2016 +0100
cache: prepare status checking for layer
To be ready to show status of cache volume, call the status
with layer. Layer is automatically detected in this case when
cache volume is used in 'layered' form (needs -real suffix).
---
WHATS_NEW | 1 +
lib/activate/activate.c | 4 ++--
lib/metadata/cache_manip.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2e9c953..6b9a310 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Support status checking of cache volume used in layer.
Avoid shifting by one number of blocks when clearing dirty cache volume.
Extend metadata validation of external origin LV use count.
Fix dm table when the last user of active external origin is removed.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c554337..b7009e6 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -770,7 +770,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
/* INFO is not set as cache-pool cannot be active.
* STATUS is collected from cache LV */
lv_seg = get_only_segment_using_this_lv(lv);
- (void) _lv_info(cmd, lv_seg->lv, 0, NULL, lv_seg, &status->seg_status, 0, 0);
+ (void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
return 1;
}
@@ -1171,7 +1171,7 @@ int lv_cache_status(const struct logical_volume *cache_lv,
return 0;
}
- if (!lv_info(cache_lv->vg->cmd, cache_lv, 0, NULL, 0, 0)) {
+ if (!lv_info(cache_lv->vg->cmd, cache_lv, 1, NULL, 0, 0)) {
log_error("Cannot check status for locally inactive cache volume %s.",
display_lvname(cache_lv));
return 0;
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 54d907c..ed72fae 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -475,7 +475,7 @@ int lv_cache_remove(struct logical_volume *cache_lv)
}
/* Localy active volume is needed for writeback */
- if (!lv_is_active_locally(cache_lv)) {
+ if (!lv_info(cache_lv->vg->cmd, cache_lv, 1, NULL, 0, 0)) {
/* Give up any remote locks */
if (!deactivate_lv(cache_lv->vg->cmd, cache_lv)) {
log_error("Cannot deactivate remotely active cache volume %s.",
7 years, 4 months
master - cache: improve wait for cache clear
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bf157ed833f873...
Commit: bf157ed833f8732c4e264422bd8be46fdf75673a
Parent: 36f609e513262547aa4d92c2b55d98b1471ba2e2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 18 15:05:57 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:22:11 2016 +0100
cache: improve wait for cache clear
Avoid printing misleading message about single dirty block.
Instead properly detect condition where the 'cleaner' policy
needs to be installed without 'overloading' dirty variable.
Also print warning if we would be clearing read-only volume.
(it really shouldn't happen).
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 17 ++++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5002308..2e9c953 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Avoid shifting by one number of blocks when clearing dirty cache volume.
Extend metadata validation of external origin LV use count.
Fix dm table when the last user of active external origin is removed.
Improve reported lvs status for active external origin volume.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index d73142d..54d907c 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -383,7 +383,7 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
const struct logical_volume *lock_lv = lv_lock_holder(cache_lv);
struct lv_segment *cache_seg = first_seg(cache_lv);
struct lv_status_cache *status;
- int cleaner_policy;
+ int cleaner_policy, writeback;
uint64_t dirty_blocks;
*is_clean = 0;
@@ -402,14 +402,11 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
cleaner_policy = !strcmp(status->cache->policy_name, "cleaner");
dirty_blocks = status->cache->dirty_blocks;
-
- /* No clear policy and writeback mode means dirty */
- if (!cleaner_policy &&
- (status->cache->feature_flags & DM_CACHE_FEATURE_WRITEBACK))
- dirty_blocks++;
+ writeback = (status->cache->feature_flags & DM_CACHE_FEATURE_WRITEBACK);
dm_pool_destroy(status->mem);
- if (!dirty_blocks)
+ /* Only clear when policy is Clear or mode != writeback */
+ if (!dirty_blocks && (cleaner_policy || !writeback))
break;
log_print_unless_silent("Flushing " FMTu64 " blocks for cache %s.",
@@ -420,6 +417,12 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
continue;
}
+ if (!(cache_lv->status & LVM_WRITE)) {
+ log_warn("WARNING: Dirty blocks found on read-only cache volume %s.",
+ display_lvname(cache_lv));
+ /* TODO: can we actually clean something? */
+ }
+
/* Switch to cleaner policy to flush the cache */
cache_seg->cleaner_policy = 1;
/* Reaload kernel with "cleaner" policy */
7 years, 4 months
master - validation: check external property is matching
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=36f609e5132625...
Commit: 36f609e513262547aa4d92c2b55d98b1471ba2e2
Parent: 7db46c4a39fd945f295a5bd4191bd48828072d24
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 21:58:35 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:17:59 2016 +0100
validation: check external property is matching
Detect if number of external_count is matching
referencing devices for external_origin LV.
---
WHATS_NEW | 1 +
lib/metadata/merge.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6d36890..5002308 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Extend metadata validation of external origin LV use count.
Fix dm table when the last user of active external origin is removed.
Improve reported lvs status for active external origin volume.
Fix table load for splitted RAID LV and require explicit activation.
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index 6d52bc4..947513b 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -398,6 +398,18 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
inc_error_count;
}
}
+
+ if (lv_is_external_origin(lv)) {
+ seg_found = 0;
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv)
+ if (sl->seg->external_lv == lv)
+ seg_found++;
+ if (seg_found != lv->external_count) {
+ log_error("LV %s: external origin count does not match.",
+ lv->name);
+ inc_error_count;
+ }
+ }
}
dm_list_iterate_items(seg, &lv->segments) {
7 years, 4 months
master - thin: reload external origin with last thin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7db46c4a39fd94...
Commit: 7db46c4a39fd945f295a5bd4191bd48828072d24
Parent: c71fefad8d5e1d9a075553ab69791ddbf6bcb153
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 21:55:02 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:13:34 2016 +0100
thin: reload external origin with last thin
External origin could be activated as stand-alone device.
When the last thin LV is removed, external origin is no longer
the external origin and it's layer property was dropped.
Ensure dm table is correct by reloading external origin
(when it's active).
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 93fc93e..6d36890 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Fix dm table when the last user of active external origin is removed.
Improve reported lvs status for active external origin volume.
Fix table load for splitted RAID LV and require explicit activation.
Always active splitted RAID LV exclusively locally.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1889998..92a6d44 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1264,6 +1264,7 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
uint32_t count = extents;
uint32_t reduction;
struct logical_volume *pool_lv;
+ struct logical_volume *external_lv = NULL;
if (lv_is_merging_origin(lv)) {
log_debug_metadata("Dropping snapshot merge of %s to removed origin %s.",
@@ -1275,6 +1276,9 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
if (!count)
break;
+ if (seg->external_lv)
+ external_lv = seg->external_lv;
+
if (seg->len <= count) {
if (seg->merge_lv) {
log_debug_metadata("Dropping snapshot merge of removed %s to origin %s.",
@@ -1341,6 +1345,12 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
!lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv))
return_0;
+ /* Removal of last user enforces refresh */
+ if (external_lv && !lv_is_external_origin(external_lv) &&
+ lv_is_active(external_lv) &&
+ !lv_update_and_reload(external_lv))
+ return_0;
+
return 1;
}
7 years, 4 months
master - lvs: show status for layer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c71fefad8d5e1d...
Commit: c71fefad8d5e1d9a075553ab69791ddbf6bcb153
Parent: bdfc96cb089031c6d95dccb0ff66616efdb16783
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 17 21:54:51 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:12:12 2016 +0100
lvs: show status for layer
When LV is external origin, show info for LV but
status for -layer. So we expose more info to a user
as otherwise active external origin is only linear
mapping of -real layer.
We do the same for i.e. old snaphost origin.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index eee6e98..93fc93e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Improve reported lvs status for active external origin volume.
Fix table load for splitted RAID LV and require explicit activation.
Always active splitted RAID LV exclusively locally.
Do not use LV RAID status bit for segment status.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index b4c8a2c..c554337 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -784,6 +784,13 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
status->info.exists = 0; /* So pool LV is not active */
}
return 1;
+ } else if (lv_is_external_origin(lv)) {
+ if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
+ with_open_count, with_read_ahead))
+ return_0;
+
+ (void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
+ return 1;
} else if (lv_is_origin(lv)) {
/* Query segment status for 'layered' (-real) device most of the time,
* only for merging snapshot, query its progress.
7 years, 4 months
master - raid: fix activation of tracked image
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bdfc96cb089031...
Commit: bdfc96cb089031c6d95dccb0ff66616efdb16783
Parent: a15f0d181ca2fb44c9c854dfba425d372a8756c6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 14 21:47:38 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Dec 18 19:10:38 2016 +0100
raid: fix activation of tracked image
Activation of raid has brough up also splitted image with tracing
(without taking lock for this).
So when raid is now activate - such image is not put into
table (with _rmeta). When user needs such device, just active it.
---
WHATS_NEW | 3 ++-
lib/activate/dev_manager.c | 3 +++
lib/metadata/metadata-exported.h | 1 +
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4ac3377..eee6e98 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,8 +1,9 @@
Version 2.02.169 -
=====================================
+ Fix table load for splitted RAID LV and require explicit activation.
Always active splitted RAID LV exclusively locally.
Do not use LV RAID status bit for segment status.
- Check segtype directly instead of checking RAID in segment status.
+ Check segtype directly instead of checking RAID in segment status.
Reusing exiting code for raid image removal.
Fix pvmove leaving -pvmove0 error device in clustered VG.
Avoid adding extra '_' at end of raid extracted images or metadata.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 581e900..8245454 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2681,12 +2681,15 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
/* Add any LVs used by this segment */
for (s = 0; s < seg->area_count; ++s) {
if ((seg_type(seg, s) == AREA_LV) &&
+ /* do not bring up tracked image */
+ !lv_is_raid_image_with_tracking(seg_lv(seg, s)) &&
/* origin only for cache without pending delete */
(!dm->track_pending_delete || !seg_is_cache(seg)) &&
!_add_new_lv_to_dtree(dm, dtree, seg_lv(seg, s),
laopts, NULL))
return_0;
if (seg_is_raid_with_meta(seg) && seg->meta_areas && seg_metalv(seg, s) &&
+ !lv_is_raid_image_with_tracking(seg_lv(seg, s)) &&
!_add_new_lv_to_dtree(dm, dtree, seg_metalv(seg, s),
laopts, NULL))
return_0;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 4bf466b..aa40c6c 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -226,6 +226,7 @@
#define lv_is_raid(lv) (((lv)->status & RAID) ? 1 : 0)
#define lv_is_raid_image(lv) (((lv)->status & RAID_IMAGE) ? 1 : 0)
+#define lv_is_raid_image_with_tracking(lv) ((lv_is_raid_image(lv) && !((lv)->status & LVM_WRITE)) ? 1 : 0)
#define lv_is_raid_metadata(lv) (((lv)->status & RAID_META) ? 1 : 0)
#define lv_is_raid_type(lv) (((lv)->status & (RAID | RAID_IMAGE | RAID_META)) ? 1 : 0)
7 years, 4 months
master - dmstats: don't declare _start_timestamp if HAVE_SYS_TIMERFD_H
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a15f0d181ca2fb...
Commit: a15f0d181ca2fb44c9c854dfba425d372a8756c6
Parent: 3e53adf7c0b83194a74a9fa75a7ebbf1c077de9a
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 14:08:11 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 14:08:11 2016 +0000
dmstats: don't declare _start_timestamp if HAVE_SYS_TIMERFD_H
The _start_timestamp is not used by the TIMERFD clock.
---
tools/dmsetup.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index e5ac80a..3f2c619 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -282,13 +282,15 @@ const char *_stats_types[] = {
/* report timekeeping */
static struct dm_timestamp *_cycle_timestamp = NULL;
+#ifndef HAVE_SYS_TIMERFD_H
static struct dm_timestamp *_start_timestamp = NULL;
+#else /* HAVE_SYS_TIMERFD_H */
+static int _timer_fd = -1; /* timerfd file descriptor. */
+#endif /* !HAVE_SYS_TIMERFD_H */
+
static uint64_t _interval = 0; /* configured interval in nsecs */
static uint64_t _new_interval = 0; /* flag top-of-interval */
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
-#ifdef HAVE_SYS_TIMERFD_H
-static int _timer_fd = -1; /* timerfd file descriptor. */
-#endif /* HAVE_SYS_TIMERFD_H */
/* Invalid fd value used to signal end-of-reporting. */
#define TIMER_STOPPED -2
7 years, 4 months
master - dmstats: fix TIMERFD _timer_running() test
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3e53adf7c0b831...
Commit: 3e53adf7c0b83194a74a9fa75a7ebbf1c077de9a
Parent: 5a4750d76c9930a6e4a181ab664f0cac4d1a400b
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 14:07:25 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 14:07:25 2016 +0000
dmstats: fix TIMERFD _timer_running() test
---
tools/dmsetup.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 06d609b..e5ac80a 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -652,10 +652,7 @@ static int _do_timer_wait(void)
static int _timer_running(void)
{
- /*
- * Clock shutdown for exit - nothing to do.
- */
- return ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp);
+ return ((_timer_fd != TIMER_STOPPED) || _cycle_timestamp);
}
#else /* !HAVE_SYS_TIMERFD_H */
7 years, 4 months
master - dmstats: fix interval number reporting with --count=0
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a4750d76c9930...
Commit: 5a4750d76c9930a6e4a181ab664f0cac4d1a400b
Parent: 5635cd3b0337ac854a82a1a15cef2609c2091e6c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 12:58:03 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 13:03:45 2016 +0000
dmstats: fix interval number reporting with --count=0
When --count=0 interval numbers are miscalculated:
Interval #18446744069414584325 time delta: 999920887ns
Interval #18446744069414584325 current err: -79113ns
End interval #18446744069414584325 duration: 999920887ns
This is because the command line argument is cast through the
uint32_t type, and fixed to UINT32_MAX:
_count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;
We also need to handle --count=0 specially when calculating the
interval number: since intervals count from #1, this must account
for the implicit "minus one" when converting from zero to the
UINT64_MAX value used (which is too large to store in _int_args).
---
tools/dmsetup.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index b1967db..06d609b 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -264,7 +264,7 @@ static struct dm_tree *_dtree;
static struct dm_report *_report;
static report_type_t _report_type;
static dev_name_t _dev_name_type;
-static uint32_t _count = 1; /* count of repeating reports */
+static uint64_t _count = 1; /* count of repeating reports */
static struct dm_timestamp *_initial_timestamp = NULL;
static uint64_t _disp_factor = 512; /* display sizes in sectors */
static char _disp_units = 's';
@@ -557,7 +557,8 @@ static void _destroy_split_name(struct dm_split_name *split_name)
*/
static uint64_t _interval_num(void)
{
- return 1 + (uint64_t) _int_args[COUNT_ARG] - _count;
+ uint64_t count_arg = _int_args[COUNT_ARG];
+ return ((uint64_t) _int_args[COUNT_ARG] - _count) + !!count_arg;
}
#ifdef HAVE_SYS_TIMERFD_H
@@ -6873,10 +6874,10 @@ unknown:
goto_out;
}
- if (_switches[COUNT_ARG])
- _count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;
- else if (_switches[INTERVAL_ARG])
- _count = UINT32_MAX;
+ if (_switches[COUNT_ARG] && _int_args[COUNT_ARG])
+ _count = (uint64_t)_int_args[COUNT_ARG];
+ else if (_switches[COUNT_ARG] || _switches[INTERVAL_ARG])
+ _count = UINT64_MAX;
if (_switches[UNITS_ARG]) {
_disp_factor = _factor_from_units(_string_args[UNITS_ARG],
7 years, 4 months
master - dmstats: separate TIMERFD and useleep() exit conditions
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5635cd3b0337ac...
Commit: 5635cd3b0337ac854a82a1a15cef2609c2091e6c
Parent: 886b4f755d7f33194f92dafbf2c22517db4de374
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 12:42:47 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 13:03:44 2016 +0000
dmstats: separate TIMERFD and useleep() exit conditions
The time management code mixes tests of the _timer_fd value with
code that should be timer agnostic: this causes problems for users
of the usleep() timer, since it cannot properly detect the start
of a new interval:
Beginning first interval
Interval #18446744069414584348 time delta: 1000000000ns
Interval #18446744069414584348 current err: 0ns
End interval #18446744069414584348 duration: 1000000000ns
Adjusted sample interval duration: 1000000000ns
[...]
Beginning first interval
Interval #18446744069414584349 time delta: 1000000000ns
Interval #18446744069414584349 current err: 0ns
End interval #18446744069414584349 duration: 1000000000ns
Adjusted sample interval duration: 1000000000ns
Separate these out, by defining a _timer_running() call that each
timer implements, and only define _timer_fd if we are compiling
with TIMERFD enabled.
---
tools/dmsetup.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 17c5742..b1967db 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -286,7 +286,9 @@ static struct dm_timestamp *_start_timestamp = NULL;
static uint64_t _interval = 0; /* configured interval in nsecs */
static uint64_t _new_interval = 0; /* flag top-of-interval */
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
+#ifdef HAVE_SYS_TIMERFD_H
static int _timer_fd = -1; /* timerfd file descriptor. */
+#endif /* HAVE_SYS_TIMERFD_H */
/* Invalid fd value used to signal end-of-reporting. */
#define TIMER_STOPPED -2
@@ -647,6 +649,14 @@ static int _do_timer_wait(void)
return _do_timerfd_wait();
}
+static int _timer_running(void)
+{
+ /*
+ * Clock shutdown for exit - nothing to do.
+ */
+ return ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp);
+}
+
#else /* !HAVE_SYS_TIMERFD_H */
static int _start_usleep_timer(void)
{
@@ -718,6 +728,11 @@ static int _do_timer_wait(void)
return _do_usleep_wait();
}
+static int _timer_running(void)
+{
+ return (_start_timestamp != NULL);
+}
+
#endif /* HAVE_SYS_TIMERFD_H */
static int _update_interval_times(void)
@@ -729,7 +744,7 @@ static int _update_interval_times(void)
/*
* Clock shutdown for exit - nothing to do.
*/
- if ((_timer_fd == TIMER_STOPPED) && !_cycle_timestamp)
+ if (!_timer_running())
goto out;
/* clock is running */
@@ -805,7 +820,7 @@ static int _update_interval_times(void)
out:
/* timer stopped or never started */
- if (!r || _timer_fd < 0) {
+ if (!r || !_timer_running()) {
/* The _cycle_timestamp has not yet been allocated if we
* fail to obtain this_timestamp on the first interval.
*/
7 years, 4 months