[dm-devel] dm-cache: clean cache resyncs to origin on every boot

Joe Thornber thornber at redhat.com
Thu Oct 22 17:19:36 UTC 2015


On Tue, Oct 20, 2015 at 11:06:07PM +0500, Bogdan Vasiliev wrote:
> Volume was clearly removed without dirty cahe blocks, re-initialized
> and began full re-sync to the origin. Is this normal behavior?

No, there is indeed a bug, fixed with the patch below.

Thanks,

- Joe


commit 7e0a9739fd9e72dc51490bdff92796400b12a34f
Author: Joe Thornber <ejt at redhat.com>
Date:   Thu Oct 22 18:10:55 2015 +0100

    [dm-cache] The CLEAN_SHUTDOWN flag was not being set
    
    or rather, it was being set on the disk, then immediately cleared again.
    
    If the CLEAN_SHUTDOWN flag is not set when a cache is loaded then all cache
    blocks are marked as dirty and a full writeback occurs.

diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index e956c44..2073d30 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -634,10 +634,11 @@ static int __commit_transaction(struct dm_cache_metadata *cmd,
 
        disk_super = dm_block_data(sblock);
 
+       disk_super->flags = cpu_to_le32(cmd->flags);
+
        if (mutator)
                update_flags(disk_super, mutator);
 
-       disk_super->flags = cpu_to_le32(cmd->flags);
        disk_super->mapping_root = cpu_to_le64(cmd->root);
        disk_super->hint_root = cpu_to_le64(cmd->hint_root);
        disk_super->discard_root = cpu_to_le64(cmd->discard_root);




More information about the dm-devel mailing list