diff mbox series

Question Regarding Optional ->prepare_read Callback in NETFS

Message ID CALGdzuomL+AACikTfBYBU4nCMXGU-eRvSYwdY-b_6n0mUekBOg@mail.gmail.com (mailing list archive)
State New
Headers show
Series Question Regarding Optional ->prepare_read Callback in NETFS | expand

Commit Message

Chenyuan Yang April 12, 2025, 7:07 p.m. UTC
Dear NETFS Developers,

I am writing to clarify whether the ->prepare_read callback can be
NULL for a backing filesystem that does not supply it. In particular,
should we assume that the pointer may be NULL and thus require an
explicit check before invoking it?

For context, commit 904abff4b1b9 ("netfs: Fix read-retry for fs with
no ->prepare_read()") introduced a similar check in the read-retry
path. I am proposing that we apply the same consideration to the code
in netfs_single_cache_prepare_read. Here is the relevant patch snippet
for reference:

 fs/netfs/read_single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

  }

Could you please confirm if this is the intended design, or if any
adjustments are needed?

Thank you for your time and assistance.

Best regards,
Chenyuan
diff mbox series

Patch

diff --git a/fs/netfs/read_single.c b/fs/netfs/read_single.c
index fea0ecdecc53..68a5ff1c3d06 100644
--- a/fs/netfs/read_single.c
+++ b/fs/netfs/read_single.c
@@ -63,7 +63,7 @@  static void netfs_single_cache_prepare_read(struct
netfs_io_request *rreq,
 {
  struct netfs_cache_resources *cres = &rreq->cache_resources;

- if (!cres->ops) {
+ if (!cres->ops || !cres->ops->prepare_read) {
  subreq->source = NETFS_DOWNLOAD_FROM_SERVER;
  return;