Skip to content

Commit 6286248

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: fix glock shrinker ref issues
Before this patch, function gfs2_scan_glock_lru would only try to free glocks that had a reference count of 0. But if the reference count ever got to 0, the glock should have already been freed. Shrinker function gfs2_dispose_glock_lru checks whether glocks on the LRU are demote_ok, and if so, tries to demote them. But that's only possible if the reference count is at least 1. This patch changes gfs2_scan_glock_lru so it will try to demote and/or dispose of glocks that have a reference count of 1 and which are either demotable, or are already unlocked. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 52954b7 commit 6286248

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/gfs2/glock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,9 @@ static long gfs2_scan_glock_lru(int nr)
20102010
if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
20112011
if (!spin_trylock(&gl->gl_lockref.lock))
20122012
continue;
2013-
if (!gl->gl_lockref.count) {
2013+
if (gl->gl_lockref.count <= 1 &&
2014+
(gl->gl_state == LM_ST_UNLOCKED ||
2015+
demote_ok(gl))) {
20142016
list_move(&gl->gl_lru, &dispose);
20152017
atomic_dec(&lru_count);
20162018
freed++;

0 commit comments

Comments
 (0)