]> sourceware.org Git - lvm2.git/commitdiff
cache: improve wait for cache clear
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 18 Dec 2016 14:05:57 +0000 (15:05 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 18 Dec 2016 18:22:11 +0000 (19:22 +0100)
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
lib/metadata/cache_manip.c

index 50023082c613524466d11f3591d131a9738dc383..2e9c9535227ebe97d1327ea0a95c9672649ae41c 100644 (file)
--- 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.
index d73142d34ff14b0891b20afd55e9ac088e0582d6..54d907cec1b4c3105a7492e79ff384717a66f96f 100644 (file)
@@ -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 */
This page took 0.052089 seconds and 5 git commands to generate.