• ZiyangZhang's avatar
    ublk_drv: add START_USER_RECOVERY and END_USER_RECOVERY support · c732a852
    ZiyangZhang authored
    START_USER_RECOVERY and END_USER_RECOVERY are two new control commands
    to support user recovery feature.
    
    After a crash, user should send START_USER_RECOVERY, it will:
    (1) check if (a)current ublk_device is UBLK_S_DEV_QUIESCED which was
        set by quiesce_work and (b)chardev is released
    (2) reinit all ubqs, including:
        (a) put the task_struct and reset ->ubq_daemon to NULL.
        (b) reset all ublk_io.
    (3) reset ub->mm to NULL.
    
    Then, user should start a new process and send FETCH_REQ on each
    ubq_daemon.
    
    Finally, user should send END_USER_RECOVERY, it will:
    (1) wait for all new ubq_daemons getting ready.
    (2) update ublksrv_pid
    (3) unquiesce the request queue and expect incoming ublk_queue_rq()
    (4) convert ub's state to UBLK_S_DEV_LIVE
    
    Note: we can handle STOP_DEV between START_USER_RECOVERY and
    END_USER_RECOVERY. This is helpful to users who cannot start new process
    after sending START_USER_RECOVERY ctrl-cmd.
    Signed-off-by: default avatarZiyangZhang <ZiyangZhang@linux.alibaba.com>
    Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
    Link: https://lore.kernel.org/r/20220923153919.44078-7-ZiyangZhang@linux.alibaba.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    c732a852
ublk_drv.c 51.6 KB