lkml.org 
[lkml]   [2023]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 6/9] erofs: implement .read_iter for page cache sharing
Date
When page cache sharing enabled, page caches are managed in the address
space of blobs rather than erofs inodes. All erofs inodes sharing one
chunk will refer to and share the page cache in the blob's address
space.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/erofs/fscache.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 4fe7f23b022e..bdeb048b78b5 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -410,8 +410,31 @@ static int erofs_fscache_share_file_open(struct inode *inode, struct file *filp)
return 0;
}

+static ssize_t erofs_fscache_share_file_read_iter(struct kiocb *iocb,
+ struct iov_iter *iter)
+{
+ struct file *realfile = iocb->ki_filp->private_data;
+ struct erofs_fscache_finfo *finfo = realfile->private_data;
+ ssize_t res;
+
+ if (!iov_iter_count(iter))
+ return 0;
+
+ if (!is_sync_kiocb(iocb))
+ return filemap_read(iocb, iter, 0);
+
+ iov_iter_truncate(iter, file_inode(iocb->ki_filp)->i_size - iocb->ki_pos);
+ iocb->ki_filp = realfile;
+ iocb->ki_pos += finfo->pa;
+
+ res = filemap_read(iocb, iter, 0);
+ iocb->ki_pos -= finfo->pa;
+ return res;
+}
+
const struct file_operations erofs_fscache_share_file_fops = {
.llseek = generic_file_llseek,
+ .read_iter = erofs_fscache_share_file_read_iter,
.open = erofs_fscache_share_file_open,
.release = erofs_fscache_share_file_release,
};
--
2.19.1.6.gb485710b
\
 
 \ /
  Last update: 2023-03-27 00:08    [W:0.099 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site