All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Shishkin <edward.shishkin@gmail.com>
To: ReiserFS Development mailing list <reiserfs-devel@vger.kernel.org>
Subject: [patch 1/2] reiser4: adjust to new shrinker API
Date: Fri, 20 Dec 2013 19:49:11 +0100	[thread overview]
Message-ID: <52B49127.5020706@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: reiser4-adjust-to-new-shrinker-api.patch --]
[-- Type: text/x-patch, Size: 2221 bytes --]

Patch from Mathieu Belanger with some improvements

Adjust to new shrinker API: introduce
d_cursor_shrink_count() as ->count_objects();  
d_cursor_shrink_scan() as ->scan_objects();

Signed-off-by: Edward Shishkin <edward.shishkin@gmail.com>
---
 fs/reiser4/fsdata.c |   44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

--- linux-3.12.5.orig/fs/reiser4/fsdata.c
+++ linux-3.12.5/fs/reiser4/fsdata.c
@@ -23,30 +23,27 @@ static int file_is_stateless(struct file
 static void free_fsdata(reiser4_file_fsdata *fsdata);
 static void kill_cursor(dir_cursor *);
 
-/**
- * d_cursor_shrink - shrink callback for cache of dir_cursor-s
- * @nr: number of objects to free
- * @mask: GFP mask
- *
- * Shrinks d_cursor_cache. Scan LRU list of unused cursors, freeing requested
- * number. Return number of still freeable cursors.
- */
-static int d_cursor_shrink(struct shrinker *shrink, struct shrink_control *sc)
+static unsigned long d_cursor_shrink_scan(struct shrinker *shrink,
+					  struct shrink_control *sc)
 {
-	if (sc->nr_to_scan != 0) {
-		dir_cursor *scan;
+	dir_cursor *scan;
+	unsigned long freed = 0;
 
-		spin_lock(&d_c_lock);
-		while (!list_empty(&cursor_cache)) {
-			scan = list_entry(cursor_cache.next, dir_cursor, alist);
-			assert("nikita-3567", scan->ref == 0);
-			kill_cursor(scan);
-			--sc->nr_to_scan;
-			if (sc->nr_to_scan == 0)
-				break;
-		}
-		spin_unlock(&d_c_lock);
+	spin_lock(&d_c_lock);
+	while (!list_empty(&cursor_cache) && sc->nr_to_scan) {
+		scan = list_entry(cursor_cache.next, dir_cursor, alist);
+		assert("nikita-3567", scan->ref == 0);
+		kill_cursor(scan);
+		freed++;
+		sc->nr_to_scan--;
 	}
+	spin_unlock(&d_c_lock);
+	return freed;
+}
+
+static unsigned long d_cursor_shrink_count (struct shrinker *shrink,
+					    struct shrink_control *sc)
+{
 	return d_cursor_unused;
 }
 
@@ -58,8 +55,9 @@ static int d_cursor_shrink(struct shrink
  * shrunk only if system is really tight on memory.
  */
 static struct shrinker d_cursor_shrinker = {
-	.shrink = d_cursor_shrink,
-	.seeks = DEFAULT_SEEKS << 3,
+	.count_objects = d_cursor_shrink_count,
+	.scan_objects = d_cursor_shrink_scan,
+	.seeks = DEFAULT_SEEKS << 3
 };
 
 /**

                 reply	other threads:[~2013-12-20 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52B49127.5020706@gmail.com \
    --to=edward.shishkin@gmail.com \
    --cc=reiserfs-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.