aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2016-09-15 09:36:24 -0400
committerMike Snitzer <snitzer@redhat.com>2016-09-22 11:15:03 -0400
commit9d1b404cbc3f990a4035dcf7ddd37adac2a99b3f (patch)
treee3afe884a02e400cf69d8e10f809b218d772b564
parent4e781b498ee5008ede91362d91404a362e7a46b3 (diff)
dm cache policy smq: distribute entries to random levels when switching to smq
For smq the 32 bit 'hint' stores the multiqueue level that the entry should be stored in. If a different policy has been used previously, and then switched to smq, the hints will be invalid. In which case we used to put all entries in the bottom level of the multiqueue, and then redistribute. Redistribution is faster if we put entries with invalid hints in random levels initially. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-cache-policy-smq.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c
index f3cec4e6333c..c33f4a6e1d7d 100644
--- a/drivers/md/dm-cache-policy-smq.c
+++ b/drivers/md/dm-cache-policy-smq.c
@@ -1359,6 +1359,11 @@ static void smq_clear_dirty(struct dm_cache_policy *p, dm_oblock_t oblock)
1359 spin_unlock_irqrestore(&mq->lock, flags); 1359 spin_unlock_irqrestore(&mq->lock, flags);
1360} 1360}
1361 1361
1362static unsigned random_level(dm_cblock_t cblock)
1363{
1364 return hash_32_generic(from_cblock(cblock), 9) & (NR_CACHE_LEVELS - 1);
1365}
1366
1362static int smq_load_mapping(struct dm_cache_policy *p, 1367static int smq_load_mapping(struct dm_cache_policy *p,
1363 dm_oblock_t oblock, dm_cblock_t cblock, 1368 dm_oblock_t oblock, dm_cblock_t cblock,
1364 uint32_t hint, bool hint_valid) 1369 uint32_t hint, bool hint_valid)
@@ -1369,7 +1374,7 @@ static int smq_load_mapping(struct dm_cache_policy *p,
1369 e = alloc_particular_entry(&mq->cache_alloc, from_cblock(cblock)); 1374 e = alloc_particular_entry(&mq->cache_alloc, from_cblock(cblock));
1370 e->oblock = oblock; 1375 e->oblock = oblock;
1371 e->dirty = false; /* this gets corrected in a minute */ 1376 e->dirty = false; /* this gets corrected in a minute */
1372 e->level = hint_valid ? min(hint, NR_CACHE_LEVELS - 1) : 1; 1377 e->level = hint_valid ? min(hint, NR_CACHE_LEVELS - 1) : random_level(cblock);
1373 push(mq, e); 1378 push(mq, e);
1374 1379
1375 return 0; 1380 return 0;