From: Shaohua Li <shli@kernel.org>
To: Heinz Mauelshagen <heinzm@redhat.com>
Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org,
linux-raid@vger.kernel.org
Subject: Re: [PATCH] md: fix md_write_start() deadlock w/o metadata devices
Date: Sun, 18 Feb 2018 10:12:21 -0800 [thread overview]
Message-ID: <20180218181221.a5l5nzgav7s6smor@kernel.org> (raw)
In-Reply-To: <054eff295e0cd2df2b11a3f9ba3b3d66e89beb47.1517609290.git.heinzm@redhat.com>
On Fri, Feb 02, 2018 at 11:13:19PM +0100, Heinz Mauelshagen wrote:
> If no metadata devices are configured on raid1/4/5/6/10
> (e.g. via dm-raid), md_write_start() unconditionally waits
> for superblocks to be written thus deadlocking.
>
> Fix introduces mddev->has_superblocks bool, defines it in md_run()
> and checks for it in md_write_start() to conditionally avoid waiting.
>
> Once on it, check for non-existing superblocks in md_super_write().
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=198647
> Fixes: cc27b0c78c796 ("md: fix deadlock between mddev_suspend() and md_write_start()")
Applied, thanks!
> Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
> ---
> drivers/md/md.c | 10 ++++++++++
> drivers/md/md.h | 2 ++
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 0081ace39a64..8a7e7034962c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -801,6 +801,9 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
> struct bio *bio;
> int ff = 0;
>
> + if (!page)
> + return;
> +
> if (test_bit(Faulty, &rdev->flags))
> return;
>
> @@ -5452,6 +5455,7 @@ int md_run(struct mddev *mddev)
> * the only valid external interface is through the md
> * device.
> */
> + mddev->has_superblocks = false;
> rdev_for_each(rdev, mddev) {
> if (test_bit(Faulty, &rdev->flags))
> continue;
> @@ -5465,6 +5469,9 @@ int md_run(struct mddev *mddev)
> set_disk_ro(mddev->gendisk, 1);
> }
>
> + if (rdev->sb_page)
> + mddev->has_superblocks = true;
> +
> /* perform some consistency tests on the device.
> * We don't want the data to overlap the metadata,
> * Internal Bitmap issues have been handled elsewhere.
> @@ -8049,6 +8056,7 @@ EXPORT_SYMBOL(md_done_sync);
> bool md_write_start(struct mddev *mddev, struct bio *bi)
> {
> int did_change = 0;
> +
> if (bio_data_dir(bi) != WRITE)
> return true;
>
> @@ -8081,6 +8089,8 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
> rcu_read_unlock();
> if (did_change)
> sysfs_notify_dirent_safe(mddev->sysfs_state);
> + if (!mddev->has_superblocks)
> + return true;
> wait_event(mddev->sb_wait,
> !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags) ||
> mddev->suspended);
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index 58cd20a5e85e..fbc925cce810 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -468,6 +468,8 @@ struct mddev {
> void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev);
> struct md_cluster_info *cluster_info;
> unsigned int good_device_nr; /* good device num within cluster raid */
> +
> + bool has_superblocks:1;
> };
>
> enum recovery_flags {
> --
> 2.14.3
>
prev parent reply other threads:[~2018-02-18 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 22:13 Heinz Mauelshagen
2018-02-18 18:12 ` Shaohua Li [this message]
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=20180218181221.a5l5nzgav7s6smor@kernel.org \
--to=shli@kernel.org \
--cc=dm-devel@redhat.com \
--cc=heinzm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@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
all inboxes | Powered by JetHome®