]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
iomap/gfs2: Unlock and put folio in page_done handler
authorAndreas Gruenbacher <agruenba@redhat.com>
Sun, 15 Jan 2023 16:45:51 +0000 (08:45 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 18 Jan 2023 18:44:04 +0000 (10:44 -0800)
commit80baab88bb93eeaa133b426d24dfc0775a8cf824
tree4f40e8ce842c0a71f2b56c6454b77b76940c11ad
parent7a70a5085ed028b4fd132447cbaea9b73113bca9
iomap/gfs2: Unlock and put folio in page_done handler

When an iomap defines a ->page_done() handler in its page_ops, delegate
unlocking the folio and putting the folio reference to that handler.

This allows to fix a race between journaled data writes and folio
writeback in gfs2: before this change, gfs2_iomap_page_done() was called
after unlocking the folio, so writeback could start writing back the
folio's buffers before they could be marked for writing to the journal.
Also, try_to_free_buffers() could free the buffers before
gfs2_iomap_page_done() was done adding the buffers to the current
current transaction.  With this change, gfs2_iomap_page_done() adds the
buffers to the current transaction while the folio is still locked, so
the problems described above can no longer occur.

The only current user of ->page_done() is gfs2, so other filesystems are
not affected.  To catch out any out-of-tree users, switch from a page to
a folio in ->page_done().

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/gfs2/bmap.c
fs/iomap/buffered-io.c
include/linux/iomap.h