Skip to content

Commit 3d215ad

Browse files
jthornbergregkh
authored andcommitted
dm cache policy smq: ensure IO doesn't prevent cleaner policy progress
commit 1e4ab7b upstream. When using the cleaner policy to decommission the cache, there is never any writeback started from the cache as it is constantly delayed due to normal I/O keeping the device busy. Meaning @idle=false was always being passed to clean_target_met() Fix this by adding a specific 'cleaner' flag that is set when the cleaner policy is configured. This flag serves to always allow the cleaner's writeback work to be queued until the cache is decommissioned (even if the cache isn't idle). Reported-by: David Jeffery <[email protected]> Fixes: b29d498 ("dm cache: significant rework to leverage dm-bio-prison-v2") Cc: [email protected] Signed-off-by: Joe Thornber <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 507f70c commit 3d215ad

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

drivers/md/dm-cache-policy-smq.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,13 @@ struct smq_policy {
855855

856856
struct background_tracker *bg_work;
857857

858-
bool migrations_allowed;
858+
bool migrations_allowed:1;
859+
860+
/*
861+
* If this is set the policy will try and clean the whole cache
862+
* even if the device is not idle.
863+
*/
864+
bool cleaner:1;
859865
};
860866

861867
/*----------------------------------------------------------------*/
@@ -1136,7 +1142,7 @@ static bool clean_target_met(struct smq_policy *mq, bool idle)
11361142
* Cache entries may not be populated. So we cannot rely on the
11371143
* size of the clean queue.
11381144
*/
1139-
if (idle) {
1145+
if (idle || mq->cleaner) {
11401146
/*
11411147
* We'd like to clean everything.
11421148
*/
@@ -1719,11 +1725,9 @@ static void calc_hotspot_params(sector_t origin_size,
17191725
*hotspot_block_size /= 2u;
17201726
}
17211727

1722-
static struct dm_cache_policy *__smq_create(dm_cblock_t cache_size,
1723-
sector_t origin_size,
1724-
sector_t cache_block_size,
1725-
bool mimic_mq,
1726-
bool migrations_allowed)
1728+
static struct dm_cache_policy *
1729+
__smq_create(dm_cblock_t cache_size, sector_t origin_size, sector_t cache_block_size,
1730+
bool mimic_mq, bool migrations_allowed, bool cleaner)
17271731
{
17281732
unsigned int i;
17291733
unsigned int nr_sentinels_per_queue = 2u * NR_CACHE_LEVELS;
@@ -1810,6 +1814,7 @@ static struct dm_cache_policy *__smq_create(dm_cblock_t cache_size,
18101814
goto bad_btracker;
18111815

18121816
mq->migrations_allowed = migrations_allowed;
1817+
mq->cleaner = cleaner;
18131818

18141819
return &mq->policy;
18151820

@@ -1833,21 +1838,24 @@ static struct dm_cache_policy *smq_create(dm_cblock_t cache_size,
18331838
sector_t origin_size,
18341839
sector_t cache_block_size)
18351840
{
1836-
return __smq_create(cache_size, origin_size, cache_block_size, false, true);
1841+
return __smq_create(cache_size, origin_size, cache_block_size,
1842+
false, true, false);
18371843
}
18381844

18391845
static struct dm_cache_policy *mq_create(dm_cblock_t cache_size,
18401846
sector_t origin_size,
18411847
sector_t cache_block_size)
18421848
{
1843-
return __smq_create(cache_size, origin_size, cache_block_size, true, true);
1849+
return __smq_create(cache_size, origin_size, cache_block_size,
1850+
true, true, false);
18441851
}
18451852

18461853
static struct dm_cache_policy *cleaner_create(dm_cblock_t cache_size,
18471854
sector_t origin_size,
18481855
sector_t cache_block_size)
18491856
{
1850-
return __smq_create(cache_size, origin_size, cache_block_size, false, false);
1857+
return __smq_create(cache_size, origin_size, cache_block_size,
1858+
false, false, true);
18511859
}
18521860

18531861
/*----------------------------------------------------------------*/

0 commit comments

Comments
 (0)