2024-04-25 09:19:59

by Youling Tang

[permalink] [raw]
Subject: [PATCH] bcachefs: Use filemap_read() to simplify the execution flow

From: Youling Tang <[email protected]>

Using filemap_read() can reduce unnecessary code execution
for non IOCB_DIRECT paths.

Signed-off-by: Youling Tang <[email protected]>
---
fs/bcachefs/fs-io-direct.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/fs-io-direct.c b/fs/bcachefs/fs-io-direct.c
index 09d21aef879a..4072a6ba0d51 100644
--- a/fs/bcachefs/fs-io-direct.c
+++ b/fs/bcachefs/fs-io-direct.c
@@ -179,7 +179,7 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter)
struct bch_inode_info *inode = file_bch_inode(file);
struct address_space *mapping = file->f_mapping;
size_t count = iov_iter_count(iter);
- ssize_t ret;
+ ssize_t ret = 0;

if (!count)
return 0; /* skip atime */
@@ -205,7 +205,7 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter)
iocb->ki_pos += ret;
} else {
bch2_pagecache_add_get(inode);
- ret = generic_file_read_iter(iocb, iter);
+ ret = filemap_read(iocb, iter, ret);
bch2_pagecache_add_put(inode);
}
out:
--
2.34.1