summaryrefslogtreecommitdiff
path: root/drivers/md/dm-zoned-reclaim.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2020-05-19 11:14:21 +0300
committerMike Snitzer <snitzer@redhat.com>2020-05-21 00:09:50 +0300
commit90a9b8693f1b84a695864f2b416cba9bde107268 (patch)
tree3b024946f0aa53cfc4e1132ef2c9cd5cb9f58f31 /drivers/md/dm-zoned-reclaim.c
parent34f5affd04c4a16d9df19c369bcec6e873e57ffe (diff)
downloadlinux-90a9b8693f1b84a695864f2b416cba9bde107268.tar.xz
dm zoned: reclaim random zones when idle
When the system is idle we should be starting reclaiming random zones, too. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-zoned-reclaim.c')
-rw-r--r--drivers/md/dm-zoned-reclaim.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/md/dm-zoned-reclaim.c b/drivers/md/dm-zoned-reclaim.c
index d566dedcd8b8..bd62245d4556 100644
--- a/drivers/md/dm-zoned-reclaim.c
+++ b/drivers/md/dm-zoned-reclaim.c
@@ -284,7 +284,10 @@ static int dmz_reclaim_rnd_data(struct dmz_reclaim *zrc, struct dm_zone *dzone)
int alloc_flags = dmz_nr_cache_zones(zmd) ?
DMZ_ALLOC_RND : DMZ_ALLOC_SEQ;
- /* Get a free sequential zone */
+ /* Always use sequential zones to reclaim random zones */
+ if (dmz_is_rnd(dzone))
+ alloc_flags = DMZ_ALLOC_SEQ;
+ /* Get a free random or sequential zone */
dmz_lock_map(zmd);
szone = dmz_alloc_zone(zmd, alloc_flags | DMZ_ALLOC_RECLAIM);
dmz_unlock_map(zmd);
@@ -344,6 +347,14 @@ static void dmz_reclaim_empty(struct dmz_reclaim *zrc, struct dm_zone *dzone)
}
/*
+ * Test if the target device is idle.
+ */
+static inline int dmz_target_idle(struct dmz_reclaim *zrc)
+{
+ return time_is_before_jiffies(zrc->atime + DMZ_IDLE_PERIOD);
+}
+
+/*
* Find a candidate zone for reclaim and process it.
*/
static int dmz_do_reclaim(struct dmz_reclaim *zrc)
@@ -355,7 +366,7 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
int ret;
/* Get a data zone */
- dzone = dmz_get_zone_for_reclaim(zmd);
+ dzone = dmz_get_zone_for_reclaim(zmd, dmz_target_idle(zrc));
if (!dzone)
return -EBUSY;
@@ -418,14 +429,6 @@ out:
return 0;
}
-/*
- * Test if the target device is idle.
- */
-static inline int dmz_target_idle(struct dmz_reclaim *zrc)
-{
- return time_is_before_jiffies(zrc->atime + DMZ_IDLE_PERIOD);
-}
-
static unsigned int dmz_reclaim_percentage(struct dmz_reclaim *zrc)
{
struct dmz_metadata *zmd = zrc->metadata;
@@ -448,8 +451,13 @@ static unsigned int dmz_reclaim_percentage(struct dmz_reclaim *zrc)
*/
static bool dmz_should_reclaim(struct dmz_reclaim *zrc, unsigned int p_unmap)
{
+ unsigned int nr_reclaim = dmz_nr_rnd_zones(zrc->metadata);
+
+ if (dmz_nr_cache_zones(zrc->metadata))
+ nr_reclaim += dmz_nr_cache_zones(zrc->metadata);
+
/* Reclaim when idle */
- if (dmz_target_idle(zrc) && p_unmap < 100)
+ if (dmz_target_idle(zrc) && nr_reclaim)
return true;
/* If there are still plenty of cache zones, do not reclaim */