diff mbox series

[RFC,03/19] cachefiles: refactor cachefiles_adjust_size()

Message ID 20211210073619.21667-4-jefflexu@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series fscache,erofs: fscache-based demand-read semantics | expand

Commit Message

Jingbo Xu Dec. 10, 2021, 7:36 a.m. UTC
In demand-read mode, fs using fscache for demand-read doesn't know the
exact file size of the data blob file, and the input @object_size
parameter of fscache_acquire_cookie() could be fake in this case.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
 fs/cachefiles/interface.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index 51c968cd00a6..b85051250cb7 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -110,6 +110,7 @@  static int cachefiles_adjust_size(struct cachefiles_object *object)
 {
 	struct iattr newattrs;
 	struct file *file = object->file;
+	struct cachefiles_cache *cache = object->volume->cache;
 	uint64_t ni_size;
 	loff_t oi_size;
 	int ret;
@@ -123,6 +124,9 @@  static int cachefiles_adjust_size(struct cachefiles_object *object)
 	if (!file)
 		return -ENOBUFS;
 
+	if (cache->mode == CACHEFILES_MODE_DEMAND)
+		return 0;
+
 	oi_size = i_size_read(file_inode(file));
 	if (oi_size == ni_size)
 		return 0;