linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: viro@zeniv.linux.org.uk, Jens Axboe <axboe@kernel.dk>,
	hch@infradead.org, linux-fsdevel@vger.kernel.org,
	linux-block@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] fs: super: possible ABBA deadlocks in do_thaw_all_callback() and freeze_bdev()
Date: Mon, 27 Dec 2021 02:08:58 +0000	[thread overview]
Message-ID: <YckgOocIWOrOoRvf@casper.infradead.org> (raw)
In-Reply-To: <e3de0d83-1170-05c8-672c-4428e781b988@gmail.com>

On Mon, Dec 27, 2021 at 10:03:35AM +0800, Jia-Ju Bai wrote:
> My static analysis tool reports several possible ABBA deadlocks in Linux
> 5.10:
> 
> do_thaw_all_callback()
>   down_write(&sb->s_umount); --> Line 1028 (Lock A)
>   emergency_thaw_bdev()
>     thaw_bdev()
>       mutex_lock(&bdev->bd_fsfreeze_mutex); --> Line 602 (Lock B)
> 
> freeze_bdev()
>   mutex_lock(&bdev->bd_fsfreeze_mutex); --> Line 556 (Lock B)
>   freeze_super()
>     down_write(&sb->s_umount); --> Line 1716 (Lock A)
>     down_write(&sb->s_umount); --> Line 1738 (Lock A)
>   deactivate_super()
>     down_write(&s->s_umount); --> Line 365 (Lock A)
> 
> When do_thaw_all_callback() and freeze_bdev() are concurrently executed, the
> deadlocks can occur.
> 
> I am not quite sure whether these possible deadlocks are real and how to fix
> them if them are real.
> Any feedback would be appreciated, thanks :)

As a rule, ABBA deadlocks that can actually occur are already found by
lockdep.    Tools that think they've found something are generally wrong.
I'm not inclined to look in detail to find out why this tool is wrong
because lockdep is so effective.

  reply	other threads:[~2021-12-27  2:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27  2:03 [BUG] fs: super: possible ABBA deadlocks in do_thaw_all_callback() and freeze_bdev() Jia-Ju Bai
2021-12-27  2:08 ` Matthew Wilcox [this message]
2021-12-27  4:39   ` Theodore Ts'o
2021-12-27  9:32     ` Jia-Ju Bai
2021-12-27 13:43       ` Theodore Ts'o
2021-12-28  2:31         ` Jia-Ju Bai

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=YckgOocIWOrOoRvf@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=baijiaju1990@gmail.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).