• Andreas Gruenbacher's avatar
    gfs2: Fix withdraw race · e3da6be3
    Andreas Gruenbacher authored
    Function gfs2_withdraw() tries to synchronize concurrent callers by
    atomically setting the SDF_WITHDRAWN flag in the first caller, setting
    the SDF_WITHDRAW_IN_PROG flag to indicate that a withdraw is in
    progress, performing the actual withdraw, and clearing the
    SDF_WITHDRAW_IN_PROG flag when done.  All other callers wait for the
    SDF_WITHDRAW_IN_PROG flag to be cleared before returning.
    
    This leaves a small window in which callers can find the SDF_WITHDRAWN
    flag set before the SDF_WITHDRAW_IN_PROG flag has been set, causing them
    to return prematurely, before the withdraw has been completed.
    
    Fix that by setting the SDF_WITHDRAWN and SDF_WITHDRAW_IN_PROG flags
    atomically.
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    e3da6be3
util.c 15.5 KB