* [PATCH] nvme-loop: set blocking flag
@ 2024-10-17 17:20 Keith Busch
2024-10-17 17:36 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Keith Busch @ 2024-10-17 17:20 UTC (permalink / raw)
To: linux-nvme; +Cc: sagi, hch, Keith Busch, Shinichiro Kawasaki
From: Keith Busch <kbusch@kernel.org>
Commit 505363957fad ("nvmet: fix nvme status code when namespace is
disabled") introduced a mutex lock in the io path for target. The loop
target connects this to the blk-mq submission side, so it requires the
blocking flag set so that queue_rq doesn't happen inside an rcu context.
Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/target/loop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index e32790d8fc260..77dd809fe4507 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -479,7 +479,7 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
static const struct nvme_ctrl_ops nvme_loop_ctrl_ops = {
.name = "loop",
.module = THIS_MODULE,
- .flags = NVME_F_FABRICS,
+ .flags = NVME_F_FABRICS | NVME_F_BLOCKING,
.reg_read32 = nvmf_reg_read32,
.reg_read64 = nvmf_reg_read64,
.reg_write32 = nvmf_reg_write32,
--
2.43.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 17:20 [PATCH] nvme-loop: set blocking flag Keith Busch
@ 2024-10-17 17:36 ` Bart Van Assche
2024-10-17 17:39 ` Jens Axboe
2024-10-18 4:19 ` Shinichiro Kawasaki
2 siblings, 0 replies; 14+ messages in thread
From: Bart Van Assche @ 2024-10-17 17:36 UTC (permalink / raw)
To: Keith Busch, linux-nvme; +Cc: sagi, hch, Keith Busch, Shinichiro Kawasaki
On 10/17/24 10:20 AM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> Commit 505363957fad ("nvmet: fix nvme status code when namespace is
> disabled") introduced a mutex lock in the io path for target. The loop
> target connects this to the blk-mq submission side, so it requires the
> blocking flag set so that queue_rq doesn't happen inside an rcu context.
>
> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> drivers/nvme/target/loop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
> index e32790d8fc260..77dd809fe4507 100644
> --- a/drivers/nvme/target/loop.c
> +++ b/drivers/nvme/target/loop.c
> @@ -479,7 +479,7 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work)
> static const struct nvme_ctrl_ops nvme_loop_ctrl_ops = {
> .name = "loop",
> .module = THIS_MODULE,
> - .flags = NVME_F_FABRICS,
> + .flags = NVME_F_FABRICS | NVME_F_BLOCKING,
> .reg_read32 = nvmf_reg_read32,
> .reg_read64 = nvmf_reg_read64,
> .reg_write32 = nvmf_reg_write32,
Shouldn't this patch have Fixes: and Cc: stable tags?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 17:20 [PATCH] nvme-loop: set blocking flag Keith Busch
2024-10-17 17:36 ` Bart Van Assche
@ 2024-10-17 17:39 ` Jens Axboe
2024-10-17 18:04 ` Keith Busch
2024-10-18 5:10 ` Christoph Hellwig
2024-10-18 4:19 ` Shinichiro Kawasaki
2 siblings, 2 replies; 14+ messages in thread
From: Jens Axboe @ 2024-10-17 17:39 UTC (permalink / raw)
To: Keith Busch, linux-nvme; +Cc: sagi, hch, Keith Busch, Shinichiro Kawasaki
On 10/17/24 11:20 AM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> Commit 505363957fad ("nvmet: fix nvme status code when namespace is
> disabled") introduced a mutex lock in the io path for target. The loop
> target connects this to the blk-mq submission side, so it requires the
> blocking flag set so that queue_rq doesn't happen inside an rcu context.
Looks fine to me, but might be worth looking at doing that a bit
differently so that the target loop driver can remain non-blocking
as it should be considerably more efficient.
--
Jens Axboe
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 17:39 ` Jens Axboe
@ 2024-10-17 18:04 ` Keith Busch
2024-10-18 5:10 ` Christoph Hellwig
2024-10-18 5:10 ` Christoph Hellwig
1 sibling, 1 reply; 14+ messages in thread
From: Keith Busch @ 2024-10-17 18:04 UTC (permalink / raw)
To: Jens Axboe; +Cc: Keith Busch, linux-nvme, sagi, hch, Shinichiro Kawasaki
On Thu, Oct 17, 2024 at 11:39:24AM -0600, Jens Axboe wrote:
> On 10/17/24 11:20 AM, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> >
> > Commit 505363957fad ("nvmet: fix nvme status code when namespace is
> > disabled") introduced a mutex lock in the io path for target. The loop
> > target connects this to the blk-mq submission side, so it requires the
> > blocking flag set so that queue_rq doesn't happen inside an rcu context.
>
> Looks fine to me, but might be worth looking at doing that a bit
> differently so that the target loop driver can remain non-blocking
> as it should be considerably more efficient.
That's what I first looked at, but it's too hard. Maybe if we can make a
lookup that doesn't rely on searching the configfs group, but it's
definitely not this nice one-liner patch. :)
No rush on this today. I'll think more on it.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 17:20 [PATCH] nvme-loop: set blocking flag Keith Busch
2024-10-17 17:36 ` Bart Van Assche
2024-10-17 17:39 ` Jens Axboe
@ 2024-10-18 4:19 ` Shinichiro Kawasaki
2 siblings, 0 replies; 14+ messages in thread
From: Shinichiro Kawasaki @ 2024-10-18 4:19 UTC (permalink / raw)
To: Keith Busch
Cc: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch,
Keith Busch
On Oct 17, 2024 / 10:20, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> Commit 505363957fad ("nvmet: fix nvme status code when namespace is
> disabled") introduced a mutex lock in the io path for target. The loop
> target connects this to the blk-mq submission side, so it requires the
> blocking flag set so that queue_rq doesn't happen inside an rcu context.
>
> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
Thank you Keith for this quick action. I confirmed the patch avoids the BUG.
I also ran whole blktests and observed no regression. In case this patch gets
applied as it is,
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 17:39 ` Jens Axboe
2024-10-17 18:04 ` Keith Busch
@ 2024-10-18 5:10 ` Christoph Hellwig
1 sibling, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2024-10-18 5:10 UTC (permalink / raw)
To: Jens Axboe
Cc: Keith Busch, linux-nvme, sagi, hch, Keith Busch,
Shinichiro Kawasaki
On Thu, Oct 17, 2024 at 11:39:24AM -0600, Jens Axboe wrote:
> On 10/17/24 11:20 AM, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> >
> > Commit 505363957fad ("nvmet: fix nvme status code when namespace is
> > disabled") introduced a mutex lock in the io path for target. The loop
> > target connects this to the blk-mq submission side, so it requires the
> > blocking flag set so that queue_rq doesn't happen inside an rcu context.
>
> Looks fine to me, but might be worth looking at doing that a bit
> differently so that the target loop driver can remain non-blocking
> as it should be considerably more efficient.
Yes. When designing the nvmet code back in the day (gosh do I feel old)
we tried to avoid blocking in the main handling thread in general.
So if we can get rid of the mutex that would be great.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-17 18:04 ` Keith Busch
@ 2024-10-18 5:10 ` Christoph Hellwig
2024-10-20 21:35 ` Sagi Grimberg
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2024-10-18 5:10 UTC (permalink / raw)
To: Keith Busch
Cc: Jens Axboe, Keith Busch, linux-nvme, sagi, hch,
Shinichiro Kawasaki
On Thu, Oct 17, 2024 at 12:04:21PM -0600, Keith Busch wrote:
> > Looks fine to me, but might be worth looking at doing that a bit
> > differently so that the target loop driver can remain non-blocking
> > as it should be considerably more efficient.
>
> That's what I first looked at, but it's too hard. Maybe if we can make a
> lookup that doesn't rely on searching the configfs group, but it's
> definitely not this nice one-liner patch. :)
Searching configfs in the I/O path sounds like a train wreck no matter
what. I feel a bit bad for not noticing that earlier.
Let me see what I can do.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-18 5:10 ` Christoph Hellwig
@ 2024-10-20 21:35 ` Sagi Grimberg
2024-10-22 6:28 ` Christoph Hellwig
0 siblings, 1 reply; 14+ messages in thread
From: Sagi Grimberg @ 2024-10-20 21:35 UTC (permalink / raw)
To: Christoph Hellwig, Keith Busch
Cc: Jens Axboe, Keith Busch, linux-nvme, Shinichiro Kawasaki
On 18/10/2024 8:10, Christoph Hellwig wrote:
> On Thu, Oct 17, 2024 at 12:04:21PM -0600, Keith Busch wrote:
>>> Looks fine to me, but might be worth looking at doing that a bit
>>> differently so that the target loop driver can remain non-blocking
>>> as it should be considerably more efficient.
>> That's what I first looked at, but it's too hard. Maybe if we can make a
>> lookup that doesn't rely on searching the configfs group, but it's
>> definitely not this nice one-liner patch. :)
> Searching configfs in the I/O path sounds like a train wreck no matter
> what. I feel a bit bad for not noticing that earlier.
>
> Let me see what I can do.
Note, the search is ONLY in the error case, i.e. when nsid is not found in
subsys->namespaces.
I agree its a shame to make the loop driver blocking for this niche case.
Note that this doesn't do anything, because it is really designed to
make the
host failover work correctly (i.e. not fail IO) when nvmet disabled the
ns in
one server, and the namespace is available in the same nvmet subsystem
on another server.
We could escape this entirely for loop transport because it there are no
multi-server nvmet
subsystems for loop? There is a weird case where one can use mpath
device where one
path is loop and another is tcp/rdma... Which is very weird but maybe
possible with nvmet.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-20 21:35 ` Sagi Grimberg
@ 2024-10-22 6:28 ` Christoph Hellwig
2024-10-22 7:02 ` Christoph Hellwig
2024-10-22 9:25 ` Sagi Grimberg
0 siblings, 2 replies; 14+ messages in thread
From: Christoph Hellwig @ 2024-10-22 6:28 UTC (permalink / raw)
To: Sagi Grimberg
Cc: Christoph Hellwig, Keith Busch, Jens Axboe, Keith Busch,
linux-nvme, Shinichiro Kawasaki
On Mon, Oct 21, 2024 at 12:35:17AM +0300, Sagi Grimberg wrote:
>> Let me see what I can do.
>
> Note, the search is ONLY in the error case, i.e. when nsid is not found in
> subsys->namespaces.
Which kinda makes it worse as we use an unusual context just from
that rare error path.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-22 6:28 ` Christoph Hellwig
@ 2024-10-22 7:02 ` Christoph Hellwig
2024-10-22 8:08 ` Shinichiro Kawasaki
2024-10-22 9:26 ` Sagi Grimberg
2024-10-22 9:25 ` Sagi Grimberg
1 sibling, 2 replies; 14+ messages in thread
From: Christoph Hellwig @ 2024-10-22 7:02 UTC (permalink / raw)
To: Sagi Grimberg
Cc: Christoph Hellwig, Keith Busch, Jens Axboe, Keith Busch,
linux-nvme, Shinichiro Kawasaki
On Tue, Oct 22, 2024 at 08:28:10AM +0200, Christoph Hellwig wrote:
> On Mon, Oct 21, 2024 at 12:35:17AM +0300, Sagi Grimberg wrote:
> >> Let me see what I can do.
> >
> > Note, the search is ONLY in the error case, i.e. when nsid is not found in
> > subsys->namespaces.
>
> Which kinda makes it worse as we use an unusual context just from
> that rare error path.
I just took a very quick look, and inserting the namespace into the
xarray when created and only removing it when it is deleted, and
instead checking an enabled flag during lookup should do the work.
Do we have a good test case for commit 505363957fad ?
>
---end quoted text---
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-22 7:02 ` Christoph Hellwig
@ 2024-10-22 8:08 ` Shinichiro Kawasaki
2024-10-23 5:20 ` hch
2024-10-22 9:26 ` Sagi Grimberg
1 sibling, 1 reply; 14+ messages in thread
From: Shinichiro Kawasaki @ 2024-10-22 8:08 UTC (permalink / raw)
To: hch
Cc: Sagi Grimberg, Keith Busch, Jens Axboe, Keith Busch,
linux-nvme@lists.infradead.org
On Oct 22, 2024 / 09:02, Christoph Hellwig wrote:
> On Tue, Oct 22, 2024 at 08:28:10AM +0200, Christoph Hellwig wrote:
> > On Mon, Oct 21, 2024 at 12:35:17AM +0300, Sagi Grimberg wrote:
> > >> Let me see what I can do.
> > >
> > > Note, the search is ONLY in the error case, i.e. when nsid is not found in
> > > subsys->namespaces.
> >
> > Which kinda makes it worse as we use an unusual context just from
> > that rare error path.
>
> I just took a very quick look, and inserting the namespace into the
> xarray when created and only removing it when it is deleted, and
> instead checking an enabled flag during lookup should do the work.
>
> Do we have a good test case for commit 505363957fad ?
As for the BUG caused by the commit 505363957fad, the blktests test case
nvme/052 can confirm if any patch fixes the BUG or not. It is recreate in
stable manner on my test node [1], so I'm happy to help testing.
If you mean a test case to confirm that the commit 505363957fad achieves its
purpose, I'm not sure about it. According to its commit log, I guess Jirong
might have a test environment.
[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-22 6:28 ` Christoph Hellwig
2024-10-22 7:02 ` Christoph Hellwig
@ 2024-10-22 9:25 ` Sagi Grimberg
1 sibling, 0 replies; 14+ messages in thread
From: Sagi Grimberg @ 2024-10-22 9:25 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Keith Busch, Jens Axboe, Keith Busch, linux-nvme,
Shinichiro Kawasaki
On 22/10/2024 9:28, Christoph Hellwig wrote:
> On Mon, Oct 21, 2024 at 12:35:17AM +0300, Sagi Grimberg wrote:
>>> Let me see what I can do.
>> Note, the search is ONLY in the error case, i.e. when nsid is not found in
>> subsys->namespaces.
> Which kinda makes it worse as we use an unusual context just from
> that rare error path.
>
I'd say that introducing this search in the hot path not only for error
cases
would be worse :)
Yes, nvme-loop was an oversight.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-22 7:02 ` Christoph Hellwig
2024-10-22 8:08 ` Shinichiro Kawasaki
@ 2024-10-22 9:26 ` Sagi Grimberg
1 sibling, 0 replies; 14+ messages in thread
From: Sagi Grimberg @ 2024-10-22 9:26 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Keith Busch, Jens Axboe, Keith Busch, linux-nvme,
Shinichiro Kawasaki
On 22/10/2024 10:02, Christoph Hellwig wrote:
> On Tue, Oct 22, 2024 at 08:28:10AM +0200, Christoph Hellwig wrote:
>> On Mon, Oct 21, 2024 at 12:35:17AM +0300, Sagi Grimberg wrote:
>>>> Let me see what I can do.
>>> Note, the search is ONLY in the error case, i.e. when nsid is not found in
>>> subsys->namespaces.
>> Which kinda makes it worse as we use an unusual context just from
>> that rare error path.
> I just took a very quick look, and inserting the namespace into the
> xarray when created and only removing it when it is deleted, and
> instead checking an enabled flag during lookup should do the work.
Agreed.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] nvme-loop: set blocking flag
2024-10-22 8:08 ` Shinichiro Kawasaki
@ 2024-10-23 5:20 ` hch
0 siblings, 0 replies; 14+ messages in thread
From: hch @ 2024-10-23 5:20 UTC (permalink / raw)
To: Shinichiro Kawasaki
Cc: hch, Sagi Grimberg, Keith Busch, Jens Axboe, Keith Busch,
linux-nvme@lists.infradead.org, Jirong Feng
On Tue, Oct 22, 2024 at 08:08:31AM +0000, Shinichiro Kawasaki wrote:
> As for the BUG caused by the commit 505363957fad, the blktests test case
> nvme/052 can confirm if any patch fixes the BUG or not. It is recreate in
> stable manner on my test node [1], so I'm happy to help testing.
>
> If you mean a test case to confirm that the commit 505363957fad achieves its
> purpose, I'm not sure about it. According to its commit log, I guess Jirong
> might have a test environment.
Yes, that's the main thing I want to be able to test.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-10-23 5:20 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 17:20 [PATCH] nvme-loop: set blocking flag Keith Busch
2024-10-17 17:36 ` Bart Van Assche
2024-10-17 17:39 ` Jens Axboe
2024-10-17 18:04 ` Keith Busch
2024-10-18 5:10 ` Christoph Hellwig
2024-10-20 21:35 ` Sagi Grimberg
2024-10-22 6:28 ` Christoph Hellwig
2024-10-22 7:02 ` Christoph Hellwig
2024-10-22 8:08 ` Shinichiro Kawasaki
2024-10-23 5:20 ` hch
2024-10-22 9:26 ` Sagi Grimberg
2024-10-22 9:25 ` Sagi Grimberg
2024-10-18 5:10 ` Christoph Hellwig
2024-10-18 4:19 ` Shinichiro Kawasaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox