[PATCH v3 5/9] erofs: set accurate anony inode size for page cache sharing
Jingbo Xu
jefflexu at linux.alibaba.com
Fri Feb 3 14:01:39 AEDT 2023
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 at linux.alibaba.com>
---
fs/erofs/fscache.c | 9 +++++++++
fs/erofs/internal.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index bed02b21978a..4fe7f23b022e 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -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;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 7c6a7a2d9acf..60d14561fb46 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -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)
--
2.19.1.6.gb485710b
More information about the Linux-erofs
mailing list