Skip to content

Commit 4058f74

Browse files
committed
netfs: Keep track of the actual remote file size
Provide a place in which to keep track of the actual remote file size in the netfs context. This is needed because inode->i_size will be updated as we buffer writes in the pagecache, but the server file size won't get updated until we flush them back. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164623013727.3564931.17659955636985232717.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/164678219305.1200972.6459431995188365134.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/164692921865.2099075.5310757978508056134.stgit@warthog.procyon.org.uk/ # v3
1 parent b900f4b commit 4058f74

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/netfs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct netfs_i_context {
126126
#if IS_ENABLED(CONFIG_FSCACHE)
127127
struct fscache_cookie *cache;
128128
#endif
129+
loff_t remote_i_size; /* Size of the remote file */
129130
};
130131

131132
/*
@@ -324,6 +325,21 @@ static inline void netfs_i_context_init(struct inode *inode,
324325

325326
memset(ctx, 0, sizeof(*ctx));
326327
ctx->ops = ops;
328+
ctx->remote_i_size = i_size_read(inode);
329+
}
330+
331+
/**
332+
* netfs_resize_file - Note that a file got resized
333+
* @inode: The inode being resized
334+
* @new_i_size: The new file size
335+
*
336+
* Inform the netfs lib that a file got resized so that it can adjust its state.
337+
*/
338+
static inline void netfs_resize_file(struct inode *inode, loff_t new_i_size)
339+
{
340+
struct netfs_i_context *ctx = netfs_i_context(inode);
341+
342+
ctx->remote_i_size = new_i_size;
327343
}
328344

329345
/**

0 commit comments

Comments
 (0)