aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandan Rajendra <chandan@linux.vnet.ibm.com>2017-01-10 15:29:54 -0500
committerJens Axboe <axboe@fb.com>2017-01-10 15:29:54 -0500
commitdd545b52a3e1efd9f2c6352dbe95ccd0c53461cc (patch)
treee60b234f4d912a7d8f0e7a8f248233cd263b3e23
parenta121103c922847ba5010819a3f250f1f7fc84ab8 (diff)
do_direct_IO: Use inode->i_blkbits to compute block count to be cleaned
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> Reviewed-by: Christoph Hellwig <hch@lst.de> Fixed up by Jeff Moyer to only use/evaluate inode->i_blkbits once, to avoid issues with block size changes with IO in flight. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--fs/direct-io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index aeae8c063451..c87bae4376b8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -906,6 +906,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
906 struct buffer_head *map_bh) 906 struct buffer_head *map_bh)
907{ 907{
908 const unsigned blkbits = sdio->blkbits; 908 const unsigned blkbits = sdio->blkbits;
909 const unsigned i_blkbits = blkbits + sdio->blkfactor;
909 int ret = 0; 910 int ret = 0;
910 911
911 while (sdio->block_in_file < sdio->final_block_in_request) { 912 while (sdio->block_in_file < sdio->final_block_in_request) {
@@ -949,7 +950,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
949 clean_bdev_aliases( 950 clean_bdev_aliases(
950 map_bh->b_bdev, 951 map_bh->b_bdev,
951 map_bh->b_blocknr, 952 map_bh->b_blocknr,
952 map_bh->b_size >> blkbits); 953 map_bh->b_size >> i_blkbits);
953 } 954 }
954 955
955 if (!sdio->blkfactor) 956 if (!sdio->blkfactor)