From: Joe Thornber Date: Thu, 27 Nov 2014 12:26:46 +0000 (+0000) Subject: dm cache: dirty flag was mistakenly being cleared when promoting via overwrite X-Git-Tag: v3.19-rc1~177^2~5 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=1e32134a5a404e80bfb47fad8a94e9bbfcbdacc5;p=linux.git dm cache: dirty flag was mistakenly being cleared when promoting via overwrite 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 Signed-off-by: Mike Snitzer Cc: stable@vger.kernel.org --- diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index ef842feda101..1a090de0c4b8 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -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); }