dm bufio: when done scanning return from __scan immediately
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 1 Oct 2014 17:29:48 +0000 (13:29 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Nov 2014 16:59:51 +0000 (08:59 -0800)
commit 0e825862f3c04cee40e25f55680333728a4ffa9b upstream.

When __scan frees the required number of buffer entries that the
shrinker requested (nr_to_scan becomes zero) it must return.  Before
this fix the __scan code exited only the inner loop and continued in the
outer loop -- which could result in reduced performance due to extra
buffers being freed (e.g. unnecessarily evicted thinp metadata needing
to be synchronously re-read into bufio's cache).

Also, move dm_bufio_cond_resched to __scan's inner loop, so that
iterating the bufio client's lru lists doesn't result in scheduling
latency.

Reported-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-bufio.c

index 148c6f5..ca1621b 100644 (file)
@@ -1486,9 +1486,9 @@ static long __scan(struct dm_bufio_client *c, unsigned long nr_to_scan,
                list_for_each_entry_safe_reverse(b, tmp, &c->lru[l], lru_list) {
                        freed += __cleanup_old_buffer(b, gfp_mask, 0);
                        if (!--nr_to_scan)
-                               break;
+                               return freed;
+                       dm_bufio_cond_resched();
                }
-               dm_bufio_cond_resched();
        }
        return freed;
 }