NFS: Revalidate the file size on a fatal write error
authorTrond Myklebust <trondmy@gmail.com>
Mon, 6 Jan 2020 20:25:00 +0000 (15:25 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 15 Jan 2020 15:54:32 +0000 (10:54 -0500)
If we suffer a fatal error upon writing a file, which causes us to
need to revalidate the entire mapping, then we should also revalidate
the file size.

Fixes: d2ceb7e57086 ("NFS: Don't use page_file_mapping after removing the page")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/write.c

index 21787711e3524047ebd028c2c34e6bbb76e06f2d..adedc16780c54887686a7efeeb0bdbd06e7493d4 100644 (file)
@@ -243,7 +243,15 @@ out:
 /* A writeback failed: mark the page as bad, and invalidate the page cache */
 static void nfs_set_pageerror(struct address_space *mapping)
 {
+       struct inode *inode = mapping->host;
+
        nfs_zap_mapping(mapping->host, mapping);
+       /* Force file size revalidation */
+       spin_lock(&inode->i_lock);
+       NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED |
+                                       NFS_INO_REVAL_PAGECACHE |
+                                       NFS_INO_INVALID_SIZE;
+       spin_unlock(&inode->i_lock);
 }
 
 static void nfs_mapping_set_error(struct page *page, int error)