* [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()'
@ 2020-08-21 7:58 Christophe JAILLET
2020-08-24 20:00 ` Sagi Grimberg
2020-08-25 7:10 ` Christoph Hellwig
0 siblings, 2 replies; 5+ messages in thread
From: Christophe JAILLET @ 2020-08-21 7:58 UTC (permalink / raw)
To: james.smart, hch, sagi, chaitanya.kulkarni
Cc: Christophe JAILLET, kernel-janitors, linux-kernel, linux-nvme
The way 'spin_lock()' and 'spin_lock_irqsave()' are used is not consistent
in this function.
Use 'spin_lock_irqsave()' also here, as there is no guarantee that
interruptions are disabled at that point, according to surrounding code.
Fixes: a97ec51b37ef ("nvmet_fc: Rework target side abort handling")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not tested, only based on what looks logical to me according to
surrounding code
---
drivers/nvme/target/fc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 55bafd56166a..e6861cc10e7d 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -2342,9 +2342,9 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
return;
if (fcpreq->fcp_error ||
fcpreq->transferred_length != fcpreq->transfer_length) {
- spin_lock(&fod->flock);
+ spin_lock_irqsave(&fod->flock, flags);
fod->abort = true;
- spin_unlock(&fod->flock);
+ spin_unlock_irqrestore(&fod->flock, flags);
nvmet_req_complete(&fod->req, NVME_SC_INTERNAL);
return;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()'
2020-08-21 7:58 [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()' Christophe JAILLET
@ 2020-08-24 20:00 ` Sagi Grimberg
2020-08-24 21:16 ` Keith Busch
2020-08-25 7:10 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2020-08-24 20:00 UTC (permalink / raw)
To: Christophe JAILLET, james.smart, hch, chaitanya.kulkarni
Cc: kernel-janitors, linux-kernel, linux-nvme
> The way 'spin_lock()' and 'spin_lock_irqsave()' are used is not consistent
> in this function.
>
> Use 'spin_lock_irqsave()' also here, as there is no guarantee that
> interruptions are disabled at that point, according to surrounding code.
>
> Fixes: a97ec51b37ef ("nvmet_fc: Rework target side abort handling")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not tested, only based on what looks logical to me according to
> surrounding code
> ---
> drivers/nvme/target/fc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index 55bafd56166a..e6861cc10e7d 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
> @@ -2342,9 +2342,9 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
> return;
> if (fcpreq->fcp_error ||
> fcpreq->transferred_length != fcpreq->transfer_length) {
> - spin_lock(&fod->flock);
> + spin_lock_irqsave(&fod->flock, flags);
> fod->abort = true;
> - spin_unlock(&fod->flock);
> + spin_unlock_irqrestore(&fod->flock, flags);
>
> nvmet_req_complete(&fod->req, NVME_SC_INTERNAL);
> return;
>
James, can I get a reviewed-by from you on this?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()'
2020-08-24 20:00 ` Sagi Grimberg
@ 2020-08-24 21:16 ` Keith Busch
2020-08-25 7:09 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Keith Busch @ 2020-08-24 21:16 UTC (permalink / raw)
To: Sagi Grimberg
Cc: chaitanya.kulkarni, kernel-janitors, linux-kernel, linux-nvme,
james.smart, Christophe JAILLET, hch
On Mon, Aug 24, 2020 at 01:00:11PM -0700, Sagi Grimberg wrote:
> > The way 'spin_lock()' and 'spin_lock_irqsave()' are used is not consistent
> > in this function.
> >
> > Use 'spin_lock_irqsave()' also here, as there is no guarantee that
> > interruptions are disabled at that point, according to surrounding code.
> >
> > Fixes: a97ec51b37ef ("nvmet_fc: Rework target side abort handling")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> > Not tested, only based on what looks logical to me according to
> > surrounding code
> > ---
> > drivers/nvme/target/fc.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> > index 55bafd56166a..e6861cc10e7d 100644
> > --- a/drivers/nvme/target/fc.c
> > +++ b/drivers/nvme/target/fc.c
> > @@ -2342,9 +2342,9 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
> > return;
> > if (fcpreq->fcp_error ||
> > fcpreq->transferred_length != fcpreq->transfer_length) {
> > - spin_lock(&fod->flock);
> > + spin_lock_irqsave(&fod->flock, flags);
> > fod->abort = true;
> > - spin_unlock(&fod->flock);
> > + spin_unlock_irqrestore(&fod->flock, flags);
> > nvmet_req_complete(&fod->req, NVME_SC_INTERNAL);
> > return;
> >
>
> James, can I get a reviewed-by from you on this?
afaics, the lock just serializes single writes, in which
WRITE/READ_ONCE() can handle that without a lock, right?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()'
2020-08-24 21:16 ` Keith Busch
@ 2020-08-25 7:09 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2020-08-25 7:09 UTC (permalink / raw)
To: Keith Busch
Cc: Sagi Grimberg, chaitanya.kulkarni, kernel-janitors, james.smart,
linux-nvme, linux-kernel, Christophe JAILLET, hch
On Mon, Aug 24, 2020 at 02:16:30PM -0700, Keith Busch wrote:
> On Mon, Aug 24, 2020 at 01:00:11PM -0700, Sagi Grimberg wrote:
> > > The way 'spin_lock()' and 'spin_lock_irqsave()' are used is not consistent
> > > in this function.
> > >
> > > Use 'spin_lock_irqsave()' also here, as there is no guarantee that
> > > interruptions are disabled at that point, according to surrounding code.
> > >
> > > Fixes: a97ec51b37ef ("nvmet_fc: Rework target side abort handling")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > ---
> > > Not tested, only based on what looks logical to me according to
> > > surrounding code
> > > ---
> > > drivers/nvme/target/fc.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> > > index 55bafd56166a..e6861cc10e7d 100644
> > > --- a/drivers/nvme/target/fc.c
> > > +++ b/drivers/nvme/target/fc.c
> > > @@ -2342,9 +2342,9 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
> > > return;
> > > if (fcpreq->fcp_error ||
> > > fcpreq->transferred_length != fcpreq->transfer_length) {
> > > - spin_lock(&fod->flock);
> > > + spin_lock_irqsave(&fod->flock, flags);
> > > fod->abort = true;
> > > - spin_unlock(&fod->flock);
> > > + spin_unlock_irqrestore(&fod->flock, flags);
> > > nvmet_req_complete(&fod->req, NVME_SC_INTERNAL);
> > > return;
> > >
> >
> > James, can I get a reviewed-by from you on this?
>
> afaics, the lock just serializes single writes, in which
> WRITE/READ_ONCE() can handle that without a lock, right?
It synchronizes a few fields, sometimes taken over multiple updates.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()'
2020-08-21 7:58 [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()' Christophe JAILLET
2020-08-24 20:00 ` Sagi Grimberg
@ 2020-08-25 7:10 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2020-08-25 7:10 UTC (permalink / raw)
To: Christophe JAILLET
Cc: sagi, chaitanya.kulkarni, kernel-janitors, linux-kernel,
linux-nvme, james.smart, hch
On Fri, Aug 21, 2020 at 09:58:19AM +0200, Christophe JAILLET wrote:
> The way 'spin_lock()' and 'spin_lock_irqsave()' are used is not consistent
> in this function.
>
> Use 'spin_lock_irqsave()' also here, as there is no guarantee that
> interruptions are disabled at that point, according to surrounding code.
>
> Fixes: a97ec51b37ef ("nvmet_fc: Rework target side abort handling")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not tested, only based on what looks logical to me according to
> surrounding code
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-25 7:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 7:58 [PATCH] nvmet-fc: Fix a missed _irqsave version of spin_lock in 'nvmet_fc_fod_op_done()' Christophe JAILLET
2020-08-24 20:00 ` Sagi Grimberg
2020-08-24 21:16 ` Keith Busch
2020-08-25 7:09 ` Christoph Hellwig
2020-08-25 7:10 ` Christoph Hellwig
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).