The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Zhou, Yun" <yun.zhou@windriver.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, hch@infradead.org, linux-xfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xfs: don't hold buffer locks across sync transaction commit in xfs_sync_sb_buf
Date: Tue, 14 Jul 2026 09:41:11 +0800	[thread overview]
Message-ID: <54dae2e9-6341-4d58-a92e-11852a12b027@windriver.com> (raw)
In-Reply-To: <20260713220436.GH7195@frogsfrogsfrogs>


Thanks a lot for your review.

On 7/14/26 06:04, Darrick J. Wong wrote:
> 
> On Mon, Jul 13, 2026 at 10:50:02PM +0800, Yun Zhou wrote:
>> xfs_sync_sb_buf() holds sb/rtsb buffer locks across a synchronous
>> xfs_trans_commit(), which flushes the CIL push workqueue internally.
>> If shutdown occurs during the CIL push, xfs_buf_item_unpin() needs to
>> lock these buffers to fail them, causing a deadlock:
>>
>>    setlabel:          holds buf lock -> flush_workqueue(xfs-cil)
>>    CIL push worker:   xfs_buf_item_unpin -> xfs_buf_lock(same buf)
>>
>> Remove the xfs_trans_bhold() calls so that commit releases the buffer
>> locks normally.  After the sync commit, re-acquire the buffers via
>> mp->m_sb_bp / mp->m_rtsb_bp for the on-disk writeback.
> 
> Is there a risk of writing out the wrong superblock contents if
> something else grabs the buffer lock(s) between the xfs_trans_commit and
> the xfs_buf_lock calls?  Can we walk off a garbage
> xfs_mount::m_{rt,}sb_bp pointer if the filesystem is being torn down, or
> does something prevent that?
> 

There shouldn't be a risk of inconsistent contents. Each update to the 
sb buffer is a full overwrite of mp->m_sb via xfs_sb_to_disk(), 
performed under the buffer lock. So when we re-lock after commit, the 
buffer  always contains a complete, consistent snapshot — we may see a 
newer version if someone else updated it in between, but never a 
partially written one.

For the pointer lifetime: mp->m_sb_bp is allocated at mount and freed in 
xfs_unmountfs(). The caller holds mnt_want_write_file(), which prevents 
unmount from making progress, so the pointer should remain valid 
throughout xfs_sync_sb_buf().

BR,
Yun

  reply	other threads:[~2026-07-14  1:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 14:50 [PATCH] xfs: don't hold buffer locks across sync transaction commit in xfs_sync_sb_buf Yun Zhou
2026-07-13 22:04 ` Darrick J. Wong
2026-07-14  1:41   ` Zhou, Yun [this message]
2026-07-14 17:46     ` Darrick J. Wong
2026-07-21 10:44 ` Carlos Maiolino

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=54dae2e9-6341-4d58-a92e-11852a12b027@windriver.com \
    --to=yun.zhou@windriver.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /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