Skip to content

Commit d2ceb7e

Browse files
bcodding-rhamschuma-ntap
authored andcommitted
NFS: Don't use page_file_mapping after removing the page
If nfs_page_async_flush() removes the page from the mapping, then we can't use page_file_mapping() on it as nfs_updatepate() is wont to do when receiving an error. Instead, push the mapping to the stack before the page is possibly truncated. Fixes: 8fc75be ("NFS: Fix up return value on fatal errors in nfs_page_async_flush()") Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent ad6fef7 commit d2ceb7e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/nfs/write.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
238238
}
239239

240240
/* A writeback failed: mark the page as bad, and invalidate the page cache */
241-
static void nfs_set_pageerror(struct page *page)
241+
static void nfs_set_pageerror(struct address_space *mapping)
242242
{
243-
nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page));
243+
nfs_zap_mapping(mapping->host, mapping);
244244
}
245245

246246
/*
@@ -994,7 +994,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
994994
nfs_list_remove_request(req);
995995
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) &&
996996
(hdr->good_bytes < bytes)) {
997-
nfs_set_pageerror(req->wb_page);
997+
nfs_set_pageerror(page_file_mapping(req->wb_page));
998998
nfs_context_set_write_error(req->wb_context, hdr->error);
999999
goto remove_req;
10001000
}
@@ -1348,7 +1348,8 @@ int nfs_updatepage(struct file *file, struct page *page,
13481348
unsigned int offset, unsigned int count)
13491349
{
13501350
struct nfs_open_context *ctx = nfs_file_open_context(file);
1351-
struct inode *inode = page_file_mapping(page)->host;
1351+
struct address_space *mapping = page_file_mapping(page);
1352+
struct inode *inode = mapping->host;
13521353
int status = 0;
13531354

13541355
nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
@@ -1366,7 +1367,7 @@ int nfs_updatepage(struct file *file, struct page *page,
13661367

13671368
status = nfs_writepage_setup(ctx, page, offset, count);
13681369
if (status < 0)
1369-
nfs_set_pageerror(page);
1370+
nfs_set_pageerror(mapping);
13701371
else
13711372
__set_page_dirty_nobuffers(page);
13721373
out:

0 commit comments

Comments
 (0)