From: Alan Huang <mmpgouride@gmail.com>
To: kent.overstreet@linux.dev
Cc: linux-bcachefs@vger.kernel.org, Alan Huang <mmpgouride@gmail.com>
Subject: [PATCH 1/3] bcachefs: Introduce bch2_splice_read
Date: Fri, 8 Aug 2025 21:43:10 +0800 [thread overview]
Message-ID: <20250808134312.878432-1-mmpgouride@gmail.com> (raw)
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
next reply other threads:[~2025-08-08 13:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 13:43 Alan Huang [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250808134312.878432-1-mmpgouride@gmail.com \
--to=mmpgouride@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).