[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221201160619.1247788-4-agruenba@redhat.com>
Date: Thu, 1 Dec 2022 17:06:19 +0100
From: Andreas Gruenbacher <agruenba@...hat.com>
To: Christoph Hellwig <hch@...radead.org>,
"Darrick J . Wong" <djwong@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>
Cc: Andreas Gruenbacher <agruenba@...hat.com>,
linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, cluster-devel@...hat.com
Subject: [RFC 3/3] gfs2: Fix race between shrinker and gfs2_iomap_folio_done
In gfs2_iomap_folio_done(), add the modified buffer heads to the current
transaction while the folio is still locked. Otherwise, the shrinker
can come in and free them before we get to gfs2_page_add_databufs().
Signed-off-by: Andreas Gruenbacher <agruenba@...hat.com>
---
fs/gfs2/bmap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 18dcaa95408e..d8d9ee843ac9 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -990,18 +990,17 @@ gfs2_iomap_folio_done(struct inode *inode, struct folio *folio,
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
- folio_unlock(folio);
-
if (!gfs2_is_stuffed(ip))
gfs2_page_add_databufs(ip, &folio->page, offset_in_page(pos),
copied);
+ folio_unlock(folio);
+ folio_put(folio);
+
if (tr->tr_num_buf_new)
__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
gfs2_trans_end(sdp);
-
- folio_put(folio);
}
static const struct iomap_folio_ops gfs2_iomap_folio_ops = {
--
2.38.1
Powered by blists - more mailing lists