summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2016-12-18 15:05:57 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2016-12-18 19:22:11 +0100
commitbf157ed833f8732c4e264422bd8be46fdf75673a (patch)
treed802cfbeeca3d5e8bc41356c807471d9b0edbff2
parent36f609e513262547aa4d92c2b55d98b1471ba2e2 (diff)
downloadlvm2-bf157ed833f8732c4e264422bd8be46fdf75673a.tar.gz
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).
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/metadata/cache_manip.c17
2 files changed, 11 insertions, 7 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 50023082c..2e9c95352 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 d73142d34..54d907cec 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 */