From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>, Jens Axboe <axboe@kernel.dk>,
Jan Kara <jack@suse.cz>, Denis Efremov <efremov@linux.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 4/5] block: assert that we're not holding open_mutex over blk_report_disk_dead
Date: Wed, 18 Oct 2023 11:18:38 +0800 [thread overview]
Message-ID: <ZS9OjlDuELDHJ4XM@fedora> (raw)
In-Reply-To: <20231017184823.1383356-5-hch@lst.de>
On Tue, Oct 17, 2023 at 08:48:22PM +0200, Christoph Hellwig wrote:
> From: Christian Brauner <brauner@kernel.org>
>
> blk_report_disk_dead() has the following major callers:
>
> (1) del_gendisk()
> (2) blk_mark_disk_dead()
>
> Since del_gendisk() acquires disk->open_mutex it's clear that all
> callers are assumed to be called without disk->open_mutex held.
> In turn, blk_report_disk_dead() is called without disk->open_mutex held
> in del_gendisk().
>
> All callers of blk_mark_disk_dead() call it without disk->open_mutex as
> well.
>
> Ensure that it is clear that blk_report_disk_dead() is called without
> disk->open_mutex on purpose by asserting it and a comment in the code.
>
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/genhd.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 4a16a424f57d4f..c9d06f72c587e8 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -559,6 +559,13 @@ static void blk_report_disk_dead(struct gendisk *disk, bool surprise)
> struct block_device *bdev;
> unsigned long idx;
>
> + /*
> + * On surprise disk removal, bdev_mark_dead() may call into file
> + * systems below. Make it clear that we're expecting to not hold
> + * disk->open_mutex.
> + */
> + lockdep_assert_not_held(&disk->open_mutex);
> +
> rcu_read_lock();
> xa_for_each(&disk->part_tbl, idx, bdev) {
> if (!kobject_get_unless_zero(&bdev->bd_device.kobj))
Reviewed-by: Ming Lei <ming.lei@redhat.com>
thanks,
Ming
next prev parent reply other threads:[~2023-10-18 3:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 18:48 don't take s_umount under open_mutex Christoph Hellwig
2023-10-17 18:48 ` [PATCH 1/5] block: simplify bdev_del_partition() Christoph Hellwig
2023-10-18 2:33 ` Ming Lei
2023-10-17 18:48 ` [PATCH 2/5] block: WARN_ON_ONCE() when we remove active partitions Christoph Hellwig
2023-10-18 2:36 ` Ming Lei
2023-10-19 8:31 ` Jan Kara
2023-10-17 18:48 ` [PATCH 3/5] block: move bdev_mark_dead out of disk_check_media_change Christoph Hellwig
2023-10-18 3:16 ` Ming Lei
2023-10-18 6:46 ` Christoph Hellwig
2023-10-18 9:15 ` Ming Lei
2023-10-18 12:10 ` Christoph Hellwig
2023-10-18 9:24 ` Christian Brauner
2023-10-19 5:57 ` Christoph Hellwig
2023-10-19 7:24 ` Christian Brauner
2023-10-19 8:34 ` Jan Kara
2023-10-17 18:48 ` [PATCH 4/5] block: assert that we're not holding open_mutex over blk_report_disk_dead Christoph Hellwig
2023-10-18 3:18 ` Ming Lei [this message]
2023-10-19 8:43 ` Jan Kara
2023-10-17 18:48 ` [PATCH 5/5] fs: assert that open_mutex isn't held over holder ops Christoph Hellwig
2023-10-18 9:53 ` Ming Lei
2023-10-19 8:43 ` Jan Kara
2023-10-19 9:35 ` don't take s_umount under open_mutex Christian Brauner
2023-10-19 11:27 ` Jens Axboe
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=ZS9OjlDuELDHJ4XM@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=efremov@linux.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@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).