]> git.karo-electronics.de Git - linux-beck.git/commitdiff
block_dev: Fixed direct I/O bio sector calculation
authorDamien Le Moal <damien.lemoal@wdc.com>
Tue, 22 Nov 2016 06:38:49 +0000 (15:38 +0900)
committerJens Axboe <axboe@fb.com>
Tue, 22 Nov 2016 15:09:09 +0000 (08:09 -0700)
A direct I/O alignment must be always checked against the device blocks size,
but the I/O offset (bio->bi_iter.bi_sector must always use 512B sector unit, and
not the actual logical block size.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/block_dev.c

index 35cc494f2e1a086cbcab9681bb6b2bfd8955df8a..e49fb797e44763706a5817ff471cad0ef4bcbba9 100644 (file)
@@ -226,7 +226,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
        bio.bi_max_vecs = nr_pages;
        bio.bi_io_vec = vecs;
        bio.bi_bdev = bdev;
-       bio.bi_iter.bi_sector = pos >> blkbits;
+       bio.bi_iter.bi_sector = pos >> 9;
        bio.bi_private = current;
        bio.bi_end_io = blkdev_bio_end_io_simple;
 
@@ -358,7 +358,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 
        for (;;) {
                bio->bi_bdev = bdev;
-               bio->bi_iter.bi_sector = pos >> blkbits;
+               bio->bi_iter.bi_sector = pos >> 9;
                bio->bi_private = dio;
                bio->bi_end_io = blkdev_bio_end_io;