dm cache: dirty flag was mistakenly being cleared when promoting via overwrite
authorJoe Thornber <ejt@redhat.com>
Thu, 27 Nov 2014 12:26:46 +0000 (12:26 +0000)
committerMike Snitzer <snitzer@redhat.com>
Mon, 1 Dec 2014 16:30:12 +0000 (11:30 -0500)
If the incoming bio is a WRITE and completely covers a block then we
don't bother to do any copying for a promotion operation.  Once this is
done the cache block and origin block will be different, so we need to
set it to 'dirty'.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
drivers/md/dm-cache-target.c

index ef842feda1015b51e2fd66e53ec4d7cfb42dde3e..1a090de0c4b8fe138bbc41985bfe9151504d7d3f 100644 (file)
@@ -988,10 +988,14 @@ static void migration_success_post_commit(struct dm_cache_migration *mg)
                }
 
        } else {
-               clear_dirty(cache, mg->new_oblock, mg->cblock);
-               if (mg->requeue_holder)
+               if (mg->requeue_holder) {
+                       clear_dirty(cache, mg->new_oblock, mg->cblock);
                        cell_defer(cache, mg->new_ocell, true);
-               else {
+               } else {
+                       /*
+                        * The block was promoted via an overwrite, so it's dirty.
+                        */
+                       set_dirty(cache, mg->new_oblock, mg->cblock);
                        bio_endio(mg->new_ocell->holder, 0);
                        cell_defer(cache, mg->new_ocell, false);
                }