NFS: Don't always trust server inode size while client holds write delegation
Subsystems (2)
Dai Ngo
reviewerPATCH v2 1/1 NFS: Don't always trust server inode size while client holds write delegation
With a write delegation, the server permits the client to buffer writes and associated metadata updates (including file size changes) locally and defer propagating them to the server. As a result, the server-reported GETATTR size may legitimately lag behind the client’s cached size for the duration of the delegation, so it must not be treated as authoritative.
This patch modifies nfs_wcc_update_inode to update the cached inode size only when the client does not hold a write delegation or the cache_validity of the nfs_inode has the NFS_INO_INVALID_SIZE bit set.
Signed-off-by Dai Ngo <[email protected]>
--- fs/nfs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
v2:
. added missing 'NFS:' on Subject line.
fs/nfs/inode.c +5 -2
@@ -1649,8 +1649,11 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) && (fattr->valid &NFS_ATTR_FATTR_SIZE ) &&i_size_read (inode) ==nfs_size_to_loff_t (fattr->pre_size) && !nfs_have_writebacks(inode)) { -trace_nfs_size_wcc (inode, fattr->size); -i_size_write (inode,nfs_size_to_loff_t (fattr->size)); + if ((!nfs_have_write_delegation(inode)) || + (NFS_I(inode)->cache_validity & NFS_INO_INVALID_SIZE)) { +trace_nfs_size_wcc (inode, fattr->size); +i_size_write (inode,nfs_size_to_loff_t (fattr->size)); + } } }
Signature · 1 line
2.47.3