]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/iomap.c
iomap: set page dirty after partial delalloc on mkwrite
authorBrian Foster <bfoster@redhat.com>
Sat, 29 Sep 2018 03:51:01 +0000 (13:51 +1000)
committerDave Chinner <david@fromorbit.com>
Sat, 29 Sep 2018 03:51:01 +0000 (13:51 +1000)
commit561295a32579e2db3b22f74d1f45d5c4c4fd9375
tree81aa3ec8a01584bff17410d04ba137e38925085b
parentec2ed0b5e96fea2a4539bd7f7f43499ecd45be8b
iomap: set page dirty after partial delalloc on mkwrite

The iomap page fault mechanism currently dirties the associated page
after the full block range of the page has been allocated. This
leaves the page susceptible to delayed allocations without ever
being set dirty on sub-page block sized filesystems.

For example, consider a page fault on a page with one preexisting
real (non-delalloc) block allocated in the middle of the page. The
first iomap_apply() iteration performs delayed allocation on the
range up to the preexisting block, the next iteration finds the
preexisting block, and the last iteration attempts to perform
delayed allocation on the range after the prexisting block to the
end of the page. If the first allocation succeeds and the final
allocation fails with -ENOSPC, iomap_apply() returns the error and
iomap_page_mkwrite() fails to dirty the page having already
performed partial delayed allocation. This eventually results in the
page being invalidated without ever converting the delayed
allocation to real blocks.

This problem is reliably reproduced by generic/083 on XFS on ppc64
systems (64k page size, 4k block size). It results in leaked
delalloc blocks on inode reclaim, which triggers an assert failure
in xfs_fs_destroy_inode() and filesystem accounting inconsistency.

Move the set_page_dirty() call from iomap_page_mkwrite() to the
actor callback, similar to how the buffer head implementation works.
The actor callback is called iff ->iomap_begin() returns success, so
ensures the page is dirtied as soon as possible after an allocation.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/iomap.c