]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
gfs2: Fix iomap write page reclaim deadlock
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 29 Apr 2019 19:50:30 +0000 (20:50 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 7 May 2019 21:39:15 +0000 (23:39 +0200)
commitd0a22a4b03b8475b7aa3fa41243c26c291407844
treeaf68f7f35e0a354aa370d130e9e79b757783b36d
parent8f91821990fd6f170a5dca79697a441181a41b16
gfs2: Fix iomap write page reclaim deadlock

Since commit 64bc06bb32ee ("gfs2: iomap buffered write support"), gfs2 is doing
buffered writes by starting a transaction in iomap_begin, writing a range of
pages, and ending that transaction in iomap_end.  This approach suffers from
two problems:

  (1) Any allocations necessary for the write are done in iomap_begin, so when
  the data aren't journaled, there is no need for keeping the transaction open
  until iomap_end.

  (2) Transactions keep the gfs2 log flush lock held.  When
  iomap_file_buffered_write calls balance_dirty_pages, this can end up calling
  gfs2_write_inode, which will try to flush the log.  This requires taking the
  log flush lock which is already held, resulting in a deadlock.

Fix both of these issues by not keeping transactions open from iomap_begin to
iomap_end.  Instead, start a small transaction in page_prepare and end it in
page_done when necessary.

Reported-by: Edwin Török <edvin.torok@citrix.com>
Fixes: 64bc06bb32ee ("gfs2: iomap buffered write support")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/aops.c
fs/gfs2/bmap.c