diff options
author | Mike Snitzer <snitzer@redhat.com> | 2017-05-04 10:04:18 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-05-04 10:27:47 -0400 |
commit | 97dfb20309e0ad4fa22deb5bc5ed85604d5014ef (patch) | |
tree | 0c8cb574c9688322cb4bf061d648e2e43dde8b79 | |
parent | ce1d64e84dbea98d41deaf5db0fe91fd729ad2cd (diff) | |
download | linux-97dfb20309e0ad4fa22deb5bc5ed85604d5014ef.tar.bz2 |
dm cache policy smq: cleanup free_target_met() and clean_target_met()
Depending on the passed @idle arg, there may be no need to calculate
'nr_free' or 'nr_clean' respectively in free_target_met() and
clean_target_met().
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r-- | drivers/md/dm-cache-policy-smq.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c index d13d9edf8dfe..72479bd61e11 100644 --- a/drivers/md/dm-cache-policy-smq.c +++ b/drivers/md/dm-cache-policy-smq.c @@ -1120,28 +1120,30 @@ static bool clean_target_met(struct smq_policy *mq, bool idle) * Cache entries may not be populated. So we cannot rely on the * size of the clean queue. */ - unsigned nr_clean = from_cblock(mq->cache_size) - q_size(&mq->dirty); + unsigned nr_clean; - if (idle) + if (idle) { /* * We'd like to clean everything. */ return q_size(&mq->dirty) == 0u; - else - return (nr_clean + btracker_nr_writebacks_queued(mq->bg_work)) >= - percent_to_target(mq, CLEAN_TARGET); + } + + nr_clean = from_cblock(mq->cache_size) - q_size(&mq->dirty); + return (nr_clean + btracker_nr_writebacks_queued(mq->bg_work)) >= + percent_to_target(mq, CLEAN_TARGET); } static bool free_target_met(struct smq_policy *mq, bool idle) { - unsigned nr_free = from_cblock(mq->cache_size) - - mq->cache_alloc.nr_allocated; + unsigned nr_free; - if (idle) - return (nr_free + btracker_nr_demotions_queued(mq->bg_work)) >= - percent_to_target(mq, FREE_TARGET); - else + if (!idle) return true; + + nr_free = from_cblock(mq->cache_size) - mq->cache_alloc.nr_allocated; + return (nr_free + btracker_nr_demotions_queued(mq->bg_work)) >= + percent_to_target(mq, FREE_TARGET); } /*----------------------------------------------------------------*/ |