Skip to content

Commit b7b8574

Browse files
author
Trond Myklebust
committed
NFS: nfs_invalidate_folio() must observe the offset and size arguments
If we're truncating part of the folio, then we need to write out the data on the part that is not covered by the cancellation. Fixes: d47992f ("mm: change invalidatepage prototype to accept length") Signed-off-by: Trond Myklebust <[email protected]>
1 parent ca247c8 commit b7b8574

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fs/nfs/file.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,11 @@ static void nfs_invalidate_folio(struct folio *folio, size_t offset,
475475
dfprintk(PAGECACHE, "NFS: invalidate_folio(%lu, %zu, %zu)\n",
476476
folio->index, offset, length);
477477

478-
if (offset != 0 || length < folio_size(folio))
479-
return;
480478
/* Cancel any unstarted writes on this page */
481-
nfs_wb_folio_cancel(inode, folio);
479+
if (offset != 0 || length < folio_size(folio))
480+
nfs_wb_folio(inode, folio);
481+
else
482+
nfs_wb_folio_cancel(inode, folio);
482483
folio_wait_private_2(folio); /* [DEPRECATED] */
483484
trace_nfs_invalidate_folio(inode, folio_pos(folio) + offset, length);
484485
}

fs/nfs/write.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,7 @@ int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio)
20452045
* release it */
20462046
nfs_inode_remove_request(req);
20472047
nfs_unlock_and_release_request(req);
2048+
folio_cancel_dirty(folio);
20482049
}
20492050

20502051
return ret;

0 commit comments

Comments
 (0)