Re: [RFC PATCH] blk-mq: move timeout handling from queue to tagset

2018-07-19 Thread jianchao.wang
Hi Keith On 07/19/2018 01:45 AM, Keith Busch wrote: >>> + list_for_each_entry(q, &set->tag_list, tag_set_list) { >>> /* >>> * Request timeouts are handled as a forward rolling timer. If >>> * we end up here it means that no requests are pending and >>> @@ -8

[PATCH 0/2] Fix silent data corruption in blkdev_direct_IO()

2018-07-19 Thread Martin Wilck
Hello Jens, Ming, Jan, and all others, the following patches have been verified by a customer to fix a silent data corruption which he has been seeing since "72ecad2 block: support a full bio worth of IO for simplified bdev direct-io". The patches are based on our observation that the corruption

[PATCH 1/2] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Martin Wilck
If the last page of the bio is not "full", the length of the last vector slot needs to be corrected. This slot has the index (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper array, which is shifted by the value of bio->bi_vcnt at function invocation, the correct index is (nr_pages

[PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
bio_iov_iter_get_pages() returns only pages for a single non-empty segment of the input iov_iter's iovec. This may be much less than the number of pages __blkdev_direct_IO_simple() is supposed to process. Call bio_iov_iter_get_pages() repeatedly until either the requested number of bytes is reached

Re: [PATCH 1/2] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Hannes Reinecke
On 07/19/2018 11:39 AM, Martin Wilck wrote: > If the last page of the bio is not "full", the length of the last > vector slot needs to be corrected. This slot has the index > (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper > array, which is shifted by the value of bio->bi_vcnt at

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Hannes Reinecke
On 07/19/2018 11:39 AM, Martin Wilck wrote: > bio_iov_iter_get_pages() returns only pages for a single non-empty > segment of the input iov_iter's iovec. This may be much less than the number > of pages __blkdev_direct_IO_simple() is supposed to process. Call > bio_iov_iter_get_pages() repeatedly u

Re: [PATCH 0/2] Fix silent data corruption in blkdev_direct_IO()

2018-07-19 Thread Hannes Reinecke
On 07/19/2018 11:39 AM, Martin Wilck wrote: > Hello Jens, Ming, Jan, and all others, > > the following patches have been verified by a customer to fix a silent data > corruption which he has been seeing since "72ecad2 block: support a full bio > worth of IO for simplified bdev direct-io". > > The

Re: [PATCH 1/2] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 5:39 PM, Martin Wilck wrote: > If the last page of the bio is not "full", the length of the last > vector slot needs to be corrected. This slot has the index > (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper > array, which is shifted by the value of bio->

Re: [PATCH 1/2] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Jan Kara
On Thu 19-07-18 11:39:17, Martin Wilck wrote: > If the last page of the bio is not "full", the length of the last > vector slot needs to be corrected. This slot has the index > (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper > array, which is shifted by the value of bio->bi_vcnt

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > bio_iov_iter_get_pages() returns only pages for a single non-empty > segment of the input iov_iter's iovec. This may be much less than the number > of pages __blkdev_direct_IO_simple() is supposed to process. Call In bio_iov_iter_get_

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 18:21:23, Ming Lei wrote: > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > segment of the input iov_iter's iovec. This may be much less than the number > > of pages __blkdev_direct_IO_simple()

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 11:39:18, Martin Wilck wrote: > bio_iov_iter_get_pages() returns only pages for a single non-empty > segment of the input iov_iter's iovec. This may be much less than the number > of pages __blkdev_direct_IO_simple() is supposed to process. Call > bio_iov_iter_get_pages() repeatedly

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 12:37:13PM +0200, Jan Kara wrote: > On Thu 19-07-18 18:21:23, Ming Lei wrote: > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > > segment of the input iov_iter's iovec. This may be m

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > bio_iov_iter_get_pages() returns only pages for a single non-empty > segment of the input iov_iter's iovec. This may be much less than the number > of pages __blkdev_direct_IO_simple() is supposed to process. Call > bio_iov_iter_get_pa

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Al Viro
On Thu, Jul 19, 2018 at 12:37:13PM +0200, Jan Kara wrote: > On Thu 19-07-18 18:21:23, Ming Lei wrote: > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > > segment of the input iov_iter's iovec. This may be m

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 19:04:46, Ming Lei wrote: > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > segment of the input iov_iter's iovec. This may be much less than the number > > of pages __blkdev_direct_IO_simple()

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 01:56:16PM +0200, Jan Kara wrote: > On Thu 19-07-18 19:04:46, Ming Lei wrote: > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > > segment of the input iov_iter's iovec. This may be m

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 12:45 +0200, Jan Kara wrote: > On Thu 19-07-18 11:39:18, Martin Wilck wrote: > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > segment of the input iov_iter's iovec. This may be much less than > > the number > > of pages __blkdev_direct_IO_simple() is

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 13:56 +0200, Jan Kara wrote: > On Thu 19-07-18 19:04:46, Ming Lei wrote: > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > bio_iov_iter_get_pages() returns only pages for a single non- > > > empty > > > segment of the input iov_iter's iovec. This may be m

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread h...@lst.de
On Wed, Jul 18, 2018 at 03:17:11PM -0600, Keith Busch wrote: > And there may be other drivers that don't want their completions > ignored, so breaking them again is also a step in the wrong direction. > > There are not that many blk-mq drivers, so we can go through them all. I think the point is

Re: [PATCH 0/2] Fix silent data corruption in blkdev_direct_IO()

2018-07-19 Thread Christoph Hellwig
Martin, please NEVER send a patch series as a reply to a previous thread. That makes it complete hell to find in the inbox.

Re: [PATCH 1/2] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Christoph Hellwig
On Thu, Jul 19, 2018 at 11:39:17AM +0200, Martin Wilck wrote: > If the last page of the bio is not "full", the length of the last > vector slot needs to be corrected. This slot has the index > (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper > array, which is shifted by the value

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Christoph Hellwig
On Thu, Jul 19, 2018 at 12:08:41PM +0100, Al Viro wrote: > > Well, there has never been a promise that it will grab *all* pages in the > > iter AFAIK. Practically, I think that it was just too hairy to implement in > > the macro magic that iter processing is... Al might know more (added to > > CC).

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread Keith Busch
On Thu, Jul 19, 2018 at 03:19:04PM +0200, h...@lst.de wrote: > On Wed, Jul 18, 2018 at 03:17:11PM -0600, Keith Busch wrote: > > And there may be other drivers that don't want their completions > > ignored, so breaking them again is also a step in the wrong direction. > > > > There are not that man

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 16:53:51, Christoph Hellwig wrote: > On Thu, Jul 19, 2018 at 12:08:41PM +0100, Al Viro wrote: > > > Well, there has never been a promise that it will grab *all* pages in the > > > iter AFAIK. Practically, I think that it was just too hairy to implement > > > in > > > the macro magi

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Christoph Hellwig
On Thu, Jul 19, 2018 at 05:06:42PM +0200, Jan Kara wrote: > Yeah. Actually previous version of the fix (not posted publicly) submitted > partial bio and then reused the bio to submit more. This is also the way > __blkdev_direct_IO operates. Martin optimized this to fill the bio > completely (as we

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 14:23:53, Martin Wilck wrote: > On Thu, 2018-07-19 at 12:45 +0200, Jan Kara wrote: > > Secondly, I don't think it is good to discard error from > > bio_iov_iter_get_pages() here and just submit partial IO. It will > > again > > lead to part of IO being done as direct and part attemp

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Jan Kara
On Thu 19-07-18 20:20:51, Ming Lei wrote: > On Thu, Jul 19, 2018 at 01:56:16PM +0200, Jan Kara wrote: > > On Thu 19-07-18 19:04:46, Ming Lei wrote: > > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > > bio_iov_iter_get_pages() returns only pages for a single non-empty > > > >

Re: [PATCH 2/3] block, scsi: Rework runtime power management

2018-07-19 Thread Bart Van Assche
On Thu, 2018-07-19 at 06:45 +0800, Ming Lei wrote: > So once blk_freeze_queue_start() returns, percpu_ref_is_zero() won't > return true only until the rcu confirmation is done. That means this > approach may not put device down. Hello Ming, I agree with your conclusion that it is not guaranteed t

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread Keith Busch
On Thu, Jul 19, 2018 at 08:59:31AM -0600, Keith Busch wrote: > > And we should never even hit the timeout handler for those as it > > is rather pointless (although it looks we currently do..). > > I don't see why we'd expect to never hit timeout for at least some of > these. It's not a stretch to

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread Bart Van Assche
On Thu, 2018-07-19 at 09:56 -0600, Keith Busch wrote: > Even some scsi drivers are susceptible to losing their requests with the > reverted behavior: take virtio-scsi for example, which returns RESET_TIMER > from it's timeout handler. With the behavior everyone seems to want, > a natural completion

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread Keith Busch
On Thu, Jul 19, 2018 at 04:04:46PM +, Bart Van Assche wrote: > On Thu, 2018-07-19 at 09:56 -0600, Keith Busch wrote: > > Even some scsi drivers are susceptible to losing their requests with the > > reverted behavior: take virtio-scsi for example, which returns RESET_TIMER > > from it's timeout

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread h...@lst.de
On Thu, Jul 19, 2018 at 10:22:40AM -0600, Keith Busch wrote: > On Thu, Jul 19, 2018 at 04:04:46PM +, Bart Van Assche wrote: > > On Thu, 2018-07-19 at 09:56 -0600, Keith Busch wrote: > > > Even some scsi drivers are susceptible to losing their requests with the > > > reverted behavior: take virt

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 17:21 +0200, Jan Kara wrote: > On Thu 19-07-18 20:20:51, Ming Lei wrote: > > On Thu, Jul 19, 2018 at 01:56:16PM +0200, Jan Kara wrote: > > > On Thu 19-07-18 19:04:46, Ming Lei wrote: > > > > On Thu, Jul 19, 2018 at 11:39:18AM +0200, Martin Wilck wrote: > > > > > bio_iov_iter_g

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 17:11 +0200, Christoph Hellwig wrote: > On Thu, Jul 19, 2018 at 05:06:42PM +0200, Jan Kara wrote: > > Yeah. Actually previous version of the fix (not posted publicly) > > submitted > > partial bio and then reused the bio to submit more. This is also > > the way > > __blkdev_di

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 16:53 +0200, Christoph Hellwig wrote: > On Thu, Jul 19, 2018 at 12:08:41PM +0100, Al Viro wrote: > > > Well, there has never been a promise that it will grab *all* > > > pages in the > > > iter AFAIK. Practically, I think that it was just too hairy to > > > implement in > > >

Re: [PATCH 2/2] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
On Thu, 2018-07-19 at 17:15 +0200, Jan Kara wrote: > On Thu 19-07-18 14:23:53, Martin Wilck wrote: > > On Thu, 2018-07-19 at 12:45 +0200, Jan Kara wrote: > > > Secondly, I don't think it is good to discard error from > > > bio_iov_iter_get_pages() here and just submit partial IO. It will > > > agai

Re: [RFC PATCH 3/3] blk-mq: Remove generation seqeunce

2018-07-19 Thread Keith Busch
On Thu, Jul 19, 2018 at 06:29:24PM +0200, h...@lst.de wrote: > How do we get a fix into 4.18 at this part of the cycle? I think that > is the most important prirority right now. Even if you were okay at this point to incorporate the concepts from Bart's patch, it still looks like trouble for scsi

[PATCH v3 3/3] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Martin Wilck
When bio_iov_iter_get_pages() is called from __blkdev_direct_IO_simple(), we already know that the content of the input iov_iter fits into a single bio, so we expect iov_iter_count(iter) to drop to 0. But in a single invocation, bio_iov_iter_get_pages() may add less bytes then we expect. For iov_i

[PATCH v3 2/3] blkdev: __blkdev_direct_IO_simple: fix leak in error case

2018-07-19 Thread Martin Wilck
Fixes: 72ecad22d9f1 ("block: support a full bio worth of IO for simplified bdev direct-io") Signed-off-by: Martin Wilck --- fs/block_dev.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 0dd87aa..aba2541 100644 --- a/fs/block_dev

[PATCH v3 0/3] Fix silent data corruption in blkdev_direct_IO()

2018-07-19 Thread Martin Wilck
Hello Jens, Ming, Jan, and all others, the following patches have been verified by a customer to fix a silent data corruption which he has been seeing since "72ecad2 block: support a full bio worth of IO for simplified bdev direct-io". The patches are based on our observation that the corruption

[PATCH v3 1/3] block: bio_iov_iter_get_pages: fix size of last iovec

2018-07-19 Thread Martin Wilck
If the last page of the bio is not "full", the length of the last vector slot needs to be corrected. This slot has the index (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper array, which is shifted by the value of bio->bi_vcnt at function invocation, the correct index is (nr_pages

Re: [PATCH 2/3] block, scsi: Rework runtime power management

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 03:54:53PM +, Bart Van Assche wrote: > On Thu, 2018-07-19 at 06:45 +0800, Ming Lei wrote: > > So once blk_freeze_queue_start() returns, percpu_ref_is_zero() won't > > return true only until the rcu confirmation is done. That means this > > approach may not put device dow

[PATCH] blk-rq-qos: make depth comparisons unsigned

2018-07-19 Thread Josef Bacik
With the change to use UINT_MAX I broke the depth check as any value of inflight (ie 0) would be less than (int)UINT_MAX. Fix this by changing everything to unsigned int to match the depth. Signed-off-by: Josef Bacik --- block/blk-rq-qos.c | 8 block/blk-rq-qos.h | 2 +- 2 files change

Re: [PATCH v3 2/3] blkdev: __blkdev_direct_IO_simple: fix leak in error case

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 11:01:57PM +0200, Martin Wilck wrote: > Fixes: 72ecad22d9f1 ("block: support a full bio worth of IO for simplified > bdev direct-io") > Signed-off-by: Martin Wilck > --- > fs/block_dev.c | 9 + > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/fs

Re: [PATCH v3 3/3] blkdev: __blkdev_direct_IO_simple: make sure to fill up the bio

2018-07-19 Thread Ming Lei
On Thu, Jul 19, 2018 at 11:01:58PM +0200, Martin Wilck wrote: > When bio_iov_iter_get_pages() is called from __blkdev_direct_IO_simple(), > we already know that the content of the input iov_iter fits into a single > bio, so we expect iov_iter_count(iter) to drop to 0. But in a single > invocation