From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: linan666@huaweicloud.com
Cc: song@kernel.org, shli@fb.com, neilb@suse.com, zlliu@suse.com,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com,
yangerkun@huawei.com
Subject: Re: [PATCH v2 1/3] md: Don't clear MD_CLOSING when the raid is about to stop
Date: Thu, 18 Jan 2024 08:35:25 +0100 [thread overview]
Message-ID: <20240118083525.00002b15@linux.intel.com> (raw)
In-Reply-To: <20240117093707.2767209-2-linan666@huaweicloud.com>
On Wed, 17 Jan 2024 17:37:05 +0800
linan666@huaweicloud.com wrote:
> From: Li Nan <linan122@huawei.com>
>
> The raid should not be opened anymore when it is about to be stopped.
> However, other processes can open it again if the flag MD_CLOSING is
> cleared before exiting. From now on, this flag will not be cleared when
> the raid will be stopped.
>
> Fixes: 065e519e71b2 ("md: MD_CLOSING needs to be cleared after called
> md_set_readonly or do_md_stop") Signed-off-by: Li Nan <linan122@huawei.com>
> ---
> drivers/md/md.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9bdd57324c37..4bf821b89415 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6254,7 +6254,15 @@ static void md_clean(struct mddev *mddev)
> mddev->persistent = 0;
> mddev->level = LEVEL_NONE;
> mddev->clevel[0] = 0;
> - mddev->flags = 0;
> + /*
> + * Don't clear MD_CLOSING, or mddev can be opened again.
> + * 'hold_active != 0' means mddev is still in the creation
> + * process and will be used later.
> + */
> + if (mddev->hold_active)
> + mddev->flags = 0;
> + else
> + mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
> mddev->sb_flags = 0;
> mddev->ro = MD_RDWR;
> mddev->metadata_type[0] = 0;
> @@ -7728,6 +7736,12 @@ static int md_ioctl(struct block_device *bdev,
> blk_mode_t mode,
> case STOP_ARRAY:
> err = do_md_stop(mddev, 0, bdev);
> + if (!err)
> + /*
> + * mddev has been stopped, keep flag the
> + * MD_CLOSING to prevent reuse.
> + */
> + did_set_md_closing = false;
Hello Nan,
The meaning of the "did_set_md_closing" is to notify that MD_CLOSING was set in
this function, to know how to behave on error.
You gave it another meaning "Do not clear MD_CLOSING because we want it to stay"
Please consider how to solve this confusion. I see the comment you added but I
think we can have this solved better, maybe just name it as "clear_md_closing"?
Anyway it looks acceptable to me:
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thanks,
Mariusz
next prev parent reply other threads:[~2024-01-18 7:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 9:37 [PATCH v2 0/3] md: Don't clear MD_CLOSING when the raid is about to stop linan666
2024-01-17 9:37 ` [PATCH v2 1/3] " linan666
2024-01-18 7:35 ` Mariusz Tkaczyk [this message]
2024-01-22 2:14 ` Li Nan
2024-01-17 9:37 ` [PATCH v2 2/3] md: factor out a helper mddev_sync_blockdev() to sync mddev linan666
2024-01-18 8:08 ` Mariusz Tkaczyk
2024-01-22 2:15 ` Li Nan
2024-01-17 9:37 ` [PATCH v2 3/3] md: sync blockdev before stopping raid or setting readonly linan666
2024-01-18 8:02 ` Mariusz Tkaczyk
2024-01-24 3:16 ` Li Nan
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=20240118083525.00002b15@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=houtao1@huawei.com \
--cc=linan666@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
--cc=shli@fb.com \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=zlliu@suse.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).