linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] bcachefs: Introduce bch2_splice_read
@ 2025-08-08 13:43 Alan Huang
  2025-08-08 13:43 ` [PATCH 2/3] bcachefs: Use our own splice_read implementation Alan Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alan Huang @ 2025-08-08 13:43 UTC (permalink / raw)
  To: kent.overstreet; +Cc: linux-bcachefs, Alan Huang

This provides our own splice read, which locks ei_pagecache_lock around
filemap_splice_read.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
 fs/bcachefs/fs-io-buffered.c | 12 ++++++++++++
 fs/bcachefs/fs-io-buffered.h |  4 ++++
 2 files changed, 16 insertions(+)

diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c
index fd8beb5167ee..c16c45a72c47 100644
--- a/fs/bcachefs/fs-io-buffered.c
+++ b/fs/bcachefs/fs-io-buffered.c
@@ -1100,6 +1100,18 @@ ssize_t bch2_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	return bch2_err_class(ret);
 }
 
+ssize_t bch2_splice_read(struct file *in, loff_t *ppos,
+			 struct pipe_inode_info *pipe,
+			 size_t len, unsigned int flags)
+{
+	ssize_t ret;
+	struct bch_inode_info *inode = to_bch_ei(in->f_mapping->host);
+	bch2_pagecache_add_get(inode);
+	ret = filemap_splice_read(in, ppos, pipe, len, flags);
+	bch2_pagecache_add_put(inode);
+	return ret;
+}
+
 void bch2_fs_fs_io_buffered_exit(struct bch_fs *c)
 {
 	bioset_exit(&c->writepage_bioset);
diff --git a/fs/bcachefs/fs-io-buffered.h b/fs/bcachefs/fs-io-buffered.h
index 3207ebbb4ab4..3bcbf62ad420 100644
--- a/fs/bcachefs/fs-io-buffered.h
+++ b/fs/bcachefs/fs-io-buffered.h
@@ -17,6 +17,10 @@ int bch2_write_end(struct file *, struct address_space *, loff_t,
 
 ssize_t bch2_write_iter(struct kiocb *, struct iov_iter *);
 
+ssize_t bch2_splice_read(struct file *in, loff_t *ppos,
+			 struct pipe_inode_info *pipe,
+			 size_t len, unsigned int flags);
+
 void bch2_fs_fs_io_buffered_exit(struct bch_fs *);
 int bch2_fs_fs_io_buffered_init(struct bch_fs *);
 #else
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-08 18:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 13:43 [PATCH 1/3] bcachefs: Introduce bch2_splice_read Alan Huang
2025-08-08 13:43 ` [PATCH 2/3] bcachefs: Use our own splice_read implementation Alan Huang
2025-08-08 13:43 ` [PATCH 3/3] bcachefs: Don't lock ei_pagecache_lock in bch2_readahead Alan Huang
2025-08-08 18:28 ` [PATCH 1/3] bcachefs: Introduce bch2_splice_read Kent Overstreet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).