From: Ming Lei <ming.lei@redhat.com>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Uday Shankar <ushankar@purestorage.com>,
Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH V3 1/6] ublk: allow io buffer register/unregister command issued from other task contexts
Date: Tue, 13 May 2025 10:26:57 +0800 [thread overview]
Message-ID: <aCKt8ZLpZctP020J@fedora> (raw)
In-Reply-To: <CADUfDZqfEnOM1hmZJw7VTNUUu_zqf1fBcju_ZvDt9tNe3-KcHw@mail.gmail.com>
On Mon, May 12, 2025 at 10:39:57AM -0700, Caleb Sander Mateos wrote:
> On Fri, May 9, 2025 at 8:06 AM Ming Lei <ming.lei@redhat.com> wrote:
> >
> > `ublk_queue` is read only for io buffer register/unregister command. Both
> > `ublk_io` and block layer request are read-only for IO buffer register/
> > unregister command.
> >
> > So the two command can be issued from other task contexts.
>
> I mentioned this before in
> https://lore.kernel.org/linux-block/CADUfDZqZ_9O7vUAYtxrrujWqPBuP05nBhCbzNuNsc9kJTmX2sA@mail.gmail.com/
>
> But UBLK_IO_(UN)REGISTER_IO_BUF still reads io->flags. So it would be
> a race condition to handle it on a thread other than ubq_daemon, as
> ubq_daemon may concurrently modify io->flags. If you do want to
> support UBLK_IO_(UN)REGISTER_IO_BUF on other threads, the writes to
> io->flags should use WRITE_ONCE() and the reads on other threads
> should use READ_ONCE(). With those modifications, it should be safe
> because __ublk_check_and_get_req() atomically checks the state of the
> request and increments its reference count.
UBLK_IO_(UN)REGISTER_IO_BUF just reads the flag, if
UBLK_IO_FLAG_OWNED_BY_SRV is cleared, the OP is failed.
Otherwise, __ublk_check_and_get_req() covers everything because both
'ublk_io' and 'request' are pre-allocation. The only race is that new
recycled request buffer is registered, that is fine, because it can be
treated as logic bug.
So I think it isn't necessary to use READ_ONCE/WRITE_ONCE, or can you show
what the exact issue is?
Thanks,
Ming
next prev parent reply other threads:[~2025-05-13 2:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 15:06 [PATCH V3 0/6] ublk: support to register bvec buffer automatically Ming Lei
2025-05-09 15:06 ` [PATCH V3 1/6] ublk: allow io buffer register/unregister command issued from other task contexts Ming Lei
2025-05-12 17:39 ` Caleb Sander Mateos
2025-05-13 2:26 ` Ming Lei [this message]
2025-05-13 17:09 ` Caleb Sander Mateos
2025-05-12 20:25 ` Caleb Sander Mateos
2025-05-13 3:05 ` Ming Lei
2025-05-13 17:19 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 2/6] ublk: convert to refcount_t Ming Lei
2025-05-09 15:06 ` [PATCH V3 3/6] ublk: prepare for supporting to register request buffer automatically Ming Lei
2025-05-13 19:45 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 4/6] ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG Ming Lei
2025-05-13 19:50 ` Caleb Sander Mateos
2025-05-17 11:02 ` Ming Lei
2025-05-18 17:10 ` Caleb Sander Mateos
2025-05-19 4:49 ` Ming Lei
2025-05-19 15:20 ` Caleb Sander Mateos
2025-05-20 1:15 ` Ming Lei
2025-05-13 19:54 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 5/6] selftests: ublk: support UBLK_F_AUTO_BUF_REG Ming Lei
2025-05-09 15:06 ` [PATCH V3 6/6] selftests: ublk: add test for covering UBLK_AUTO_BUF_REG_FALLBACK 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=aCKt8ZLpZctP020J@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ushankar@purestorage.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.