• Coly Li's avatar
    bcache: add failure check to run_cache_set() for journal replay · ce3e4cfb
    Coly Li authored
    Currently run_cache_set() has no return value, if there is failure in
    bch_journal_replay(), the caller of run_cache_set() has no idea about
    such failure and just continue to execute following code after
    run_cache_set().  The internal failure is triggered inside
    bch_journal_replay() and being handled in async way. This behavior is
    inefficient, while failure handling inside bch_journal_replay(), cache
    register code is still running to start the cache set. Registering and
    unregistering code running as same time may introduce some rare race
    condition, and make the code to be more hard to be understood.
    
    This patch adds return value to run_cache_set(), and returns -EIO if
    bch_journal_rreplay() fails. Then caller of run_cache_set() may detect
    such failure and stop registering code flow immedidately inside
    register_cache_set().
    
    If journal replay fails, run_cache_set() can report error immediately
    to register_cache_set(). This patch makes the failure handling for
    bch_journal_replay() be in synchronized way, easier to understand and
    debug, and avoid poetential race condition for register-and-unregister
    in same time.
    Signed-off-by: default avatarColy Li <colyli@suse.de>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    ce3e4cfb
super.c 61.5 KB