From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel <linux-kernel@vger.kernel.org>
Subject: [BUG] fs: btrfs: several possible ABBA deadlocks
Date: Sat, 27 Nov 2021 16:23:37 +0800 [thread overview]
Message-ID: <44b385ca-f00d-0b47-e370-bd7d97cb1be3@gmail.com> (raw)
Hello,
My static analysis tool reports several possible ABBA deadlocks in the
btrfs module in Linux 5.10:
# DEADLOCK 1:
__clear_extent_bit()
spin_lock(&tree->lock); --> Line 733 (Lock A)
split_state()
btrfs_split_delalloc_extent()
spin_lock(&BTRFS_I(inode)->lock); --> Line 1870 (Lock B)
btrfs_inode_safe_disk_i_size_write()
spin_lock(&BTRFS_I(inode)->lock); --> Line 53 (Lock B)
find_contiguous_extent_bit()
spin_lock(&tree->lock); --> Line 1620 (Lock A)
When __clear_extent_bit() and btrfs_inode_safe_disk_i_size_write() are
concurrently executed, the deadlock can occur.
# DEADLOCK 2:
__set_extent_bit()
spin_lock(&tree->lock); --> Line 995 (Lock A)
set_state_bits()
btrfs_set_delalloc_extent()
spin_lock(&BTRFS_I(inode)->lock); --> Line 2007 or 2017 or 2029
(Lock B)
btrfs_inode_safe_disk_i_size_write()
spin_lock(&BTRFS_I(inode)->lock); --> Line 53 (Lock B)
find_contiguous_extent_bit()
spin_lock(&tree->lock); --> Line 1620 (Lock A)
When __set_extent_bit() and btrfs_inode_safe_disk_i_size_write() are
concurrently executed, the deadlock can occur.
# DEADLOCK 3:
convert_extent_bit()
spin_lock(&tree->lock); --> Line 1241 (Lock A)
set_state_bits()
btrfs_set_delalloc_extent()
spin_lock(&BTRFS_I(inode)->lock); --> Line 2007 or 2017 or 2029
(Lock B)
btrfs_inode_safe_disk_i_size_write()
spin_lock(&BTRFS_I(inode)->lock); --> Line 53 (Lock B)
find_contiguous_extent_bit()
spin_lock(&tree->lock); --> Line 1620 (Lock A)
When convert_extent_bit() and btrfs_inode_safe_disk_i_size_write() are
concurrently executed, the deadlock can occur.
I am not quite sure whether these possible deadlocks are real and how to
fix them if they are real.
Any feedback would be appreciated, thanks :)
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Best wishes,
Jia-Ju Bai
next reply other threads:[~2021-11-27 8:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 8:23 Jia-Ju Bai [this message]
2021-11-29 0:34 ` [BUG] fs: btrfs: several possible ABBA deadlocks Josef Bacik
2021-11-29 1:48 ` Jia-Ju Bai
2021-11-29 14:37 ` Nikolay Borisov
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=44b385ca-f00d-0b47-e370-bd7d97cb1be3@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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