Commit d96d96ee authored by David Howells's avatar David Howells Committed by Jens Axboe

afs: Provide a splice-read wrapper

Provide a splice_read wrapper for AFS to call afs_validate() before going
into generic_file_splice_read() so that we're likely to have a callback
promise from the server.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-mm@kvack.org
Link: https://lore.kernel.org/r/20230522135018.2742245-16-dhowells@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c829d0bd
...@@ -25,6 +25,9 @@ static void afs_invalidate_folio(struct folio *folio, size_t offset, ...@@ -25,6 +25,9 @@ static void afs_invalidate_folio(struct folio *folio, size_t offset,
static bool afs_release_folio(struct folio *folio, gfp_t gfp_flags); static bool afs_release_folio(struct folio *folio, gfp_t gfp_flags);
static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter); static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter);
static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags);
static void afs_vm_open(struct vm_area_struct *area); static void afs_vm_open(struct vm_area_struct *area);
static void afs_vm_close(struct vm_area_struct *area); static void afs_vm_close(struct vm_area_struct *area);
static vm_fault_t afs_vm_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pgoff_t end_pgoff); static vm_fault_t afs_vm_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pgoff_t end_pgoff);
...@@ -36,7 +39,7 @@ const struct file_operations afs_file_operations = { ...@@ -36,7 +39,7 @@ const struct file_operations afs_file_operations = {
.read_iter = afs_file_read_iter, .read_iter = afs_file_read_iter,
.write_iter = afs_file_write, .write_iter = afs_file_write,
.mmap = afs_file_mmap, .mmap = afs_file_mmap,
.splice_read = generic_file_splice_read, .splice_read = afs_file_splice_read,
.splice_write = iter_file_splice_write, .splice_write = iter_file_splice_write,
.fsync = afs_fsync, .fsync = afs_fsync,
.lock = afs_lock, .lock = afs_lock,
...@@ -587,3 +590,18 @@ static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) ...@@ -587,3 +590,18 @@ static ssize_t afs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
return generic_file_read_iter(iocb, iter); return generic_file_read_iter(iocb, iter);
} }
static ssize_t afs_file_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags)
{
struct afs_vnode *vnode = AFS_FS_I(file_inode(in));
struct afs_file *af = in->private_data;
int ret;
ret = afs_validate(vnode, af->key);
if (ret < 0)
return ret;
return generic_file_splice_read(in, ppos, pipe, len, flags);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment