dm cache: fix spurious cell_defer when dealing with partial block at end of device
authorJoe Thornber <ejt@redhat.com>
Fri, 28 Nov 2014 09:48:25 +0000 (09:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2015 18:30:19 +0000 (10:30 -0800)
commit f824a2af3dfbbb766c02e19df21f985bceadf0ee upstream.

We never bother caching a partial block that is at the back end of the
origin device.  No cell ever gets locked, but the calling code was
assuming it was and trying to release it.

Now the code only releases if the cell has been set to a non NULL
value.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-cache-target.c

index 387b93d81138d4da4a7acead58f72582ca9a7e03..da496cfb458d7bc4d919bffd9fb3b1c45fa0fb9e 100644 (file)
@@ -2554,11 +2554,11 @@ static int __cache_map(struct cache *cache, struct bio *bio, struct dm_bio_priso
 static int cache_map(struct dm_target *ti, struct bio *bio)
 {
        int r;
-       struct dm_bio_prison_cell *cell;
+       struct dm_bio_prison_cell *cell = NULL;
        struct cache *cache = ti->private;
 
        r = __cache_map(cache, bio, &cell);
-       if (r == DM_MAPIO_REMAPPED) {
+       if (r == DM_MAPIO_REMAPPED && cell) {
                inc_ds(cache, bio, cell);
                cell_defer(cache, cell, false);
        }