From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2: Prevent writeback in gfs2_file_write_iter
Date: Wed, 13 Mar 2019 18:13:22 +0100 [thread overview]
Message-ID: <20190313171322.23308-1-agruenba@redhat.com> (raw)
In-Reply-To: <b7ecf30b-4a11-22b7-321d-a7eb539a7916@citrix.com>
Hi Edwin,
On Wed, 6 Mar 2019 at 12:08, Edwin T?r?k <edvin.torok@citrix.com> wrote:
> Hello,
>
> I've been trying to debug a GFS2 deadlock that we see in our lab quite frequently with a 4.19 kernel. With 4.4 and older kernels we were not able to reproduce this.
> See below for lockdep dumps and stacktraces.
thanks for the thorough bug report. Does the below fix work for you?
Thanks,
Andreas
--
Prevent page reclaim on the backing device of the filesystem in
gfs2_file_write_iter:
- In gfs2_file_write_iter, iomap_file_buffered_write grabs the log
flush lock (via iomap_apply -> iomap_begin -> gfs2_iomap_begin_write
-> gfs2_trans_begin) and holds it for the duration of the write.
- It then calls iomap_write_actor -> balance_dirty_pages.
- If that triggers writeback on the same filesystem, we would try
to grab the log flush lock again (via writeback_sb_inodes ->
gfs2_write_inode -> gfs2_log_flush) and deadlock.
Prevent that by not setting backing_dev_info in gfs2_file_write_iter.
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>
---
fs/gfs2/file.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index a2dea5bc04276..8c7d296d58608 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -816,16 +816,13 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (ret <= 0)
goto out;
- /* We can write back this queue in page reclaim */
- current->backing_dev_info = inode_to_bdi(inode);
-
ret = file_remove_privs(file);
if (ret)
- goto out2;
+ goto out;
ret = file_update_time(file);
if (ret)
- goto out2;
+ goto out;
if (iocb->ki_flags & IOCB_DIRECT) {
struct address_space *mapping = file->f_mapping;
@@ -834,11 +831,11 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
written = gfs2_file_direct_write(iocb, from);
if (written < 0 || !iov_iter_count(from))
- goto out2;
+ goto out;
ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops);
if (unlikely(ret < 0))
- goto out2;
+ goto out;
buffered = ret;
/*
@@ -867,8 +864,6 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
iocb->ki_pos += ret;
}
-out2:
- current->backing_dev_info = NULL;
out:
inode_unlock(inode);
if (likely(ret > 0)) {
--
2.20.1
next prev parent reply other threads:[~2019-03-13 17:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 11:00 [Cluster-devel] GFS2 deadlock in 4.19 (iomap/writeback?) Edwin Török
2019-03-13 17:13 ` Andreas Gruenbacher [this message]
2019-03-14 11:18 ` [Cluster-devel] [PATCH] gfs2: Prevent writeback in gfs2_file_write_iter Ross Lagerwall
2019-03-15 20:58 ` Andreas Gruenbacher
2019-08-13 12:47 ` [Cluster-devel] GFS2 deadlock in 4.19 (iomap/writeback?) Andreas Gruenbacher
[not found] <19:84>
2019-03-16 23:58 ` [Cluster-devel] [PATCH] gfs2: Prevent writeback in gfs2_file_write_iter Mark Syms
2019-03-17 20:06 ` Andreas Gruenbacher
2019-03-18 15:10 ` Mark Syms
2019-03-18 16:30 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190313171322.23308-1-agruenba@redhat.com \
--to=agruenba@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).