From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Hillf Danton <hdanton@sina.com>
Cc: <hch@lst.de>, <torvalds@linux-foundation.org>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yukuai3@huawei.com>
Subject: Re: [PATCH v2] fs-writeback: writeback_sb_inodes: Recalculate 'wrote' according skipped pages
Date: Mon, 18 Apr 2022 21:27:09 +0800 [thread overview]
Message-ID: <4df77267-09f0-c4be-116e-86e447cbd292@huawei.com> (raw)
In-Reply-To: <20220418112745.1761-1-hdanton@sina.com>
HI Hillf,
> On Mon, 18 Apr 2022 17:28:24 +0800 Zhihao Cheng wrote:
>> Commit 505a666ee3fc ("writeback: plug writeback in wb_writeback() and
>> writeback_inodes_wb()") has us holding a plug during wb_writeback, which
>> may cause a potential ABBA dead lock:
>>
>> wb_writeback fat_file_fsync
>> blk_start_plug(&plug)
>> for (;;) {
>> iter i-1: some reqs have been added into plug->mq_list // LOCK A
>> iter i:
>> progress = __writeback_inodes_wb(wb, work)
>> . writeback_sb_inodes // fat's bdev
See comments " fat's bdev".
>
> if (inode->i_state & I_SYNC) {
> /* Wait for I_SYNC. This function drops i_lock... */
> inode_sleep_on_writeback(inode);
> /* Inode may be gone, start again */
> spin_lock(&wb->list_lock);
> continue;
> }
> inode->i_state |= I_SYNC;
This inode is fat's bdev's inode.
>
>> . __writeback_single_inode
>> . . generic_writepages
>> . . __block_write_full_page
>> . . . . __generic_file_fsync
>> . . . . sync_inode_metadata
>> . . . . writeback_single_inode
>
> if (inode->i_state & I_SYNC) {
This inode is fat's inode.
> /*
> * Writeback is already running on the inode. For WB_SYNC_NONE,
> * that's enough and we can just return. For WB_SYNC_ALL, we
> * must wait for the existing writeback to complete, then do
> * writeback again if there's anything left.
> */
> if (wbc->sync_mode != WB_SYNC_ALL)
> goto out;
> __inode_wait_for_writeback(inode);
> }
> inode->i_state |= I_SYNC;
>
>> . . . . __writeback_single_inode
>> . . . . fat_write_inode
>> . . . . __fat_write_inode
>> . . . . sync_dirty_buffer // fat's bdev
>> . . . . lock_buffer(bh) // LOCK B
>> . . . . submit_bh
>> . . . . blk_mq_get_tag // LOCK A
>> . . . trylock_buffer(bh) // LOCK B
>
> Given I_SYNC checked on both sides, the chance for ABBA deadlock is zero.
Above two inodes are not same.
next parent reply other threads:[~2022-04-18 14:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220418112745.1761-1-hdanton@sina.com>
2022-04-18 13:27 ` Zhihao Cheng [this message]
2022-04-18 9:28 [PATCH v2] fs-writeback: writeback_sb_inodes:Recalculate " Zhihao Cheng
2022-04-18 19:43 ` Linus Torvalds
2022-04-18 21:16 ` Jens Axboe
2022-04-18 22:01 ` Linus Torvalds
2022-04-18 22:12 ` Jens Axboe
2022-04-18 22:20 ` Jens Axboe
2022-04-19 0:24 ` Linus Torvalds
2022-04-19 0:19 ` Linus Torvalds
2022-04-19 0:30 ` Jens Axboe
2022-04-19 8:16 ` Peter Zijlstra
2022-04-19 8:10 ` Peter Zijlstra
2022-04-19 8:17 ` Peter Zijlstra
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=4df77267-09f0-c4be-116e-86e447cbd292@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=hch@lst.de \
--cc=hdanton@sina.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®