• Andreas Gruenbacher's avatar
    gfs2: Fix lru_count accounting · 7a1ad9d8
    Andreas Gruenbacher authored
    Currently, gfs2_scan_glock_lru() decrements lru_count when a glock is
    moved onto the dispose list.  When such a glock is then stolen from the
    dispose list while gfs2_dispose_glock_lru() doesn't hold the lru_lock,
    lru_count will be decremented again, so the counter will eventually go
    negative.
    
    This bug has existed in one form or another since at least commit
    97cc1025 ("GFS2: Kill two daemons with one patch").
    
    Fix this by only decrementing lru_count when we actually remove a glock
    and schedule for it to be unlocked and dropped.  We also don't need to
    remove and then re-add glocks when we can just as well move them back
    onto the lru_list when necessary.
    
    In addition, return the number of glocks freed as we should, not the
    number of glocks moved onto the dispose list.
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    7a1ad9d8
glock.c 74.1 KB