[patch 1/2] reiser4: adjust to new shrinker API

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

 




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

[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux