linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Christoph Hellwig <hch@lst.de>
Cc: ming.lei@redhat.com, pasha.tatashin@soleen.com,
	linux-block@vger.kernel.org,
	Colin Ian King <colin.king@canonical.com>
Subject: Re: [PATCH] block: loop: fix deadlock between open and remove
Date: Fri, 11 Jun 2021 11:51:12 -0600	[thread overview]
Message-ID: <b186cfd8-5000-c712-67ca-9919451ba501@kernel.dk> (raw)
In-Reply-To: <20210605140950.5800-1-hch@lst.de>

On 6/5/21 8:09 AM, Christoph Hellwig wrote:
> Commit c76f48eb5c08 ("block: take bd_mutex around delete_partitions in
> del_gendisk") adds disk->part0->bd_mutex in del_gendisk(), this way
> causes the following AB/BA deadlock between removing loop and opening
> loop:
> 
>  1) loop_control_ioctl(LOOP_CTL_REMOVE)
>      -> mutex_lock(&loop_ctl_mutex)
>      -> del_gendisk
>          -> mutex_lock(&disk->part0->bd_mutex)
> 
>  2) blkdev_get_by_dev
>      -> mutex_lock(&disk->part0->bd_mutex)
>      -> lo_open
>          -> mutex_lock(&loop_ctl_mutex)
> 
> Add a new Lo_deleting state to remove the need for clearing
> ->private_data and thus holding loop_ctl_mutex in the ioctl
> LOOP_CTL_REMOVE path.
> 
> Based on an analysis and earlier patch from
> Ming Lei <ming.lei@redhat.com>.

Applied, thanks.

-- 
Jens Axboe


  parent reply	other threads:[~2021-06-11 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05 14:09 [PATCH] block: loop: fix deadlock between open and remove Christoph Hellwig
2021-06-05 15:00 ` Colin Ian King
2021-06-07  0:11 ` Ming Lei
2021-06-11 17:51 ` Jens Axboe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-06-04  0:04 Ming Lei
2021-06-04  6:57 ` Christoph Hellwig
2021-06-04  8:56   ` Ming Lei

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=b186cfd8-5000-c712-67ca-9919451ba501@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=colin.king@canonical.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=pasha.tatashin@soleen.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).