Skip to content

Commit ab60ca2

Browse files
committed
dm cache policy smq: ensure IO doesn't prevent cleaner policy progress
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-284.30.1.el9_2 commit-author Joe Thornber <[email protected]> commit 1e4ab7b 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]> (cherry picked from commit 1e4ab7b) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 2064a27 commit ab60ca2

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
@@ -854,7 +854,13 @@ struct smq_policy {
854854

855855
struct background_tracker *bg_work;
856856

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

860866
/*----------------------------------------------------------------*/
@@ -1135,7 +1141,7 @@ static bool clean_target_met(struct smq_policy *mq, bool idle)
11351141
* Cache entries may not be populated. So we cannot rely on the
11361142
* size of the clean queue.
11371143
*/
1138-
if (idle) {
1144+
if (idle || mq->cleaner) {
11391145
/*
11401146
* We'd like to clean everything.
11411147
*/
@@ -1718,11 +1724,9 @@ static void calc_hotspot_params(sector_t origin_size,
17181724
*hotspot_block_size /= 2u;
17191725
}
17201726

1721-
static struct dm_cache_policy *__smq_create(dm_cblock_t cache_size,
1722-
sector_t origin_size,
1723-
sector_t cache_block_size,
1724-
bool mimic_mq,
1725-
bool migrations_allowed)
1727+
static struct dm_cache_policy *
1728+
__smq_create(dm_cblock_t cache_size, sector_t origin_size, sector_t cache_block_size,
1729+
bool mimic_mq, bool migrations_allowed, bool cleaner)
17261730
{
17271731
unsigned i;
17281732
unsigned nr_sentinels_per_queue = 2u * NR_CACHE_LEVELS;
@@ -1809,6 +1813,7 @@ static struct dm_cache_policy *__smq_create(dm_cblock_t cache_size,
18091813
goto bad_btracker;
18101814

18111815
mq->migrations_allowed = migrations_allowed;
1816+
mq->cleaner = cleaner;
18121817

18131818
return &mq->policy;
18141819

@@ -1832,21 +1837,24 @@ static struct dm_cache_policy *smq_create(dm_cblock_t cache_size,
18321837
sector_t origin_size,
18331838
sector_t cache_block_size)
18341839
{
1835-
return __smq_create(cache_size, origin_size, cache_block_size, false, true);
1840+
return __smq_create(cache_size, origin_size, cache_block_size,
1841+
false, true, false);
18361842
}
18371843

18381844
static struct dm_cache_policy *mq_create(dm_cblock_t cache_size,
18391845
sector_t origin_size,
18401846
sector_t cache_block_size)
18411847
{
1842-
return __smq_create(cache_size, origin_size, cache_block_size, true, true);
1848+
return __smq_create(cache_size, origin_size, cache_block_size,
1849+
true, true, false);
18431850
}
18441851

18451852
static struct dm_cache_policy *cleaner_create(dm_cblock_t cache_size,
18461853
sector_t origin_size,
18471854
sector_t cache_block_size)
18481855
{
1849-
return __smq_create(cache_size, origin_size, cache_block_size, false, false);
1856+
return __smq_create(cache_size, origin_size, cache_block_size,
1857+
false, false, true);
18501858
}
18511859

18521860
/*----------------------------------------------------------------*/

0 commit comments

Comments
 (0)