Commit b7b85742 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

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: d47992f8 ("mm: change invalidatepage prototype to accept length")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent ca247c89
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -475,9 +475,10 @@ static void nfs_invalidate_folio(struct folio *folio, size_t offset,
	dfprintk(PAGECACHE, "NFS: invalidate_folio(%lu, %zu, %zu)\n",
		 folio->index, offset, length);

	if (offset != 0 || length < folio_size(folio))
		return;
	/* Cancel any unstarted writes on this page */
	if (offset != 0 || length < folio_size(folio))
		nfs_wb_folio(inode, folio);
	else
		nfs_wb_folio_cancel(inode, folio);
	folio_wait_private_2(folio); /* [DEPRECATED] */
	trace_nfs_invalidate_folio(inode, folio_pos(folio) + offset, length);
+1 −0
Original line number Diff line number Diff line
@@ -2045,6 +2045,7 @@ int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio)
		 * release it */
		nfs_inode_remove_request(req);
		nfs_unlock_and_release_request(req);
		folio_cancel_dirty(folio);
	}

	return ret;