Skip to content

Commit 95ecbd0

Browse files
author
Andreas Gruenbacher
committed
Revert "gfs2: stop using generic_writepages in gfs2_ail1_start_one"
Commit b2b0a5e switched from generic_writepages() to filemap_fdatawrite_wbc() in gfs2_ail1_start_one() on the path to replacing ->writepage() with ->writepages() and eventually eliminating the former. Function gfs2_ail1_start_one() is called from gfs2_log_flush(), our main function for flushing the filesystem log. Unfortunately, at least as implemented today, ->writepage() and ->writepages() are entirely different operations for journaled data inodes: while the former creates and submits transactions covering the data to be written, the latter flushes dirty buffers out to disk. With gfs2_ail1_start_one() now calling ->writepages(), we end up creating filesystem transactions while we are in the course of a log flush, which immediately deadlocks on the sdp->sd_log_flush_lock semaphore. Work around that by going back to how things used to work before commit b2b0a5e for now; figuring out a superior solution will take time we don't have available right now. However ... Since the removal of generic_writepages() is imminent, open-code it here. We're already inside a blk_start_plug() ... blk_finish_plug() section here, so skip that part of the original generic_writepages(). This reverts commit b2b0a5e. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Acked-by: Christoph Hellwig <hch@lst.de>
1 parent 5dc4c99 commit 95ecbd0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/gfs2/log.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
8080
brelse(bd->bd_bh);
8181
}
8282

83+
static int __gfs2_writepage(struct page *page, struct writeback_control *wbc,
84+
void *data)
85+
{
86+
struct address_space *mapping = data;
87+
int ret = mapping->a_ops->writepage(page, wbc);
88+
mapping_set_error(mapping, ret);
89+
return ret;
90+
}
91+
8392
/**
8493
* gfs2_ail1_start_one - Start I/O on a transaction
8594
* @sdp: The superblock
@@ -131,7 +140,7 @@ __acquires(&sdp->sd_ail_lock)
131140
if (!mapping)
132141
continue;
133142
spin_unlock(&sdp->sd_ail_lock);
134-
ret = filemap_fdatawrite_wbc(mapping, wbc);
143+
ret = write_cache_pages(mapping, wbc, __gfs2_writepage, mapping);
135144
if (need_resched()) {
136145
blk_finish_plug(plug);
137146
cond_resched();

0 commit comments

Comments
 (0)