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>
This commit is contained in:
@ -1985,26 +1985,21 @@ add_back_to_lru:
|
|||||||
|
|
||||||
static long gfs2_scan_glock_lru(int nr)
|
static long gfs2_scan_glock_lru(int nr)
|
||||||
{
|
{
|
||||||
struct gfs2_glock *gl;
|
struct gfs2_glock *gl, *next;
|
||||||
LIST_HEAD(skipped);
|
|
||||||
LIST_HEAD(dispose);
|
LIST_HEAD(dispose);
|
||||||
long freed = 0;
|
long freed = 0;
|
||||||
|
|
||||||
spin_lock(&lru_lock);
|
spin_lock(&lru_lock);
|
||||||
while ((nr-- >= 0) && !list_empty(&lru_list)) {
|
list_for_each_entry_safe(gl, next, &lru_list, gl_lru) {
|
||||||
gl = list_first_entry(&lru_list, struct gfs2_glock, gl_lru);
|
if (nr-- <= 0)
|
||||||
|
break;
|
||||||
/* Test for being demotable */
|
/* Test for being demotable */
|
||||||
if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
|
if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
|
||||||
list_move(&gl->gl_lru, &dispose);
|
list_move(&gl->gl_lru, &dispose);
|
||||||
atomic_dec(&lru_count);
|
atomic_dec(&lru_count);
|
||||||
freed++;
|
freed++;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list_move(&gl->gl_lru, &skipped);
|
|
||||||
}
|
}
|
||||||
list_splice(&skipped, &lru_list);
|
|
||||||
if (!list_empty(&dispose))
|
if (!list_empty(&dispose))
|
||||||
gfs2_dispose_glock_lru(&dispose);
|
gfs2_dispose_glock_lru(&dispose);
|
||||||
spin_unlock(&lru_lock);
|
spin_unlock(&lru_lock);
|
||||||
|
Reference in New Issue
Block a user