Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1553887 > unrolled thread

[PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned

Started byChandan Rajendra <chandan@linux.vnet.ibm.com>
First post2017-01-08 15:50 +0100
Last post2017-01-10 21:40 +0100
Articles 9 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned Chandan Rajendra <chandan@linux.vnet.ibm.com> - 2017-01-08 15:50 +0100
    Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block  count to be cleaned Christoph Hellwig <hch@infradead.org> - 2017-01-09 15:00 +0100
    Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count  to be cleaned Jens Axboe <axboe@kernel.dk> - 2017-01-09 16:40 +0100
    Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned Jeff Moyer <jmoyer@redhat.com> - 2017-01-09 17:10 +0100
    Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block  count to be cleaned Jan Kara <jack@suse.cz> - 2017-01-09 21:30 +0100
    Re: [PATCH] direct-io: don't introduce another read of  inode->i_blkbits Jens Axboe <axboe@kernel.dk> - 2017-01-09 22:50 +0100
    [PATCH] direct-io: don't introduce another read of inode->i_blkbits Jeff Moyer <jmoyer@redhat.com> - 2017-01-09 22:50 +0100
      Re: [PATCH] direct-io: don't introduce another read of inode->i_blkbits Chandan Rajendra <chandan@linux.vnet.ibm.com> - 2017-01-10 06:30 +0100
        Re: [PATCH] direct-io: don't introduce another read of  inode->i_blkbits Jens Axboe <axboe@kernel.dk> - 2017-01-10 21:40 +0100

#1553887 — [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned

FromChandan Rajendra <chandan@linux.vnet.ibm.com>
Date2017-01-08 15:50 +0100
Subject[PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
Message-ID<sXmXf-7DZ-5@gated-at.bofh.it>
The code currently uses sdio->blkbits to compute the number of blocks to
be cleaned. However sdio->blkbits is derived from the logical block size
of the underlying block device (Refer to the definition of
do_blockdev_direct_IO()). Due to this, generic/299 test would rarely
fail when executed on an ext4 filesystem with 64k as the block size and
when using a virtio based disk (having 512 byte as the logical block
size) inside a kvm guest.

This commit fixes the bug by using inode->i_blkbits to compute the
number of blocks to be cleaned.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 fs/direct-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index aeae8c0..b20adf9 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -905,6 +905,7 @@ static inline void dio_zero_block(struct dio *dio, struct dio_submit *sdio,
 static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
 			struct buffer_head *map_bh)
 {
+	const unsigned i_blkbits = dio->inode->i_blkbits;
 	const unsigned blkbits = sdio->blkbits;
 	int ret = 0;
 
@@ -949,7 +950,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
 					clean_bdev_aliases(
 						map_bh->b_bdev,
 						map_bh->b_blocknr,
-						map_bh->b_size >> blkbits);
+						map_bh->b_size >> i_blkbits);
 				}
 
 				if (!sdio->blkfactor)
-- 
2.5.5

[toc] | [next] | [standalone]


#1554355 — Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned

FromChristoph Hellwig <hch@infradead.org>
Date2017-01-09 15:00 +0100
SubjectRe: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
Message-ID<sXIEp-4UO-5@gated-at.bofh.it>
In reply to#1553887
On Sun, Jan 08, 2017 at 08:17:10PM +0530, Chandan Rajendra wrote:
> The code currently uses sdio->blkbits to compute the number of blocks to
> be cleaned. However sdio->blkbits is derived from the logical block size
> of the underlying block device (Refer to the definition of
> do_blockdev_direct_IO()). Due to this, generic/299 test would rarely
> fail when executed on an ext4 filesystem with 64k as the block size and
> when using a virtio based disk (having 512 byte as the logical block
> size) inside a kvm guest.
> 
> This commit fixes the bug by using inode->i_blkbits to compute the
> number of blocks to be cleaned.

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [next] | [standalone]


#1554423 — Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned

FromJens Axboe <axboe@kernel.dk>
Date2017-01-09 16:40 +0100
SubjectRe: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
Message-ID<sXKdb-5VJ-21@gated-at.bofh.it>
In reply to#1553887
On 01/08/2017 07:47 AM, Chandan Rajendra wrote:
> The code currently uses sdio->blkbits to compute the number of blocks to
> be cleaned. However sdio->blkbits is derived from the logical block size
> of the underlying block device (Refer to the definition of
> do_blockdev_direct_IO()). Due to this, generic/299 test would rarely
> fail when executed on an ext4 filesystem with 64k as the block size and
> when using a virtio based disk (having 512 byte as the logical block
> size) inside a kvm guest.
> 
> This commit fixes the bug by using inode->i_blkbits to compute the
> number of blocks to be cleaned.

Thanks, added for 4.10.

-- 
Jens Axboe

[toc] | [prev] | [next] | [standalone]


#1554446

FromJeff Moyer <jmoyer@redhat.com>
Date2017-01-09 17:10 +0100
Message-ID<sXKGe-6kS-27@gated-at.bofh.it>
In reply to#1553887
Chandan Rajendra <chandan@linux.vnet.ibm.com> writes:

> The code currently uses sdio->blkbits to compute the number of blocks to
> be cleaned. However sdio->blkbits is derived from the logical block size
> of the underlying block device (Refer to the definition of
> do_blockdev_direct_IO()). Due to this, generic/299 test would rarely
> fail when executed on an ext4 filesystem with 64k as the block size and
> when using a virtio based disk (having 512 byte as the logical block
> size) inside a kvm guest.
>
> This commit fixes the bug by using inode->i_blkbits to compute the
> number of blocks to be cleaned.
>
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> ---
>  fs/direct-io.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index aeae8c0..b20adf9 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -905,6 +905,7 @@ static inline void dio_zero_block(struct dio *dio, struct dio_submit *sdio,
>  static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>  			struct buffer_head *map_bh)
>  {
> +	const unsigned i_blkbits = dio->inode->i_blkbits;

NAK.  Please see commit ab73857e354 ("direct-io: don't read
inode->i_blkbits multiple times").

I think you want:

	const unsigned i_blkbits = sdio->blkbits + sdio->blkfactor;

as is used elsewhere in the code.

Cheers,
Jeff

[toc] | [prev] | [next] | [standalone]


#1554685 — Re: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned

FromJan Kara <jack@suse.cz>
Date2017-01-09 21:30 +0100
SubjectRe: [PATCH] do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
Message-ID<sXOJQ-jZ-37@gated-at.bofh.it>
In reply to#1553887
On Sun 08-01-17 20:17:10, Chandan Rajendra wrote:
> The code currently uses sdio->blkbits to compute the number of blocks to
> be cleaned. However sdio->blkbits is derived from the logical block size
> of the underlying block device (Refer to the definition of
> do_blockdev_direct_IO()). Due to this, generic/299 test would rarely
> fail when executed on an ext4 filesystem with 64k as the block size and
> when using a virtio based disk (having 512 byte as the logical block
> size) inside a kvm guest.
> 
> This commit fixes the bug by using inode->i_blkbits to compute the
> number of blocks to be cleaned.

Ah, good catch. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> ---
>  fs/direct-io.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index aeae8c0..b20adf9 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -905,6 +905,7 @@ static inline void dio_zero_block(struct dio *dio, struct dio_submit *sdio,
>  static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>  			struct buffer_head *map_bh)
>  {
> +	const unsigned i_blkbits = dio->inode->i_blkbits;
>  	const unsigned blkbits = sdio->blkbits;
>  	int ret = 0;
>  
> @@ -949,7 +950,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>  					clean_bdev_aliases(
>  						map_bh->b_bdev,
>  						map_bh->b_blocknr,
> -						map_bh->b_size >> blkbits);
> +						map_bh->b_size >> i_blkbits);
>  				}
>  
>  				if (!sdio->blkfactor)
> -- 
> 2.5.5
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[toc] | [prev] | [next] | [standalone]


#1554733 — Re: [PATCH] direct-io: don't introduce another read of inode->i_blkbits

FromJens Axboe <axboe@kernel.dk>
Date2017-01-09 22:50 +0100
SubjectRe: [PATCH] direct-io: don't introduce another read of inode->i_blkbits
Message-ID<sXPZf-ZK-5@gated-at.bofh.it>
In reply to#1553887
On 01/09/2017 02:42 PM, Jeff Moyer wrote:
> Commit 20ce44d545844 ("do_direct_IO: Use inode->i_blkbits to compute
> block count to be cleaned") introduced a regression: if the block size
> of the block device is changed while a direct I/O request is being
> setup, it can result in a panic.  See commit ab73857e354ab ("direct-io:
> don't read inode->i_blkbits multiple times") for the reasoning, and
> commit b87570f5d3496 ("Fix a crash when block device is read and block
> size is changed at the same time") for a more detailed problem
> description and reproducer.
> 
> Fixes: 20ce44d545844
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
> 
> ---
> Chandan, can you please test this to ensure this still fixes your problem?

Please, that would be great. And if so, then let's fold the two.

-- 
Jens Axboe

[toc] | [prev] | [next] | [standalone]


#1554738 — [PATCH] direct-io: don't introduce another read of inode->i_blkbits

FromJeff Moyer <jmoyer@redhat.com>
Date2017-01-09 22:50 +0100
Subject[PATCH] direct-io: don't introduce another read of inode->i_blkbits
Message-ID<sXPZf-ZK-7@gated-at.bofh.it>
In reply to#1553887
Commit 20ce44d545844 ("do_direct_IO: Use inode->i_blkbits to compute
block count to be cleaned") introduced a regression: if the block size
of the block device is changed while a direct I/O request is being
setup, it can result in a panic.  See commit ab73857e354ab ("direct-io:
don't read inode->i_blkbits multiple times") for the reasoning, and
commit b87570f5d3496 ("Fix a crash when block device is read and block
size is changed at the same time") for a more detailed problem
description and reproducer.

Fixes: 20ce44d545844
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

---
Chandan, can you please test this to ensure this still fixes your problem?

diff --git a/fs/direct-io.c b/fs/direct-io.c
index b20adf9..c87bae4 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -905,8 +905,8 @@ static inline void dio_zero_block(struct dio *dio, struct dio_submit *sdio,
 static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
 			struct buffer_head *map_bh)
 {
-	const unsigned i_blkbits = dio->inode->i_blkbits;
 	const unsigned blkbits = sdio->blkbits;
+	const unsigned i_blkbits = blkbits + sdio->blkfactor;
 	int ret = 0;
 
 	while (sdio->block_in_file < sdio->final_block_in_request) {

[toc] | [prev] | [next] | [standalone]


#1554928 — Re: [PATCH] direct-io: don't introduce another read of inode->i_blkbits

FromChandan Rajendra <chandan@linux.vnet.ibm.com>
Date2017-01-10 06:30 +0100
SubjectRe: [PATCH] direct-io: don't introduce another read of inode->i_blkbits
Message-ID<sXXap-5IN-7@gated-at.bofh.it>
In reply to#1554738
On Monday, January 09, 2017 04:42:58 PM Jeff Moyer wrote:
> Commit 20ce44d545844 ("do_direct_IO: Use inode->i_blkbits to compute
> block count to be cleaned") introduced a regression: if the block size
> of the block device is changed while a direct I/O request is being
> setup, it can result in a panic.  See commit ab73857e354ab ("direct-io:
> don't read inode->i_blkbits multiple times") for the reasoning, and
> commit b87570f5d3496 ("Fix a crash when block device is read and block
> size is changed at the same time") for a more detailed problem
> description and reproducer.
> 
> Fixes: 20ce44d545844
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
> 
> ---
> Chandan, can you please test this to ensure this still fixes your problem?

This patch fixes the failure,

Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>

-- 
chandan

[toc] | [prev] | [next] | [standalone]


#1555905 — Re: [PATCH] direct-io: don't introduce another read of inode->i_blkbits

FromJens Axboe <axboe@kernel.dk>
Date2017-01-10 21:40 +0100
SubjectRe: [PATCH] direct-io: don't introduce another read of inode->i_blkbits
Message-ID<sYbn3-5V0-17@gated-at.bofh.it>
In reply to#1554928
On 01/09/2017 10:27 PM, Chandan Rajendra wrote:
> On Monday, January 09, 2017 04:42:58 PM Jeff Moyer wrote:
>> Commit 20ce44d545844 ("do_direct_IO: Use inode->i_blkbits to compute
>> block count to be cleaned") introduced a regression: if the block size
>> of the block device is changed while a direct I/O request is being
>> setup, it can result in a panic.  See commit ab73857e354ab ("direct-io:
>> don't read inode->i_blkbits multiple times") for the reasoning, and
>> commit b87570f5d3496 ("Fix a crash when block device is read and block
>> size is changed at the same time") for a more detailed problem
>> description and reproducer.
>>
>> Fixes: 20ce44d545844
>> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
>>
>> ---
>> Chandan, can you please test this to ensure this still fixes your problem?
> 
> This patch fixes the failure,
> 
> Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> 

I've updated the patch, thanks guys.

-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web