From: yangerkun <yangerkun@huaweicloud.com>
To: Dave Chinner <david@fromorbit.com>
Cc: djwong@kernel.org, dchinner@redhat.com, sandeen@redhat.com,
linux-xfs@vger.kernel.org, yangerkun@huawei.com,
yukuai3@huawei.com
Subject: Re: [PATCH] xfs: fix deadlock when set label online
Date: Tue, 27 Jun 2023 16:42:41 +0800 [thread overview]
Message-ID: <c4f2edcd-efe2-2a96-316b-40f7ac95e6ce@huaweicloud.com> (raw)
In-Reply-To: <ZJoHEuoMkg2Ngn5o@dread.disaster.area>
在 2023/6/27 5:45, Dave Chinner 写道:
> On Mon, Jun 26, 2023 at 09:15:42PM +0800, yangerkun wrote:
>> From: yangerkun <yangerkun@huawei.com>
>>
>> Combine use of xfs_trans_hold and xfs_trans_set_sync in xfs_sync_sb_buf
>> can trigger a deadlock once shutdown happened concurrently. xlog_ioend_work
>> will first unpin the sb(which stuck with xfs_buf_lock), then wakeup
>> xfs_sync_sb_buf. However, xfs_sync_sb_buf never get the chance to unlock
>> sb until been wakeup by xlog_ioend_work.
>>
>> xfs_sync_sb_buf
>> xfs_trans_getsb // lock sb buf
>> xfs_trans_bhold // sb buf keep lock until success commit
>> xfs_trans_commit
>> ...
>> xfs_log_force_seq
>> xlog_force_lsn
>> xlog_wait_on_iclog
>> xlog_wait(&iclog->ic_force_wait... // shutdown happened
>> xfs_buf_relse // unlock sb buf
>>
>> xlog_ioend_work
>> xlog_force_shutdown
>> xlog_state_shutdown_callbacks
>> xlog_cil_process_committed
>> xlog_cil_committed
>> ...
>> xfs_buf_item_unpin
>> xfs_buf_lock // deadlock
>> wake_up_all(&iclog->ic_force_wait)
>>
>> xfs_ioc_setlabel use xfs_sync_sb_buf to make sure userspace will see the
>> change for sb immediately. We can simply call xfs_ail_push_all_sync to
>> do this and sametime fix the deadlock.
>
> Why is this deadlock specific to the superblock buffer?
Hi Dave,
Thanks a lot for your revirew! We find this problem when do some code
reading(which can help us to fix another growfs bug). And then reproduce
it easily when we set label online frequently with IO error inject at
the sametime.
>
> Can't any buffer that is held locked over a synchronous transaction
> commit deadlock during a shutdown like this?
After check all place use xfs_buf_bhold, it seems xfs_sync_sb_buf is the
only convict that combine use xfs_trans_hold and xfs_trans_set_sync(I'm
not familiar with xfs yet, so I may have some problems with my code
check)...
Thanks,
Yang Erkun.
>
> Cheers,
>
> Dave.
next prev parent reply other threads:[~2023-06-27 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 13:15 [PATCH] xfs: fix deadlock when set label online yangerkun
2023-06-26 21:45 ` Dave Chinner
2023-06-27 8:42 ` yangerkun [this message]
2023-06-28 23:10 ` Dave Chinner
2023-06-29 11:55 ` yangerkun
2023-06-29 22:24 ` Dave Chinner
2023-06-30 2:19 ` yangerkun
2023-08-11 6:21 ` yangerkun
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=c4f2edcd-efe2-2a96-316b-40f7ac95e6ce@huaweicloud.com \
--to=yangerkun@huaweicloud.com \
--cc=david@fromorbit.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=yangerkun@huawei.com \
--cc=yukuai3@huawei.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).