From: Ming Lei <ming.lei@redhat.com>
To: Yoav Cohen <yoav@nvidia.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"axboe@kernel.dk" <axboe@kernel.dk>
Subject: Re: ublk: Graceful Upgrade of ublk server application
Date: Tue, 15 Apr 2025 19:06:03 +0800 [thread overview]
Message-ID: <Z_49m8awtNFsY8pl@fedora> (raw)
In-Reply-To: <DM4PR12MB63282BE4C94D28AA2E1CACA0A9B22@DM4PR12MB6328.namprd12.prod.outlook.com>
On Tue, Apr 15, 2025 at 08:15:08AM +0000, Yoav Cohen wrote:
> I am seeking advice on whether it is possible to upgrade the ublksrv version without terminating the daemon abruptly. Specifically, I would like the daemon to exit gracefully, ensuring all necessary cleanups are performed.
> In my current implementation, I attempted to cancel all ublk uring SQEs (specifically the COMMIT_AND_FETCH_REQ/FETCH_REQ operations) using the following approach:
> io_uring_prep_cancel_fd(sqe, cdev_fd, IORING_ASYNC_CANCEL_ALL);io_uring_prep_cancel_fd(sqe, cdev_fd, IORING_ASYNC_CANCEL_ALL);
That shouldn't work because COMMIT_AND_FETCH_REQ/FETCH_REQ has been
issued to ublk driver already.
> However, this method does not seem to be effective. In my scenario, I have a single io_uring instance that serves multiple devices and other producers, so simply stopping the polling of CQEs is not a viable solution due to potential race conditions.
> Could you please provide any suggestions or guidance on how to achieve a graceful upgrade of the ublksrv version without causing disruptions?
>
You can delete all ublk devices handled by this single io_ring instance
first by sending UBLK_CMD_DEL_DEV, then exit ublk server loop if there
isn't any pending uring_cmd & target IO. And the ublk server need to stop
to issue COMMIT_AND_FETCH_REQ after getting uring_cmd with UBLK_IO_RES_ABORT.
I guess you want to send the control command in single pthread too?
If yes, it still can work with coroutine or modern language's .async/await.
This feature is actually in my todo list for libublk-rs, just not started
because of not seeing real requirement.
Thanks,
Ming
next prev parent reply other threads:[~2025-04-15 11:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 8:15 ublk: Graceful Upgrade of ublk server application Yoav Cohen
2025-04-15 11:06 ` Ming Lei [this message]
2025-04-15 19:46 ` Yoav Cohen
2025-04-16 0:51 ` Uday Shankar
2025-04-16 1:39 ` Ming Lei
2025-04-16 8:16 ` Yoav Cohen
2025-04-16 9:12 ` Ming Lei
2025-04-20 8:57 ` Yoav Cohen
2025-04-21 2:43 ` 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=Z_49m8awtNFsY8pl@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=yoav@nvidia.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;
as well as URLs for NNTP newsgroup(s).