]> git.baikalelectronics.ru Git - kernel.git/commit
block: Fix __blkdev_direct_IO() for bio fragments
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 1 Aug 2019 10:21:51 +0000 (19:21 +0900)
committerJens Axboe <axboe@kernel.dk>
Thu, 1 Aug 2019 19:51:18 +0000 (13:51 -0600)
commit83fda0553a2740d27611ba9b17b78d7a7f469709
tree154f2d35d99a33fb052046358f9e6e1586b6e8f6
parentac235b1530bddc3a688baebfc9ed9d985c129b5f
block: Fix __blkdev_direct_IO() for bio fragments

The recent fix to properly handle IOCB_NOWAIT for async O_DIRECT IO
(patch b0485bcfa05b) introduced two problems with BIO fragment handling
for direct IOs:
1) The dio size processed is calculated by incrementing the ret variable
by the size of the bio fragment issued for the dio. However, this size
is obtained directly from bio->bi_iter.bi_size AFTER the bio submission
which may result in referencing the bi_size value after the bio
completed, resulting in an incorrect value use.
2) The ret variable is not incremented by the size of the last bio
fragment issued for the bio, leading to an invalid IO size being
returned to the user.

Fix both problem by using dio->size (which is incremented before the bio
submission) to update the value of ret after bio submissions, including
for the last bio fragment issued.

Fixes: b0485bcfa05b ("block: properly handle IOCB_NOWAIT for async O_DIRECT IO")
Reported-by: Masato Suzuki <masato.suzuki@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/block_dev.c