Skip to content
  • Emanuele Giuseppe Esposito's avatar
    6f592e5a
    job.c: enable job lock/unlock and remove Aiocontext locks · 6f592e5a
    Emanuele Giuseppe Esposito authored
    
    
    Change the job_{lock/unlock} and macros to use job_mutex.
    
    Now that they are not nop anymore, remove the aiocontext
    to avoid deadlocks.
    
    Therefore:
    - when possible, remove completely the aiocontext lock/unlock pair
    - if it is used by some other function too, reduce the locking
      section as much as possible, leaving the job API outside.
    - change AIO_WAIT_WHILE in AIO_WAIT_WHILE_UNLOCKED, since we
      are not using the aiocontext lock anymore
    
    The only functions that still need the aiocontext lock are:
    - the JobDriver callbacks, already documented in job.h
    - job_cancel_sync() in replication.c is called with aio_context_lock
      taken, but now job is using AIO_WAIT_WHILE_UNLOCKED so we need to
      release the lock.
    
    Reduce the locking section to only cover the callback invocation
    and document the functions that take the AioContext lock,
    to avoid taking it twice.
    
    Also remove real_job_{lock/unlock}, as they are replaced by the
    public functions.
    
    Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20220926093214.506243-19-eesposit@redhat.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    6f592e5a
    job.c: enable job lock/unlock and remove Aiocontext locks
    Emanuele Giuseppe Esposito authored
    
    
    Change the job_{lock/unlock} and macros to use job_mutex.
    
    Now that they are not nop anymore, remove the aiocontext
    to avoid deadlocks.
    
    Therefore:
    - when possible, remove completely the aiocontext lock/unlock pair
    - if it is used by some other function too, reduce the locking
      section as much as possible, leaving the job API outside.
    - change AIO_WAIT_WHILE in AIO_WAIT_WHILE_UNLOCKED, since we
      are not using the aiocontext lock anymore
    
    The only functions that still need the aiocontext lock are:
    - the JobDriver callbacks, already documented in job.h
    - job_cancel_sync() in replication.c is called with aio_context_lock
      taken, but now job is using AIO_WAIT_WHILE_UNLOCKED so we need to
      release the lock.
    
    Reduce the locking section to only cover the callback invocation
    and document the functions that take the AioContext lock,
    to avoid taking it twice.
    
    Also remove real_job_{lock/unlock}, as they are replaced by the
    public functions.
    
    Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20220926093214.506243-19-eesposit@redhat.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading