reiserfs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] reiser4: adjust to new shrinker API
@ 2013-12-20 18:49 Edward Shishkin
  0 siblings, 0 replies; only message in thread
From: Edward Shishkin @ 2013-12-20 18:49 UTC (permalink / raw)
  To: ReiserFS Development mailing list

[-- 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
 };
 
 /**

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-20 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20 18:49 [patch 1/2] reiser4: adjust to new shrinker API Edward Shishkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).