Commit a023127a authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Eliminate function calls in DIO fastpaths

We can assume that usually buffered and O_DIRECT IO won't be mixed, and
the calls to flush the page cache won't be needed.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 54847d25
...@@ -77,7 +77,7 @@ struct dio_read { ...@@ -77,7 +77,7 @@ struct dio_read {
}; };
/* pagecache_block must be held */ /* pagecache_block must be held */
static int write_invalidate_inode_pages_range(struct address_space *mapping, static noinline int write_invalidate_inode_pages_range(struct address_space *mapping,
loff_t start, loff_t end) loff_t start, loff_t end)
{ {
int ret; int ret;
...@@ -1693,11 +1693,13 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter) ...@@ -1693,11 +1693,13 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter)
if (iocb->ki_flags & IOCB_DIRECT) { if (iocb->ki_flags & IOCB_DIRECT) {
struct blk_plug plug; struct blk_plug plug;
ret = filemap_write_and_wait_range(mapping, if (unlikely(mapping->nrpages)) {
iocb->ki_pos, ret = filemap_write_and_wait_range(mapping,
iocb->ki_pos + count - 1); iocb->ki_pos,
if (ret < 0) iocb->ki_pos + count - 1);
return ret; if (ret < 0)
return ret;
}
file_accessed(file); file_accessed(file);
...@@ -1961,11 +1963,13 @@ ssize_t bch2_direct_write(struct kiocb *req, struct iov_iter *iter) ...@@ -1961,11 +1963,13 @@ ssize_t bch2_direct_write(struct kiocb *req, struct iov_iter *iter)
dio->op.opts.data_replicas)) dio->op.opts.data_replicas))
goto err_put_bio; goto err_put_bio;
ret = write_invalidate_inode_pages_range(mapping, if (unlikely(mapping->nrpages)) {
req->ki_pos, ret = write_invalidate_inode_pages_range(mapping,
req->ki_pos + iter->count - 1); req->ki_pos,
if (unlikely(ret)) req->ki_pos + iter->count - 1);
goto err_put_bio; if (unlikely(ret))
goto err_put_bio;
}
ret = bch2_dio_write_loop(dio); ret = bch2_dio_write_loop(dio);
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment