dm cache: lift common migration preparation code to alloc_migration()

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
Mike Snitzer 2017-11-09 11:59:37 -05:00
parent ede6507d67
commit ef7afb3656
1 changed files with 7 additions and 10 deletions

View File

@ -551,10 +551,13 @@ static struct dm_cache_migration *alloc_migration(struct cache *cache)
struct dm_cache_migration *mg; struct dm_cache_migration *mg;
mg = mempool_alloc(cache->migration_pool, GFP_NOWAIT); mg = mempool_alloc(cache->migration_pool, GFP_NOWAIT);
if (mg) { if (!mg)
mg->cache = cache; return NULL;
atomic_inc(&mg->cache->nr_allocated_migrations);
} memset(mg, 0, sizeof(*mg));
mg->cache = cache;
atomic_inc(&cache->nr_allocated_migrations);
return mg; return mg;
} }
@ -1542,9 +1545,6 @@ static int mg_start(struct cache *cache, struct policy_work *op, struct bio *bio
return -ENOMEM; return -ENOMEM;
} }
memset(mg, 0, sizeof(*mg));
mg->cache = cache;
mg->op = op; mg->op = op;
mg->overwrite_bio = bio; mg->overwrite_bio = bio;
@ -1678,9 +1678,6 @@ static int invalidate_start(struct cache *cache, dm_cblock_t cblock,
return -ENOMEM; return -ENOMEM;
} }
memset(mg, 0, sizeof(*mg));
mg->cache = cache;
mg->overwrite_bio = bio; mg->overwrite_bio = bio;
mg->invalidate_cblock = cblock; mg->invalidate_cblock = cblock;
mg->invalidate_oblock = oblock; mg->invalidate_oblock = oblock;