splice_read will read file data to the page cache, to prevent cache
coherency issure from happening, we need to lock ei_pagecache_lock
around it. Therefore, use our own splice_read implementation.

This also solves one deadlock issue, which locks the folio first when
bch2_readahead is invoked from splice_read path, but fail to lock
ei_pagecache_lock, which was already locked by the direct I/O path
or fallocate path, when the DIO path tries to invalidate the page cache,
a deadlock happens.

Signed-off-by: Alan Huang <[email protected]>
---
 fs/bcachefs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 0425238a83ee..6d8830345538 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1716,7 +1716,7 @@ static const struct file_operations bch_file_operations = 
{
        .mmap           = bch2_mmap,
        .get_unmapped_area = thp_get_unmapped_area,
        .fsync          = bch2_fsync,
-       .splice_read    = filemap_splice_read,
+       .splice_read    = bch2_splice_read,
        .splice_write   = iter_file_splice_write,
        .fallocate      = bch2_fallocate_dispatch,
        .unlocked_ioctl = bch2_fs_file_ioctl,
-- 
2.49.0


Reply via email to