aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs-io-direct.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/fs-io-direct.c')
-rw-r--r--fs/bcachefs/fs-io-direct.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io-direct.c b/fs/bcachefs/fs-io-direct.c
index e3b219e19e10..33cb6da3a5ad 100644
--- a/fs/bcachefs/fs-io-direct.c
+++ b/fs/bcachefs/fs-io-direct.c
@@ -88,6 +88,8 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter)
return ret;
shorten = iov_iter_count(iter) - round_up(ret, block_bytes(c));
+ if (shorten >= iter->count)
+ shorten = 0;
iter->count -= shorten;
bio = bio_alloc_bioset(NULL,