linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Eric Van Hensbergen <ericvh@gmail.com>,
	Latchesar Ionkov <lucho@ionkov.net>,
	Dominique Martinet <asmadeus@codewreck.org>,
	v9fs-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: [PATCH] fs: 9p: add generic splice_read file operations
Date: Tue,  1 Dec 2020 14:54:09 +0100	[thread overview]
Message-ID: <20201201135409.55510-1-toke@redhat.com> (raw)

The v9fs file operations were missing the splice_read operations, which
breaks sendfile() of files on such a filesystem. I discovered this while
trying to load an eBPF program using iproute2 inside a 'virtme' environment
which uses 9pfs for the virtual file system. iproute2 relies on sendfile()
with an AF_ALG socket to hash files, which was erroring out in the virtual
environment.

Since generic_file_splice_read() seems to just implement splice_read in
terms of the read_iter operation, I simply added the generic implementation
to the file operations, which fixed the error I was seeing. A quick grep
indicates that this is what most other file systems do as well.

The only caveat is that my test case was only hitting the
v9fs_file_operations_dotl implementation. I added it to the other file
operations structs as well because it seemed like the sensible thing to do
given that they all implement read_iter, but those are only compile tested.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 fs/9p/vfs_file.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index b177fd3b1eb3..01026b47018c 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -655,6 +655,7 @@ const struct file_operations v9fs_cached_file_operations = {
 	.release = v9fs_dir_release,
 	.lock = v9fs_file_lock,
 	.mmap = v9fs_file_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync,
 };
 
@@ -667,6 +668,7 @@ const struct file_operations v9fs_cached_file_operations_dotl = {
 	.lock = v9fs_file_lock_dotl,
 	.flock = v9fs_file_flock_dotl,
 	.mmap = v9fs_file_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync_dotl,
 };
 
@@ -678,6 +680,7 @@ const struct file_operations v9fs_file_operations = {
 	.release = v9fs_dir_release,
 	.lock = v9fs_file_lock,
 	.mmap = generic_file_readonly_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync,
 };
 
@@ -690,6 +693,7 @@ const struct file_operations v9fs_file_operations_dotl = {
 	.lock = v9fs_file_lock_dotl,
 	.flock = v9fs_file_flock_dotl,
 	.mmap = generic_file_readonly_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync_dotl,
 };
 
@@ -701,6 +705,7 @@ const struct file_operations v9fs_mmap_file_operations = {
 	.release = v9fs_dir_release,
 	.lock = v9fs_file_lock,
 	.mmap = v9fs_mmap_file_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync,
 };
 
@@ -713,5 +718,6 @@ const struct file_operations v9fs_mmap_file_operations_dotl = {
 	.lock = v9fs_file_lock_dotl,
 	.flock = v9fs_file_flock_dotl,
 	.mmap = v9fs_mmap_file_mmap,
+	.splice_read = generic_file_splice_read,
 	.fsync = v9fs_file_fsync_dotl,
 };
-- 
2.29.2


             reply	other threads:[~2020-12-01 13:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 13:54 Toke Høiland-Jørgensen [this message]
2020-12-01 14:57 ` [PATCH] fs: 9p: add generic splice_read file operations Dominique Martinet
2020-12-01 15:16   ` [V9fs-developer] " Dominique Martinet
2020-12-01 15:23     ` Toke Høiland-Jørgensen
2020-12-01 15:39       ` Dominique Martinet
2020-12-01 20:37         ` Toke Høiland-Jørgensen
2020-12-01 15:44     ` [PATCH] fs: 9p: add generic splice_write file operation Dominique Martinet
2020-12-01 19:25       ` Christoph Hellwig
2020-12-01 20:37       ` Toke Høiland-Jørgensen

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=20201201135409.55510-1-toke@redhat.com \
    --to=toke@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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).