summaryrefslogtreecommitdiff
path: root/fs/gfs2
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2022-12-10 04:14:04 +0300
committerAndreas Gruenbacher <agruenba@redhat.com>2023-02-01 00:40:24 +0300
commit8fb8f70ec71eb5ca51ecbfc2303523ff836648db (patch)
tree16f7c5fc276f5354328ed5d8bf9d1e74a283a883 /fs/gfs2
parent2d1439557ffeab3b9729f1c64fa86830070f9a04 (diff)
downloadlinux-8fb8f70ec71eb5ca51ecbfc2303523ff836648db.tar.xz
gfs2: Clean up gfs2_scan_glock_lru
Switch to list_for_each_entry_safe() and eliminate the "skipped" list in gfs2_scan_glock_lru(). At the same time, scan the requested number of items to scan, not one more than that number. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/glock.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 2868e979810a..05ef0ffa7ea6 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1985,26 +1985,21 @@ add_back_to_lru:
static long gfs2_scan_glock_lru(int nr)
{
- struct gfs2_glock *gl;
- LIST_HEAD(skipped);
+ struct gfs2_glock *gl, *next;
LIST_HEAD(dispose);
long freed = 0;
spin_lock(&lru_lock);
- while ((nr-- >= 0) && !list_empty(&lru_list)) {
- gl = list_first_entry(&lru_list, struct gfs2_glock, gl_lru);
-
+ list_for_each_entry_safe(gl, next, &lru_list, gl_lru) {
+ if (nr-- <= 0)
+ break;
/* Test for being demotable */
if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
list_move(&gl->gl_lru, &dispose);
atomic_dec(&lru_count);
freed++;
- continue;
}
-
- list_move(&gl->gl_lru, &skipped);
}
- list_splice(&skipped, &lru_list);
if (!list_empty(&dispose))
gfs2_dispose_glock_lru(&dispose);
spin_unlock(&lru_lock);