* Re: [PATCH 2/9] dm: Fix a race condition related to stopping and starting queues
From: Hannes Reinecke @ 2016-09-27 6:21 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <ba8ddc16-b709-e7fb-1120-b6e1bd393540-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
On 09/26/2016 08:26 PM, Bart Van Assche wrote:
> Ensure that all ongoing dm_mq_queue_rq() and dm_mq_requeue_request()
> calls have stopped before setting the "queue stopped" flag. This
> allows to remove the "queue stopped" test from dm_mq_queue_rq() and
> dm_mq_requeue_request(). This patch fixes a race condition because
> dm_mq_queue_rq() is called without holding the queue lock and hence
> BLK_MQ_S_STOPPED can be set at any time while dm_mq_queue_rq() is
> in progress.
>
> Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
> Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/md/dm-rq.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
Reviewed-by: Hannes Reinecke <hare-IBi9RG/b67k@public.gmane.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare-l3A5Bk7waGM@public.gmane.org +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 1/9] blk-mq: Introduce blk_mq_queue_stopped()
From: Hannes Reinecke @ 2016-09-27 6:20 UTC (permalink / raw)
To: Bart Van Assche, Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <b2210943-62b2-959a-569a-a404da03bcae@sandisk.com>
On 09/26/2016 08:26 PM, Bart Van Assche wrote:
> The function blk_queue_stopped() allows to test whether or not a
> traditional request queue has been stopped. Introduce a helper
> function that allows block drivers to query easily whether or not
> one or more hardware contexts of a blk-mq queue have been stopped.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-mq.c | 20 ++++++++++++++++++++
> include/linux/blk-mq.h | 1 +
> 2 files changed, 21 insertions(+)
>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
^ permalink raw reply
* Re: [PATCH v5 00/16] Add Paravirtual RDMA Driver
From: Bjorn Helgaas @ 2016-09-26 22:42 UTC (permalink / raw)
To: Adit Ranadive
Cc: dledford, linux-rdma, pv-drivers, netdev, linux-pci, jhansen,
asarwade, georgezhang, bryantan
In-Reply-To: <cover.1474759181.git.aditr@vmware.com>
On Sat, Sep 24, 2016 at 04:21:24PM -0700, Adit Ranadive wrote:
> MAINTAINERS | 9 +
> drivers/infiniband/Kconfig | 1 +
> drivers/infiniband/hw/Makefile | 1 +
> drivers/infiniband/hw/pvrdma/Kconfig | 7 +
> drivers/infiniband/hw/pvrdma/Makefile | 3 +
> drivers/infiniband/hw/pvrdma/pvrdma.h | 473 +++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_cmd.c | 117 +++
> drivers/infiniband/hw/pvrdma/pvrdma_cq.c | 426 +++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_defs.h | 301 ++++++
> drivers/infiniband/hw/pvrdma/pvrdma_dev_api.h | 342 +++++++
> drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c | 127 +++
> drivers/infiniband/hw/pvrdma/pvrdma_ib_verbs.h | 444 +++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_main.c | 1220 ++++++++++++++++++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_misc.c | 304 ++++++
> drivers/infiniband/hw/pvrdma/pvrdma_mr.c | 334 +++++++
> drivers/infiniband/hw/pvrdma/pvrdma_qp.c | 973 +++++++++++++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_verbs.c | 577 +++++++++++
> drivers/infiniband/hw/pvrdma/pvrdma_verbs.h | 108 +++
> drivers/net/vmxnet3/vmxnet3_int.h | 3 +-
> include/linux/pci_ids.h | 1 +
> include/uapi/rdma/Kbuild | 2 +
> include/uapi/rdma/pvrdma-abi.h | 99 ++
> include/uapi/rdma/pvrdma-uapi.h | 255 +++++
Hi Adit,
You don't need to cc linux-pci just because of the one-line change to
pci_ids.h. I've already acked that, and the rest is just noise to the
main linux-pci audience.
Bjorn
^ permalink raw reply
* Re: [PATCH 0/9] Introduce blk_quiesce_queue() and blk_resume_queue()
From: Bart Van Assche @ 2016-09-26 22:26 UTC (permalink / raw)
To: Mike Snitzer
Cc: Jens Axboe, Christoph Hellwig, James Bottomley,
Martin K. Petersen, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <20160926183308.GA13309-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 09/26/2016 11:33 AM, Mike Snitzer wrote:
> How much testing has this series seen? Did you run it against the
> mptest testsuite? https://github.com/snitm/mptest
Hello Mike,
The output of mptest with MULTIPATH_BACKEND_MODULE="scsidebug":
# ./runtest
[ ... ]
SUCCESS
** summary **
PASSED: test_00_no_failure test_01_sdev_offline test_02_sdev_delete
test_03_dm_failpath test_04_dm_switchpg
FAILED:
I think this is the output we were hoping to see :-)
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH rdma-core 4/5] libocrdma: Move ocrdma's list implementation into common directory
From: Jason Gunthorpe @ 2016-09-26 22:23 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Leon Romanovsky, dledford-H+wXaHxf7aLQT0dZR+AlfA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, yishaih-VPRAkNaXOzVWk0Htik3J/w
In-Reply-To: <20160926221440.GA5878-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
On Mon, Sep 26, 2016 at 03:14:40PM -0700, Christoph Hellwig wrote:
> On Mon, Sep 26, 2016 at 11:40:57AM -0600, Jason Gunthorpe wrote:
> > Copyright isn't a patent,
>
> I know very well, thanks..
Right, mainly for others..
> > assuming freebsd didn't copy any code and
> > just implemented the same API independently (eg it is an Independent
> > Creation) they should be OK from a copyright perspective.
>
> That's a big IF, as I'm honestly not sure it is. I don't want to blame
> anywone because I really don't know but if I had to decided to use it
> or not I would error on the safe side.
Sounds reasonable.
> > As should be
> > Rusty's version in CCAN.
>
> That's a much safer choice. It's a lightly different API, though.
Leon? Does this seem doable to you?
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH rdma-core 4/5] libocrdma: Move ocrdma's list implementation into common directory
From: Christoph Hellwig @ 2016-09-26 22:14 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Christoph Hellwig, Leon Romanovsky,
dledford-H+wXaHxf7aLQT0dZR+AlfA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, yishaih-VPRAkNaXOzVWk0Htik3J/w
In-Reply-To: <20160926174057.GD22965-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
On Mon, Sep 26, 2016 at 11:40:57AM -0600, Jason Gunthorpe wrote:
> Copyright isn't a patent,
I know very well, thanks..
> assuming freebsd didn't copy any code and
> just implemented the same API independently (eg it is an Independent
> Creation) they should be OK from a copyright perspective.
That's a big IF, as I'm honestly not sure it is. I don't want to blame
anywone because I really don't know but if I had to decided to use it
or not I would error on the safe side.
> As should be
> Rusty's version in CCAN.
That's a much safer choice. It's a lightly different API, though.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v5 00/16] Add Paravirtual RDMA Driver
From: Adit Ranadive @ 2016-09-26 21:16 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, dledford, linux-rdma, pv-drivers, netdev,
linux-pci, jhansen, asarwade, georgezhang, bryantan
In-Reply-To: <20160926210724.GA16413@obsidianresearch.com>
On Mon, Sep 26, 2016 at 14:07:24PM -0700, Jason Gunthorpe wrote:
> On Mon, Sep 26, 2016 at 01:40:10PM -0700, Adit Ranadive wrote:
>
> > Wouldnt they be some overlap between the user-space and kernel driver? Or is
> > it expected that the common structures (even device specific ones) be moved to
> > the ABI file?
>
> Yes, even device specific structures must be in the abi file. Anything
> that is used with copy_to_user/copy_from_user/etc.
>
Ok. Will make sure we consolidate the common stuff in the ABI file in the
next version.
Thanks,
Adit
^ permalink raw reply
* Re: [PATCH v5 00/16] Add Paravirtual RDMA Driver
From: Jason Gunthorpe @ 2016-09-26 21:07 UTC (permalink / raw)
To: Adit Ranadive
Cc: Leon Romanovsky, dledford-H+wXaHxf7aLQT0dZR+AlfA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
pv-drivers-pghWNbHTmq7QT0dZR+AlfA, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-pci-u79uwXL29TY76Z2rM5mHXA, jhansen-pghWNbHTmq7QT0dZR+AlfA,
asarwade-pghWNbHTmq7QT0dZR+AlfA,
georgezhang-pghWNbHTmq7QT0dZR+AlfA,
bryantan-pghWNbHTmq7QT0dZR+AlfA
In-Reply-To: <b4e0acd9-e1a2-f6ac-0afa-c0fd62dd62f0-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
On Mon, Sep 26, 2016 at 01:40:10PM -0700, Adit Ranadive wrote:
> Wouldnt they be some overlap between the user-space and kernel driver? Or is
> it expected that the common structures (even device specific ones) be moved to
> the ABI file?
Yes, even device specific structures must be in the abi file. Anything
that is used with copy_to_user/copy_from_user/etc.
> For the mlx4 driver I see that the structures in include/linux/mlx4/qp.h
> and in libmlx4/src/wqe.h are similar.
We are trying to clean exactly that sort of stuff up, please try not
to add more.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v5 00/16] Add Paravirtual RDMA Driver
From: Adit Ranadive @ 2016-09-26 20:40 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, dledford, linux-rdma, pv-drivers, netdev,
linux-pci, jhansen, asarwade, georgezhang, bryantan
In-Reply-To: <20160926165104.GA12011@obsidianresearch.com>
On Mon, Sep 26, 2016 at 10:51:04AM -0600, Jason Gunthorpe wrote:
> On Sun, Sep 25, 2016 at 10:25:12PM -0700, Adit Ranadive wrote:
> > > As Jason said, you need a very good reason to split and create number of
> > > files per-driver in UAPI folder.
> >
> > I can move the pvrdma-uapi.h back to the pvrdma driver folder.
>
> Just don't copy any of the content into your user space provider.
Thanks. I wanted to clarify regarding device specific structures since that
is what our pvrdma-uapi.h file has.
Wouldnt they be some overlap between the user-space and kernel driver? Or is
it expected that the common structures (even device specific ones) be moved to
the ABI file?
For the mlx4 driver I see that the structures in include/linux/mlx4/qp.h
and in libmlx4/src/wqe.h are similar.
Thanks,
Adit
^ permalink raw reply
* [PATCH 2/2] IB/srp: Avoid that certain sg-lists trigger an infinite loop with FMR
From: Bart Van Assche @ 2016-09-26 19:58 UTC (permalink / raw)
To: Doug Ledford
Cc: Alex Estrin, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <c5bd10df-225d-df4c-c765-97551348dbbd-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Avoid that mapping an sg-list in which the first element has a
non-zero offset triggers an infinite loop when using FMR. This
patch makes the FMR mapping code similar to that of ib_sg_to_pages().
Note: older Mellanox HCAs do not support non-zero offsets for FMR.
See also commit 8c4037b501ac ("IB/srp: always avoid non-zero offsets
into an FMR").
Reported-by: Alex Estrin <alex.estrin-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
---
drivers/infiniband/ulp/srp/ib_srp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 06bb7a905635..29ec5e2f247e 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1416,7 +1416,9 @@ static int srp_map_sg_entry(struct srp_map_state *state,
while (dma_len) {
unsigned offset = dma_addr & ~dev->mr_page_mask;
- if (state->npages == dev->max_pages_per_mr || offset != 0) {
+
+ if (state->npages == dev->max_pages_per_mr ||
+ (state->npages > 0 && offset != 0)) {
ret = srp_map_finish_fmr(state, ch);
if (ret)
return ret;
@@ -1433,12 +1435,12 @@ static int srp_map_sg_entry(struct srp_map_state *state,
}
/*
- * If the last entry of the MR wasn't a full page, then we need to
+ * If the end of the MR is not on a page boundary then we need to
* close it out and start a new one -- we can only merge at page
* boundaries.
*/
ret = 0;
- if (len != dev->mr_page_size)
+ if ((dma_addr & ~dev->mr_page_mask) != 0)
ret = srp_map_finish_fmr(state, ch);
return ret;
}
--
2.10.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 1/2] IB/srp: Remove an unused argument
From: Bart Van Assche @ 2016-09-26 19:57 UTC (permalink / raw)
To: Doug Ledford
Cc: Alex Estrin, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <c5bd10df-225d-df4c-c765-97551348dbbd-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
---
drivers/infiniband/ulp/srp/ib_srp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 513f2ec..06bb7a9 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1402,7 +1402,7 @@ static int srp_map_finish_fr(struct srp_map_state *state,
static int srp_map_sg_entry(struct srp_map_state *state,
struct srp_rdma_ch *ch,
- struct scatterlist *sg, int sg_index)
+ struct scatterlist *sg)
{
struct srp_target_port *target = ch->target;
struct srp_device *dev = target->srp_host->srp_dev;
@@ -1455,7 +1455,7 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch,
state->fmr.end = req->fmr_list + ch->target->mr_per_cmd;
for_each_sg(scat, sg, count, i) {
- ret = srp_map_sg_entry(state, ch, sg, i);
+ ret = srp_map_sg_entry(state, ch, sg);
if (ret)
return ret;
}
--
2.10.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 0/2] Avoid that certain sg-lists trigger an infinite loop with FMR
From: Bart Van Assche @ 2016-09-26 19:56 UTC (permalink / raw)
To: Doug Ledford
Cc: Alex Estrin, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hello Doug,
It would be appreciated if the following two patches would be considered
for inclusion in kernel v4.9:
0001-IB-srp-Remove-an-unused-argument.patch
0002-IB-srp-Avoid-that-certain-sg-lists-trigger-an-infini.patch
Thanks,
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 13/13] Remove ibsupport-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org from MAINTAINERS
From: Dalessandro, Dennis @ 2016-09-26 19:12 UTC (permalink / raw)
To: jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20160926181206.GA28992-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
On Mon, 2016-09-26 at 12:12 -0600, Jason Gunthorpe wrote:
> On Sat, Sep 24, 2016 at 07:18:42PM +0000, Dalessandro, Dennis wrote:
> > Actually on second thought, maybe better to use:
> >
> > infinipath <infinipath@intel.com>
>
> This Ok?
>
> https://github.com/jgunthorpe/rdma-plumbing/commit/b8436b9b21bc9f8432
> bba6b49573ea31db945101
Works for me. Thanks.
-Denny
^ permalink raw reply
* [ANNOUNCE] Open Fabrics Verbs Working Group (OFVWG) meeting tomorrow - 9/27/2016 at 11:00PDT
From: Liran Liss @ 2016-09-26 18:59 UTC (permalink / raw)
To: 'ofvwg-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5@public.gmane.org',
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Agenda - ABI proposal update:
- Additional TLV type for file descriptors
- New common handlers
--Liran
Concall details
===========
JOIN WEBEX MEETING
https://mellanox-tech.webex.com/join/Liran.Liss | 702 830 424
JOIN BY PHONE
1-80-9453550 Israel toll free
1-855-299-5224 USA/Canada toll free
Access code: 702 830 424
Global call-in numbers:
https://mellanox-tech.webex.com/mellanox-tech/globalcallin.php?serviceType=MC&ED=457637257&tollFree=1
Toll-free calling restrictions:
http://www.webex.com/pdf/tollfree_restrictions.pdf
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 0/9] Introduce blk_quiesce_queue() and blk_resume_queue()
From: Bart Van Assche @ 2016-09-26 18:46 UTC (permalink / raw)
To: Mike Snitzer
Cc: Jens Axboe, Christoph Hellwig, James Bottomley,
Martin K. Petersen, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <20160926183308.GA13309-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 09/26/2016 11:33 AM, Mike Snitzer wrote:
> On Mon, Sep 26 2016 at 2:25pm -0400,
> Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> wrote:
>
>> Hello Jens,
>>
>> Multiple block drivers need the functionality to stop a request
>> queue and to wait until all ongoing request_fn() / queue_rq() calls
>> have finished without waiting until all outstanding requests have
>> finished. Hence this patch series that introduces the
>> blk_quiesce_queue() and blk_resume_queue() functions. The dm-mq, SRP
>> and nvme patches in this patch series are three examples of where
>> these functions are useful. These patches apply on top of the
>> September 21 version of your for-4.9/block branch. The individual
>> patches in this series are:
>>
>> 0001-blk-mq-Introduce-blk_mq_queue_stopped.patch
>> 0002-dm-Fix-a-race-condition-related-to-stopping-and-star.patch
>> 0003-RFC-nvme-Use-BLK_MQ_S_STOPPED-instead-of-QUEUE_FLAG_.patch
>> 0004-block-Move-blk_freeze_queue-and-blk_unfreeze_queue-c.patch
>> 0005-block-Extend-blk_freeze_queue_start-to-the-non-blk-m.patch
>> 0006-block-Rename-mq_freeze_wq-and-mq_freeze_depth.patch
>> 0007-blk-mq-Introduce-blk_quiesce_queue-and-blk_resume_qu.patch
>> 0008-SRP-transport-Port-srp_wait_for_queuecommand-to-scsi.patch
>> 0009-RFC-nvme-Fix-a-race-condition.patch
>
> Hi Bart,
>
> How much testing has this series seen? Did you run it against the
> mptest testsuite? https://github.com/snitm/mptest
>
> I did notice patch 2 should come after patch 7 (not sure if other
> patches are out of order).
Hello Mike,
Regarding testing: I have primarily used my srp-test regression test
suite to test this patch series because that test suite uncovered a
dm-mq race that was not discovered by mptest. I'm currently running
xfstests (to verify an ib_srp change that is not in this patch series)
and will run mptest next.
You are right that patch 2 should come after patch 7. The order of the
other patches in this series should be fine.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 0/9] Introduce blk_quiesce_queue() and blk_resume_queue()
From: Mike Snitzer @ 2016-09-26 18:33 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, Christoph Hellwig, James Bottomley,
Martin K. Petersen, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
On Mon, Sep 26 2016 at 2:25pm -0400,
Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> wrote:
> Hello Jens,
>
> Multiple block drivers need the functionality to stop a request
> queue and to wait until all ongoing request_fn() / queue_rq() calls
> have finished without waiting until all outstanding requests have
> finished. Hence this patch series that introduces the
> blk_quiesce_queue() and blk_resume_queue() functions. The dm-mq, SRP
> and nvme patches in this patch series are three examples of where
> these functions are useful. These patches apply on top of the
> September 21 version of your for-4.9/block branch. The individual
> patches in this series are:
>
> 0001-blk-mq-Introduce-blk_mq_queue_stopped.patch
> 0002-dm-Fix-a-race-condition-related-to-stopping-and-star.patch
> 0003-RFC-nvme-Use-BLK_MQ_S_STOPPED-instead-of-QUEUE_FLAG_.patch
> 0004-block-Move-blk_freeze_queue-and-blk_unfreeze_queue-c.patch
> 0005-block-Extend-blk_freeze_queue_start-to-the-non-blk-m.patch
> 0006-block-Rename-mq_freeze_wq-and-mq_freeze_depth.patch
> 0007-blk-mq-Introduce-blk_quiesce_queue-and-blk_resume_qu.patch
> 0008-SRP-transport-Port-srp_wait_for_queuecommand-to-scsi.patch
> 0009-RFC-nvme-Fix-a-race-condition.patch
Hi Bart,
How much testing has this series seen? Did you run it against the
mptest testsuite? https://github.com/snitm/mptest
I did notice patch 2 should come after patch 7 (not sure if other
patches are out of order).
Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH 9/9] [RFC] nvme: Fix a race condition
From: Bart Van Assche @ 2016-09-26 18:28 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
Avoid that nvme_queue_rq() is still running when nvme_stop_queues()
returns. Untested.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/core.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 057f1fa..6e2bf6a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -201,13 +201,9 @@ fail:
void nvme_requeue_req(struct request *req)
{
- unsigned long flags;
-
blk_mq_requeue_request(req);
- spin_lock_irqsave(req->q->queue_lock, flags);
- if (!blk_mq_queue_stopped(req->q))
- blk_mq_kick_requeue_list(req->q);
- spin_unlock_irqrestore(req->q->queue_lock, flags);
+ WARN_ON_ONCE(blk_mq_queue_stopped(req->q));
+ blk_mq_kick_requeue_list(req->q);
}
EXPORT_SYMBOL_GPL(nvme_requeue_req);
@@ -2079,11 +2075,15 @@ EXPORT_SYMBOL_GPL(nvme_kill_queues);
void nvme_stop_queues(struct nvme_ctrl *ctrl)
{
struct nvme_ns *ns;
+ struct request_queue *q;
mutex_lock(&ctrl->namespaces_mutex);
list_for_each_entry(ns, &ctrl->namespaces, list) {
- blk_mq_cancel_requeue_work(ns->queue);
- blk_mq_stop_hw_queues(ns->queue);
+ q = ns->queue;
+ blk_quiesce_queue(q);
+ blk_mq_cancel_requeue_work(q);
+ blk_mq_stop_hw_queues(q);
+ blk_resume_queue(q);
}
mutex_unlock(&ctrl->namespaces_mutex);
}
--
2.10.0
^ permalink raw reply related
* [PATCH 8/9] SRP transport: Port srp_wait_for_queuecommand() to scsi-mq
From: Bart Van Assche @ 2016-09-26 18:28 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
Ensure that if scsi-mq is enabled that srp_wait_for_queuecommand()
waits until ongoing shost->hostt->queuecommand() calls have finished.
For the !scsi-mq path, use blk_quiesce_queue() and blk_resume_queue()
instead of busy-waiting.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: James Bottomley <jejb@linux.vnet.ibm.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Doug Ledford <dledford@redhat.com>
---
drivers/scsi/scsi_transport_srp.c | 26 +++++---------------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index e3cd3ec..841a3eb 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -24,7 +24,7 @@
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/string.h>
-#include <linux/delay.h>
+#include <linux/blk-mq.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -402,34 +402,18 @@ static void srp_reconnect_work(struct work_struct *work)
}
}
-/**
- * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
- * @shost: SCSI host for which to count the number of scsi_request_fn() callers.
- *
- * To do: add support for scsi-mq in this function.
- */
-static int scsi_request_fn_active(struct Scsi_Host *shost)
+/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */
+static void srp_wait_for_queuecommand(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
struct request_queue *q;
- int request_fn_active = 0;
shost_for_each_device(sdev, shost) {
q = sdev->request_queue;
- spin_lock_irq(q->queue_lock);
- request_fn_active += q->request_fn_active;
- spin_unlock_irq(q->queue_lock);
+ blk_quiesce_queue(q);
+ blk_resume_queue(q);
}
-
- return request_fn_active;
-}
-
-/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */
-static void srp_wait_for_queuecommand(struct Scsi_Host *shost)
-{
- while (scsi_request_fn_active(shost))
- msleep(20);
}
static void __rport_fail_io_fast(struct srp_rport *rport)
--
2.10.0
^ permalink raw reply related
* [PATCH 7/9] blk-mq: Introduce blk_quiesce_queue() and blk_resume_queue()
From: Bart Van Assche @ 2016-09-26 18:28 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
blk_quiesce_queue() prevents that new queue_rq() invocations
occur and waits until ongoing invocations have finished. This
function does *not* wait until all outstanding requests have
finished (this means invocation of request.end_io()).
blk_resume_queue() resumes normal I/O processing.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
block/blk-core.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++----
block/blk-mq.c | 24 +++++++++++++-----
block/blk.h | 2 +-
include/linux/blkdev.h | 5 ++++
4 files changed, 85 insertions(+), 12 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 0ff5d57..62cb6ae 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -682,18 +682,20 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref)
wake_up_all(&q->freeze_wq);
}
-void blk_freeze_queue_start(struct request_queue *q)
+bool blk_freeze_queue_start(struct request_queue *q, bool kill_percpu_ref)
{
int freeze_depth;
freeze_depth = atomic_inc_return(&q->freeze_depth);
if (freeze_depth == 1) {
- percpu_ref_kill(&q->q_usage_counter);
+ if (kill_percpu_ref)
+ percpu_ref_kill(&q->q_usage_counter);
if (q->mq_ops)
blk_mq_run_hw_queues(q, false);
else if (q->request_fn)
blk_run_queue(q);
}
+ return freeze_depth == 1;
}
void blk_freeze_queue_wait(struct request_queue *q)
@@ -708,21 +710,75 @@ void blk_freeze_queue_wait(struct request_queue *q)
*/
void blk_freeze_queue(struct request_queue *q)
{
- blk_freeze_queue_start(q);
+ blk_freeze_queue_start(q, true);
blk_freeze_queue_wait(q);
}
-void blk_unfreeze_queue(struct request_queue *q)
+static bool __blk_unfreeze_queue(struct request_queue *q,
+ bool reinit_percpu_ref)
{
int freeze_depth;
freeze_depth = atomic_dec_return(&q->freeze_depth);
WARN_ON_ONCE(freeze_depth < 0);
if (!freeze_depth) {
- percpu_ref_reinit(&q->q_usage_counter);
+ if (reinit_percpu_ref)
+ percpu_ref_reinit(&q->q_usage_counter);
wake_up_all(&q->freeze_wq);
}
+ return freeze_depth == 0;
+}
+
+void blk_unfreeze_queue(struct request_queue *q)
+{
+ __blk_unfreeze_queue(q, true);
+}
+
+/**
+ * blk_quiesce_queue() - wait until all pending queue_rq calls have finished
+ *
+ * Prevent that new I/O requests are queued and wait until all pending
+ * queue_rq() calls have finished. Must not be called if the queue has already
+ * been frozen. Additionally, freezing the queue after having quiesced the
+ * queue and before resuming the queue is not allowed.
+ *
+ * Note: this function does not prevent that the struct request end_io()
+ * callback function is invoked.
+ */
+void blk_quiesce_queue(struct request_queue *q)
+{
+ spin_lock_irq(q->queue_lock);
+ WARN_ON_ONCE(blk_queue_quiescing(q));
+ queue_flag_set(QUEUE_FLAG_QUIESCING, q);
+ spin_unlock_irq(q->queue_lock);
+
+ WARN_ON_ONCE(!blk_freeze_queue_start(q, false));
+ synchronize_rcu();
+
+ spin_lock_irq(q->queue_lock);
+ WARN_ON_ONCE(!blk_queue_quiescing(q));
+ queue_flag_clear(QUEUE_FLAG_QUIESCING, q);
+ spin_unlock_irq(q->queue_lock);
+}
+EXPORT_SYMBOL_GPL(blk_quiesce_queue);
+
+/**
+ * blk_resume_queue() - resume request processing
+ *
+ * The caller is responsible for serializing blk_quiesce_queue() and
+ * blk_resume_queue().
+ */
+void blk_resume_queue(struct request_queue *q)
+{
+ WARN_ON_ONCE(!__blk_unfreeze_queue(q, false));
+ WARN_ON_ONCE(blk_queue_quiescing(q));
+
+ if (q->mq_ops)
+ blk_mq_run_hw_queues(q, false);
+ else
+ blk_run_queue(q);
}
+EXPORT_SYMBOL_GPL(blk_resume_queue);
static void blk_rq_timed_out_timer(unsigned long data)
{
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e17a5bf..4df9e4f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -60,7 +60,7 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx,
void blk_mq_freeze_queue_start(struct request_queue *q)
{
- blk_freeze_queue_start(q);
+ blk_freeze_queue_start(q, true);
}
EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start);
@@ -441,6 +441,9 @@ static void blk_mq_requeue_work(struct work_struct *work)
struct request *rq, *next;
unsigned long flags;
+ if (blk_queue_quiescing(q))
+ return;
+
spin_lock_irqsave(&q->requeue_lock, flags);
list_splice_init(&q->requeue_list, &rq_list);
spin_unlock_irqrestore(&q->requeue_lock, flags);
@@ -757,6 +760,8 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
*/
flush_busy_ctxs(hctx, &rq_list);
+ rcu_read_lock();
+
/*
* If we have previous entries on our dispatch list, grab them
* and stuff them at the front for more fair dispatch.
@@ -836,8 +841,11 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
*
* blk_mq_run_hw_queue() already checks the STOPPED bit
**/
- blk_mq_run_hw_queue(hctx, true);
+ if (!blk_queue_quiescing(q))
+ blk_mq_run_hw_queue(hctx, true);
}
+
+ rcu_read_unlock();
}
/*
@@ -1294,7 +1302,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
blk_mq_bio_to_request(rq, bio);
/*
- * We do limited pluging. If the bio can be merged, do that.
+ * We do limited plugging. If the bio can be merged, do that.
* Otherwise the existing request in the plug list will be
* issued. So the plug list will have one request at most
*/
@@ -1314,9 +1322,13 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
blk_mq_put_ctx(data.ctx);
if (!old_rq)
goto done;
- if (!blk_mq_direct_issue_request(old_rq, &cookie))
- goto done;
- blk_mq_insert_request(old_rq, false, true, true);
+
+ rcu_read_lock();
+ if (blk_queue_quiescing(q) ||
+ blk_mq_direct_issue_request(old_rq, &cookie) != 0)
+ blk_mq_insert_request(old_rq, false, true, true);
+ rcu_read_unlock();
+
goto done;
}
diff --git a/block/blk.h b/block/blk.h
index 12f7366..0e934b5 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -71,7 +71,7 @@ void __blk_queue_free_tags(struct request_queue *q);
bool __blk_end_bidi_request(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes);
void blk_freeze_queue(struct request_queue *q);
-void blk_freeze_queue_start(struct request_queue *q);
+bool blk_freeze_queue_start(struct request_queue *q, bool kill_percpu_ref);
void blk_freeze_queue_wait(struct request_queue *q);
void blk_unfreeze_queue(struct request_queue *q);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f08dc65..06c9b21 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -505,6 +505,7 @@ struct request_queue {
#define QUEUE_FLAG_FUA 24 /* device supports FUA writes */
#define QUEUE_FLAG_FLUSH_NQ 25 /* flush not queueuable */
#define QUEUE_FLAG_DAX 26 /* device supports DAX */
+#define QUEUE_FLAG_QUIESCING 27
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_STACKABLE) | \
@@ -595,6 +596,8 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
#define blk_queue_secure_erase(q) \
(test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags))
#define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags)
+#define blk_queue_quiescing(q) test_bit(QUEUE_FLAG_QUIESCING, \
+ &(q)->queue_flags)
#define blk_noretry_request(rq) \
((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
@@ -824,6 +827,8 @@ extern void __blk_run_queue(struct request_queue *q);
extern void __blk_run_queue_uncond(struct request_queue *q);
extern void blk_run_queue(struct request_queue *);
extern void blk_run_queue_async(struct request_queue *q);
+extern void blk_quiesce_queue(struct request_queue *q);
+extern void blk_resume_queue(struct request_queue *q);
extern int blk_rq_map_user(struct request_queue *, struct request *,
struct rq_map_data *, void __user *, unsigned long,
gfp_t);
--
2.10.0
^ permalink raw reply related
* [PATCH 6/9] block: Rename mq_freeze_wq and mq_freeze_depth
From: Bart Van Assche @ 2016-09-26 18:28 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
Since these two structure members are now used in blk-mq and !blk-mq
paths, remove the mq_prefix. This patch does not change any
functionality.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
block/blk-core.c | 20 ++++++++++----------
block/blk-mq.c | 4 ++--
include/linux/blkdev.h | 4 ++--
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 5ecc7ab..0ff5d57 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -659,9 +659,9 @@ int blk_queue_enter(struct request_queue *q, bool nowait)
if (nowait)
return -EBUSY;
- ret = wait_event_interruptible(q->mq_freeze_wq,
- !atomic_read(&q->mq_freeze_depth) ||
- blk_queue_dying(q));
+ ret = wait_event_interruptible(q->freeze_wq,
+ !atomic_read(&q->freeze_depth) ||
+ blk_queue_dying(q));
if (blk_queue_dying(q))
return -ENODEV;
if (ret)
@@ -679,14 +679,14 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref)
struct request_queue *q =
container_of(ref, struct request_queue, q_usage_counter);
- wake_up_all(&q->mq_freeze_wq);
+ wake_up_all(&q->freeze_wq);
}
void blk_freeze_queue_start(struct request_queue *q)
{
int freeze_depth;
- freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
+ freeze_depth = atomic_inc_return(&q->freeze_depth);
if (freeze_depth == 1) {
percpu_ref_kill(&q->q_usage_counter);
if (q->mq_ops)
@@ -698,12 +698,12 @@ void blk_freeze_queue_start(struct request_queue *q)
void blk_freeze_queue_wait(struct request_queue *q)
{
- wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
+ wait_event(q->freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
}
/*
* Guarantee no request is in use, so we can change any data structure of
- * the queue afterward. Increases q->mq_freeze_depth and waits until
+ * the queue afterward. Increases q->freeze_depth and waits until
* q->q_usage_counter drops to zero.
*/
void blk_freeze_queue(struct request_queue *q)
@@ -716,11 +716,11 @@ void blk_unfreeze_queue(struct request_queue *q)
{
int freeze_depth;
- freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
+ freeze_depth = atomic_dec_return(&q->freeze_depth);
WARN_ON_ONCE(freeze_depth < 0);
if (!freeze_depth) {
percpu_ref_reinit(&q->q_usage_counter);
- wake_up_all(&q->mq_freeze_wq);
+ wake_up_all(&q->freeze_wq);
}
}
@@ -790,7 +790,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
q->bypass_depth = 1;
__set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags);
- init_waitqueue_head(&q->mq_freeze_wq);
+ init_waitqueue_head(&q->freeze_wq);
/*
* Init percpu_ref in atomic mode so that it's faster to shutdown.
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 50b26df..e17a5bf 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -94,7 +94,7 @@ void blk_mq_wake_waiters(struct request_queue *q)
* dying, we need to ensure that processes currently waiting on
* the queue are notified as well.
*/
- wake_up_all(&q->mq_freeze_wq);
+ wake_up_all(&q->freeze_wq);
}
bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)
@@ -2071,7 +2071,7 @@ void blk_mq_free_queue(struct request_queue *q)
static void blk_mq_queue_reinit(struct request_queue *q,
const struct cpumask *online_mask)
{
- WARN_ON_ONCE(!atomic_read(&q->mq_freeze_depth));
+ WARN_ON_ONCE(!atomic_read(&q->freeze_depth));
blk_mq_sysfs_unregister(q);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c47c358..f08dc65 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -454,7 +454,7 @@ struct request_queue {
struct mutex sysfs_lock;
int bypass_depth;
- atomic_t mq_freeze_depth;
+ atomic_t freeze_depth;
#if defined(CONFIG_BLK_DEV_BSG)
bsg_job_fn *bsg_job_fn;
@@ -467,7 +467,7 @@ struct request_queue {
struct throtl_data *td;
#endif
struct rcu_head rcu_head;
- wait_queue_head_t mq_freeze_wq;
+ wait_queue_head_t freeze_wq;
struct percpu_ref q_usage_counter;
struct list_head all_q_node;
--
2.10.0
^ permalink raw reply related
* [PATCH 5/9] block: Extend blk_freeze_queue_start() to the non-blk-mq path
From: Bart Van Assche @ 2016-09-26 18:27 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
---
block/blk-core.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 8cc8006..5ecc7ab 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -689,7 +689,10 @@ void blk_freeze_queue_start(struct request_queue *q)
freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
if (freeze_depth == 1) {
percpu_ref_kill(&q->q_usage_counter);
- blk_mq_run_hw_queues(q, false);
+ if (q->mq_ops)
+ blk_mq_run_hw_queues(q, false);
+ else if (q->request_fn)
+ blk_run_queue(q);
}
}
@@ -700,17 +703,11 @@ void blk_freeze_queue_wait(struct request_queue *q)
/*
* Guarantee no request is in use, so we can change any data structure of
- * the queue afterward.
+ * the queue afterward. Increases q->mq_freeze_depth and waits until
+ * q->q_usage_counter drops to zero.
*/
void blk_freeze_queue(struct request_queue *q)
{
- /*
- * In the !blk_mq case we are only calling this to kill the
- * q_usage_counter, otherwise this increases the freeze depth
- * and waits for it to return to zero. For this reason there is
- * no blk_unfreeze_queue(), and blk_freeze_queue() is not
- * exported to drivers as the only user for unfreeze is blk_mq.
- */
blk_freeze_queue_start(q);
blk_freeze_queue_wait(q);
}
--
2.10.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 4/9] block: Move blk_freeze_queue() and blk_unfreeze_queue() code
From: Bart Van Assche @ 2016-09-26 18:27 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
Move the blk_freeze_queue() and blk_unfreeze_queue() implementations
from block/blk-mq.c to block/blk-core.c. Drop "_mq" from the name of
the functions that have been moved.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
block/blk-core.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
block/blk-mq.c | 41 +++--------------------------------------
block/blk.h | 3 +++
3 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index b75d688..8cc8006 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -682,6 +682,51 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref)
wake_up_all(&q->mq_freeze_wq);
}
+void blk_freeze_queue_start(struct request_queue *q)
+{
+ int freeze_depth;
+
+ freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
+ if (freeze_depth == 1) {
+ percpu_ref_kill(&q->q_usage_counter);
+ blk_mq_run_hw_queues(q, false);
+ }
+}
+
+void blk_freeze_queue_wait(struct request_queue *q)
+{
+ wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
+}
+
+/*
+ * Guarantee no request is in use, so we can change any data structure of
+ * the queue afterward.
+ */
+void blk_freeze_queue(struct request_queue *q)
+{
+ /*
+ * In the !blk_mq case we are only calling this to kill the
+ * q_usage_counter, otherwise this increases the freeze depth
+ * and waits for it to return to zero. For this reason there is
+ * no blk_unfreeze_queue(), and blk_freeze_queue() is not
+ * exported to drivers as the only user for unfreeze is blk_mq.
+ */
+ blk_freeze_queue_start(q);
+ blk_freeze_queue_wait(q);
+}
+
+void blk_unfreeze_queue(struct request_queue *q)
+{
+ int freeze_depth;
+
+ freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
+ WARN_ON_ONCE(freeze_depth < 0);
+ if (!freeze_depth) {
+ percpu_ref_reinit(&q->q_usage_counter);
+ wake_up_all(&q->mq_freeze_wq);
+ }
+}
+
static void blk_rq_timed_out_timer(unsigned long data)
{
struct request_queue *q = (struct request_queue *)data;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 98d4812..50b26df 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -60,38 +60,10 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx,
void blk_mq_freeze_queue_start(struct request_queue *q)
{
- int freeze_depth;
-
- freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
- if (freeze_depth == 1) {
- percpu_ref_kill(&q->q_usage_counter);
- blk_mq_run_hw_queues(q, false);
- }
+ blk_freeze_queue_start(q);
}
EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start);
-static void blk_mq_freeze_queue_wait(struct request_queue *q)
-{
- wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter));
-}
-
-/*
- * Guarantee no request is in use, so we can change any data structure of
- * the queue afterward.
- */
-void blk_freeze_queue(struct request_queue *q)
-{
- /*
- * In the !blk_mq case we are only calling this to kill the
- * q_usage_counter, otherwise this increases the freeze depth
- * and waits for it to return to zero. For this reason there is
- * no blk_unfreeze_queue(), and blk_freeze_queue() is not
- * exported to drivers as the only user for unfreeze is blk_mq.
- */
- blk_mq_freeze_queue_start(q);
- blk_mq_freeze_queue_wait(q);
-}
-
void blk_mq_freeze_queue(struct request_queue *q)
{
/*
@@ -104,14 +76,7 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue);
void blk_mq_unfreeze_queue(struct request_queue *q)
{
- int freeze_depth;
-
- freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
- WARN_ON_ONCE(freeze_depth < 0);
- if (!freeze_depth) {
- percpu_ref_reinit(&q->q_usage_counter);
- wake_up_all(&q->mq_freeze_wq);
- }
+ blk_unfreeze_queue(q);
}
EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
@@ -2177,7 +2142,7 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
list_for_each_entry(q, &all_q_list, all_q_node)
blk_mq_freeze_queue_start(q);
list_for_each_entry(q, &all_q_list, all_q_node) {
- blk_mq_freeze_queue_wait(q);
+ blk_freeze_queue_wait(q);
/*
* timeout handler can't touch hw queue during the
diff --git a/block/blk.h b/block/blk.h
index c37492f..12f7366 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -71,6 +71,9 @@ void __blk_queue_free_tags(struct request_queue *q);
bool __blk_end_bidi_request(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes);
void blk_freeze_queue(struct request_queue *q);
+void blk_freeze_queue_start(struct request_queue *q);
+void blk_freeze_queue_wait(struct request_queue *q);
+void blk_unfreeze_queue(struct request_queue *q);
static inline void blk_queue_enter_live(struct request_queue *q)
{
--
2.10.0
^ permalink raw reply related
* [PATCH 3/9] [RFC] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code
From: Bart Van Assche @ 2016-09-26 18:27 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Make nvme_requeue_req() check BLK_MQ_S_STOPPED instead of
QUEUE_FLAG_STOPPED. Remove the QUEUE_FLAG_STOPPED manipulations
that became superfluous because of this change. Untested.
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Cc: Keith Busch <keith.busch-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
---
drivers/nvme/host/core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bd2156c..057f1fa 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -205,7 +205,7 @@ void nvme_requeue_req(struct request *req)
blk_mq_requeue_request(req);
spin_lock_irqsave(req->q->queue_lock, flags);
- if (!blk_queue_stopped(req->q))
+ if (!blk_mq_queue_stopped(req->q))
blk_mq_kick_requeue_list(req->q);
spin_unlock_irqrestore(req->q->queue_lock, flags);
}
@@ -2082,10 +2082,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
mutex_lock(&ctrl->namespaces_mutex);
list_for_each_entry(ns, &ctrl->namespaces, list) {
- spin_lock_irq(ns->queue->queue_lock);
- queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue);
- spin_unlock_irq(ns->queue->queue_lock);
-
blk_mq_cancel_requeue_work(ns->queue);
blk_mq_stop_hw_queues(ns->queue);
}
@@ -2099,7 +2095,6 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
mutex_lock(&ctrl->namespaces_mutex);
list_for_each_entry(ns, &ctrl->namespaces, list) {
- queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue);
blk_mq_start_stopped_hw_queues(ns->queue, true);
blk_mq_kick_requeue_list(ns->queue);
}
--
2.10.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 2/9] dm: Fix a race condition related to stopping and starting queues
From: Bart Van Assche @ 2016-09-26 18:26 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc@sandisk.com>
Ensure that all ongoing dm_mq_queue_rq() and dm_mq_requeue_request()
calls have stopped before setting the "queue stopped" flag. This
allows to remove the "queue stopped" test from dm_mq_queue_rq() and
dm_mq_requeue_request(). This patch fixes a race condition because
dm_mq_queue_rq() is called without holding the queue lock and hence
BLK_MQ_S_STOPPED can be set at any time while dm_mq_queue_rq() is
in progress.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-rq.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 182b679..1b7a65e 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -116,9 +116,12 @@ static void dm_mq_stop_queue(struct request_queue *q)
queue_flag_set(QUEUE_FLAG_STOPPED, q);
spin_unlock_irqrestore(q->queue_lock, flags);
+ /* Wait until dm_mq_queue_rq() has finished. */
+ blk_quiesce_queue(q);
/* Avoid that requeuing could restart the queue. */
blk_mq_cancel_requeue_work(q);
blk_mq_stop_hw_queues(q);
+ blk_resume_queue(q);
}
void dm_stop_queue(struct request_queue *q)
@@ -901,17 +904,6 @@ static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
dm_put_live_table(md, srcu_idx);
}
- /*
- * On suspend dm_stop_queue() handles stopping the blk-mq
- * request_queue BUT: even though the hw_queues are marked
- * BLK_MQ_S_STOPPED at that point there is still a race that
- * is allowing block/blk-mq.c to call ->queue_rq against a
- * hctx that it really shouldn't. The following check guards
- * against this rarity (albeit _not_ race-free).
- */
- if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
- return BLK_MQ_RQ_QUEUE_BUSY;
-
if (ti->type->busy && ti->type->busy(ti))
return BLK_MQ_RQ_QUEUE_BUSY;
--
2.10.0
^ permalink raw reply related
* [PATCH 1/9] blk-mq: Introduce blk_mq_queue_stopped()
From: Bart Van Assche @ 2016-09-26 18:26 UTC (permalink / raw)
To: Jens Axboe
Cc: Christoph Hellwig, James Bottomley, Martin K. Petersen,
Mike Snitzer, Doug Ledford, Keith Busch,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <7948dbb8-6333-dc62-2673-4da35b4dfdbc-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
The function blk_queue_stopped() allows to test whether or not a
traditional request queue has been stopped. Introduce a helper
function that allows block drivers to query easily whether or not
one or more hardware contexts of a blk-mq queue have been stopped.
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Cc: Jens Axboe <axboe-b10kYP2dOMg@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
block/blk-mq.c | 20 ++++++++++++++++++++
include/linux/blk-mq.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e9ebe98..98d4812 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -938,6 +938,26 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async)
}
EXPORT_SYMBOL(blk_mq_run_hw_queues);
+/**
+ * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped
+ * @q: request queue.
+ *
+ * The caller is responsible for serializing this function against
+ * blk_mq_{start,stop}_hw_queue().
+ */
+bool blk_mq_queue_stopped(struct request_queue *q)
+{
+ struct blk_mq_hw_ctx *hctx;
+ int i;
+
+ queue_for_each_hw_ctx(q, hctx, i)
+ if (test_bit(BLK_MQ_S_STOPPED, &hctx->state))
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(blk_mq_queue_stopped);
+
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx)
{
cancel_work(&hctx->run_work);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 5daa0ef..368c460d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -233,6 +233,7 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs
void blk_mq_abort_requeue_list(struct request_queue *q);
void blk_mq_complete_request(struct request *rq, int error);
+bool blk_mq_queue_stopped(struct request_queue *q);
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);
void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx);
void blk_mq_stop_hw_queues(struct request_queue *q);
--
2.10.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox