From: "Dae R. Jeong" <dae.r.jeong@kaist.ac.kr>
To: Song Liu <song@kernel.org>
Cc: yjkwon@kaist.ac.kr, linux-raid <linux-raid@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: WARNING in md_ioctl
Date: Mon, 19 Oct 2020 16:03:19 +0900 [thread overview]
Message-ID: <20201019070319.GA1811280@dragonet> (raw)
In-Reply-To: <CAPhsuW583=org7AOR-W2vcQV3pTBxin2LG1tb3On=x6VtjXvxQ@mail.gmail.com>
> diff --git i/drivers/md/md.c w/drivers/md/md.c
> index 6072782070230..49442a3f4605b 100644
> --- i/drivers/md/md.c
> +++ w/drivers/md/md.c
> @@ -7591,8 +7591,10 @@ static int md_ioctl(struct block_device *bdev,
> fmode_t mode,
> err = -EBUSY;
> goto out;
> }
> - WARN_ON_ONCE(test_bit(MD_CLOSING, &mddev->flags));
> - set_bit(MD_CLOSING, &mddev->flags);
> + if (test_and_set_bit(MD_CLOSING, &mddev->flags)) {
> + err = -EBUSY;
> + goto out;
> + }
> did_set_md_closing = true;
> mutex_unlock(&mddev->open_mutex);
> sync_blockdev(bdev);
>
> Could you please test whether this fixes the issue?
Since &mddev->open_mutex is held when testing a bit of mddev->flags, I
modified the code just a little bit by putting mutex_unlock() as
belows.
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 98bac4f304ae..643f7f5be49b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7590,8 +7590,11 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
err = -EBUSY;
goto out;
}
- WARN_ON_ONCE(test_bit(MD_CLOSING, &mddev->flags));
- set_bit(MD_CLOSING, &mddev->flags);
+ if (test_and_set_bit(MD_CLOSING, &mddev->flags)) {
+ mutex_unlock(&mddev->open_mutex);
+ err = -EBUSY;
+ goto out;
+ }
did_set_md_closing = true;
mutex_unlock(&mddev->open_mutex);
sync_blockdev(bdev);
The warning no longer recurs (of course, we removed
WARN_ON_ONCE()). As I am not familiar with this code, I do not see any
other problem.
Best regards,
Dae R. Jeong
next prev parent reply other threads:[~2020-10-19 7:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-17 11:06 WARNING in md_ioctl Dae R. Jeong
2020-10-19 6:18 ` Song Liu
2020-10-19 7:03 ` Dae R. Jeong [this message]
2020-10-21 5:28 ` Song Liu
2020-10-22 0:24 ` Dae R. Jeong
-- strict thread matches above, loose matches on Subject: below --
2018-04-30 1:00 syzbot
2019-11-25 22:37 ` syzbot
2019-11-26 8:42 ` Daniel Vetter
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=20201019070319.GA1811280@dragonet \
--to=dae.r.jeong@kaist.ac.kr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yjkwon@kaist.ac.kr \
/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).