From: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
To: ming.lei@redhat.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH V5 6/7] ublk_drv: add START_USER_RECOVERY and END_USER_RECOVERY support
Date: Fri, 23 Sep 2022 14:34:29 +0800 [thread overview]
Message-ID: <882f5629-a6e2-5fcc-7d26-b3de77ca2985@linux.alibaba.com> (raw)
In-Reply-To: <20220923061505.52007-7-ZiyangZhang@linux.alibaba.com>
On 2022/9/23 14:15, ZiyangZhang wrote:
> 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: ZiyangZhang <ZiyangZhang@linux.alibaba.com>
Let me explain why we still need two ctrl-cmds: START_USER_RECOVERY
and END_USER_RECOVERY:
(1) They are easy to use and understand. Just like calling
a)ADD_DEV, b)start daemon c)START_DEV, we can recover a device by
a)START_USER_RECOVERY b)start new daemon c)END_USER_RECOVERY.
IMO, START_USER_RECOVERY can guide user whether to start a new daemon.
Without it, user must directly start a new daemon. He may fail here
because /dev/ublkc* is not released. So a retry is necessary here.
But I think that let the user retry by sending START_USER_RECOVERY
instead of opening /dev/ublkc* is more reasonable.
(2) Handling put_task_struct(ubq_daemon) is hard in ublk_ch_release().
Assume all ioucmds have been issued back to userspace and a crash happens,
ublk_ch_release() can be called immediately here and ubq_daemon is
freed. But monoitor_work may be running now. Dealing with UAF on
ubq_daemon in monitor_work may be difficult. But handling
put_task_struct(ubq_daemon) in START_USER_RECOVERY solves the problem
because monitor_work is sure to be canceled. Besides, here is no race
with ublk_deinit_queue() since it cannot be called if ub's state is
QUIESCED.
Regards,
Zhang
next prev parent reply other threads:[~2022-09-23 6:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 6:14 [RESEND PATCH V5 0/7] ublk_drv: add USER_RECOVERY support ZiyangZhang
2022-09-23 6:14 ` [RESEND PATCH V5 1/7] ublk_drv: check 'current' instead of 'ubq_daemon' ZiyangZhang
2022-09-23 6:15 ` [RESEND PATCH V5 2/7] ublk_drv: define macros for recovery feature and check them ZiyangZhang
2022-09-23 6:15 ` [RESEND PATCH V5 3/7] ublk_drv: requeue rqs with recovery feature enabled ZiyangZhang
2022-09-23 13:47 ` Ming Lei
2022-09-23 6:15 ` [RESEND PATCH V5 4/7] ublk_drv: consider recovery feature in aborting mechanism ZiyangZhang
2022-09-23 13:48 ` Ming Lei
2022-09-23 6:15 ` [RESEND PATCH V5 5/7] ublk_drv: support UBLK_F_USER_RECOVERY_REISSUE ZiyangZhang
2022-09-23 6:15 ` [RESEND PATCH V5 6/7] ublk_drv: add START_USER_RECOVERY and END_USER_RECOVERY support ZiyangZhang
2022-09-23 6:34 ` Ziyang Zhang [this message]
2022-09-23 13:50 ` Ming Lei
2022-09-23 6:15 ` [RESEND PATCH V5 7/7] Documentation: document ublk user recovery feature ZiyangZhang
2022-09-23 13:58 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=882f5629-a6e2-5fcc-7d26-b3de77ca2985@linux.alibaba.com \
--to=ziyangzhang@linux.alibaba.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox