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: [PATCH V5 6/7] ublk_drv: allow new process to open ublk chardev with recovery feature enabled
Date: Fri, 23 Sep 2022 10:03:32 +0800 [thread overview]
Message-ID: <caf0bfbf-18d2-e936-4bbd-3e728a567de5@linux.alibaba.com> (raw)
In-Reply-To: <20220922061734.21625-7-ZiyangZhang@linux.alibaba.com>
On 2022/9/22 14:17, ZiyangZhang wrote:
> With recovery feature enabled, if ublk chardev is ready to be released
> and quiesce_work has been scheduled, we:
> (1) reinit all ubqs, including:
> (a) put the task_struct and reset ->ubq_daemon to NULL.
> (b) reset all ublk_io.
> (2) reset ub->mm to NULL.
> Then ublk chardev is released and new process can open it.
>
> RECOVER_DEV is introduced as a new ctrl-cmd for recovery feature.
> After the chardev is opened and all ubqs are ready, user should send
> RECOVER_DEV to:
> (1) wait until 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
> (5) reschedule monitor_work
>
> Signed-off-by: ZiyangZhang <ZiyangZhang@linux.alibaba.com>
> ---
> drivers/block/ublk_drv.c | 67 +++++++++++++++++++++++++++++++++++
> include/uapi/linux/ublk_cmd.h | 1 +
> 2 files changed, 68 insertions(+)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 3977869d2bc4..ac8bf497567f 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -898,10 +898,40 @@ static int ublk_ch_open(struct inode *inode, struct file *filp)
> return 0;
> }
>
> +static void ublk_queue_reinit(struct ublk_device *ub, struct ublk_queue *ubq)
> +{
> + int i;
> +
> + /* old daemon is PF_EXITING, put it now */
> + if (ubq->ubq_daemon) {
> + put_task_struct(ubq->ubq_daemon);
> + /* We have to reset it to NULL, otherwise ub won't accept new FETCH_REQ */
> + ubq->ubq_daemon = NULL;
> + }
> +
> + for (i = 0; i < ubq->q_depth; i++) {
> + struct ublk_io *io = &ubq->ios[i];
> +
> + /* forget everything now and be ready for new FETCH_REQ */
> + io->flags = 0;
> + io->cmd = NULL;
> + io->addr = 0;
> + }
> + ubq->nr_io_ready = 0;
> +}
> +
> static int ublk_ch_release(struct inode *inode, struct file *filp)
> {
> struct ublk_device *ub = filp->private_data;
> + int i;
>
> + pr_devel("%s: reinit queues for dev id %d.\n", __func__, ub->dev_info.dev_id);
> + for (i = 0; i < ub->dev_info.nr_hw_queues; i++)
> + ublk_queue_reinit(ub, ublk_get_queue(ub, i));
> + /* set to NULL, otherwise new ubq_daemon cannot mmap the io_cmd_buf */
> + ub->mm = NULL;
> + ub->nr_queues_ready = 0;
> + init_completion(&ub->completion);
> clear_bit(UB_STATE_OPEN, &ub->state);
> return 0;
> }
This one is not correct. I will figure out how to correctly
put_task_struct(ubq->ubq_daemon) with recovery feature enabled.
next prev parent reply other threads:[~2022-09-23 2:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 6:17 [PATCH V5 0/7] ublk_drv: add USER_RECOVERY support ZiyangZhang
2022-09-22 6:17 ` [PATCH V5 1/7] ublk_drv: check 'current' instead of 'ubq_daemon' ZiyangZhang
2022-09-22 6:17 ` [PATCH V5 2/7] ublk_drv: define macros for recovery feature and check them ZiyangZhang
2022-09-23 3:01 ` Ming Lei
2022-09-22 6:17 ` [PATCH V5 3/7] ublk_drv: requeue rqs with recovery feature enabled ZiyangZhang
2022-09-23 3:07 ` Ming Lei
2022-09-22 6:17 ` [PATCH V5 4/7] ublk_drv: consider recovery feature in aborting mechanism ZiyangZhang
2022-09-22 6:17 ` [PATCH V5 5/7] ublk_drv: support UBLK_F_USER_RECOVERY_REISSUE ZiyangZhang
2022-09-22 6:17 ` [PATCH V5 6/7] ublk_drv: allow new process to open ublk chardev with recovery feature enabled ZiyangZhang
2022-09-23 2:03 ` Ziyang Zhang [this message]
2022-09-22 6:17 ` [PATCH V5 7/7] Documentation: document ublk user recovery feature ZiyangZhang
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=caf0bfbf-18d2-e936-4bbd-3e728a567de5@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