]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
xfs: cancel dirty pages on invalidation
authorDave Chinner <dchinner@redhat.com>
Fri, 13 Oct 2017 16:47:45 +0000 (09:47 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 16 Oct 2017 19:11:56 +0000 (12:11 -0700)
commit793d7dbe6d82a50b9d14bf992b9eaacb70a11ce6
treeb8aa09684dd49335da3ac453c6a7fa4fc6fcd4b9
parent33d930e59a98fa10a0db9f56c7fa2f21a4aef9b9
xfs: cancel dirty pages on invalidation

Recently we've had warnings arise from the vm handing us pages
without bufferheads attached to them. This should not ever occur
in XFS, but we don't defend against it properly if it does. The only
place where we remove bufferheads from a page is in
xfs_vm_releasepage(), but we can't tell the difference here between
"page is dirty so don't release" and "page is dirty but is being
invalidated so release it".

In some places that are invalidating pages ask for pages to be
released and follow up afterward calling ->releasepage by checking
whether the page was dirty and then aborting the invalidation. This
is a possible vector for releasing buffers from a page but then
leaving it in the mapping, so we really do need to avoid dirty pages
in xfs_vm_releasepage().

To differentiate between invalidated pages and normal pages, we need
to clear the page dirty flag when invalidating the pages. This can
be done through xfs_vm_invalidatepage(), and will result
xfs_vm_releasepage() seeing the page as clean which matches the
bufferhead state on the page after calling block_invalidatepage().

Hence we can re-add the page dirty check in xfs_vm_releasepage to
catch the case where we might be releasing a page that is actually
dirty and so should not have the bufferheads on it removed. This
will remove one possible vector of "dirty page with no bufferheads"
and so help narrow down the search for the root cause of that
problem.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_aops.c