[RFC PATCH 4/7] bcache: add __bch_mca_scan() with parameter "bool reap_flush"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch renames original bch_mca_scan() to __bch_mca_scan() and add
the third parameter "bool reap_flush". The parameter reap_flush is used
when calling mca_reap() inside __bch_mca_scan() to indicate weather
mca_reap() should flush or skip dirty btree node cache.

bch_mca_scan() still exists but it changes to a wrapper of,
	{return __bch_mca_scan(shrink, sc, false);}

bch_mca_scan() won't reap dirty btree node cache, by this change, it is
possible to reap and shrink dirty btree node cache when calling
__bch_mca_scan() with reap_flush set to true.

This is necessary for following changes which control memory consumption
of bcache btree node cache by throttling regular I/O requests.

Signed-off-by: Coly Li <colyli@xxxxxxx>
---
 drivers/md/bcache/btree.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index fa872df4e770..b37405aedf6e 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -699,8 +699,9 @@ static int mca_reap(struct btree *b, unsigned int min_order, bool flush)
 	return -ENOMEM;
 }
 
-static unsigned long bch_mca_scan(struct shrinker *shrink,
-				  struct shrink_control *sc)
+static unsigned long __bch_mca_scan(struct shrinker *shrink,
+				    struct shrink_control *sc,
+				    bool reap_flush)
 {
 	struct cache_set *c = container_of(shrink, struct cache_set, shrink);
 	struct btree *b, *t;
@@ -738,7 +739,7 @@ static unsigned long bch_mca_scan(struct shrinker *shrink,
 		if (nr <= 0)
 			goto out;
 
-		if (!mca_reap(b, 0, false)) {
+		if (!mca_reap(b, 0, reap_flush)) {
 			mca_data_free(b);
 			rw_unlock(true, b);
 			freed++;
@@ -751,7 +752,7 @@ static unsigned long bch_mca_scan(struct shrinker *shrink,
 		if (nr <= 0 || i >= btree_cache_used)
 			goto out;
 
-		if (!mca_reap(b, 0, false)) {
+		if (!mca_reap(b, 0, reap_flush)) {
 			mca_bucket_free(b);
 			mca_data_free(b);
 			rw_unlock(true, b);
@@ -766,6 +767,12 @@ static unsigned long bch_mca_scan(struct shrinker *shrink,
 	return freed * c->btree_pages;
 }
 
+static unsigned long bch_mca_scan(struct shrinker *shrink,
+				  struct shrink_control *sc)
+{
+	return __bch_mca_scan(shrink, sc, false);
+}
+
 static unsigned long bch_mca_count(struct shrinker *shrink,
 				   struct shrink_control *sc)
 {
-- 
2.16.4




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux