@@ -554,6 +554,15 @@ struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb,
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
inode->i_private = ctx;
+ if (test_opt(&EROFS_SB(sb)->opt, SHARE_CACHE)) {
+ struct netfs_cache_resources cres;
+ ret = fscache_begin_read_operation(&cres, cookie);
+ if (ret)
+ goto err_cookie;
+ fscache_end_operation(&cres);
+ inode->i_size = cookie->object_size;
+ }
+
ctx->cookie = cookie;
ctx->inode = inode;
return ctx;
@@ -181,6 +181,7 @@ struct erofs_sb_info {
#define EROFS_MOUNT_POSIX_ACL 0x00000020
#define EROFS_MOUNT_DAX_ALWAYS 0x00000040
#define EROFS_MOUNT_DAX_NEVER 0x00000080
+#define EROFS_MOUNT_SHARE_CACHE 0x00000100
#define clear_opt(opt, option) ((opt)->mount_opt &= ~EROFS_MOUNT_##option)
#define set_opt(opt, option) ((opt)->mount_opt |= EROFS_MOUNT_##option)
In prep for the following support for readahead for page cache sharing, we need accurate inode size of the anonymous inode, or the readahead algorithm may exceed EOF of blobs if the inode size is OFFSET_MAX magic. Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com> --- fs/erofs/fscache.c | 9 +++++++++ fs/erofs/internal.h | 1 + 2 files changed, 10 insertions(+)