diff mbox series

[RFC,v2,11/14] NFS: Call nfs_fscache_invalidate() when write extends the size of the file

Message ID 1596031949-26793-12-git-send-email-dwysocha@redhat.com (mailing list archive)
State New, archived
Headers show
Series Convert NFS to new FS-Cache iter API | expand

Commit Message

David Wysochanski July 29, 2020, 2:12 p.m. UTC
If a write extends the size of the file and fscache is enabled, we
need to invalidate the object with the new size.  Otherwise, the next
read from the cache may fail inside cachefiles_shape_extent() due to
cookie->zero_point being smaller than the size of the file.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 fs/nfs/write.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 005eea29e0ec..2da99814da51 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -290,6 +290,7 @@  static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
 		goto out;
 	i_size_write(inode, end);
 	NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE;
+	nfs_fscache_invalidate(inode);
 	nfs_inc_stats(inode, NFSIOS_EXTENDWRITE);
 out:
 	spin_unlock(&inode->i_lock);