• Bob Peterson's avatar
    gfs2: Use TRY lock in gfs2_inode_lookup for UNLINKED inodes · c412a97c
    Bob Peterson authored
    Before this patch, delete_work_func() would check for the GLF_DEMOTE
    flag on the iopen glock and if set, it would perform special processing.
    However, there was a race whereby the GLF_DEMOTE flag could be set by
    another process after the check. Then when it called
    gfs2_lookup_by_inum() which calls gfs2_inode_lookup(), it tried to lock
    the iopen glock in SH mode, but the GLF_DEMOTE flag prevented the
    request from being granted. But the iopen glock could never be demoted
    because that happens when the inode is evicted, and the evict was never
    completed because of the failed lookup.
    
    To fix that, change function gfs2_inode_lookup() so that when
    GFS2_BLKST_UNLINKED inodes are searched, it uses the LM_FLAG_TRY flag
    for the iopen glock.  If the locking request fails, fail
    gfs2_inode_lookup() with -EAGAIN so that delete_work_func() can retry
    the operation later.
    Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    c412a97c
inode.c 51.6 KB