From: Yu Kuai <yukuai1@huaweicloud.com>
To: Yu Kuai <yukuai1@huaweicloud.com>, Christoph Hellwig <hch@lst.de>,
Song Liu <song@kernel.org>
Cc: linux-raid@vger.kernel.org, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH 1/2] md/raid0: don't free conf on raid0_run failure
Date: Fri, 7 Jun 2024 14:17:14 +0800 [thread overview]
Message-ID: <703d7cf4-e869-d96c-1778-818b29192a3e@huaweicloud.com> (raw)
In-Reply-To: <45ab7eb3-02d4-dbc2-8956-1387a008e53f@huaweicloud.com>
Hi,
在 2024/06/07 14:08, Yu Kuai 写道:
> 在 2024/06/05 1:25, Christoph Hellwig 写道:
>> The core md code calls the ->free method which already frees conf.
>>
>> Fixes: 0c031fd37f69 ("md: Move alloc/free acct bioset in to personality")
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> LGTM
> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Sorry that I just noticed that the sysfs api level_store() calls the
pers->run() as well, and it didn't handle failure by pers->free().
It's weried that the api will return success in this case, and after
this patch, it will require __md_stop() to free the conf.
Can you also fix the level_store()? By checking pers->run() and if it
failed, call pers->free() and return error.
Thanks,
Kuai
>
>> ---
>> drivers/md/raid0.c | 21 +++++----------------
>> 1 file changed, 5 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
>> index c5d4aeb68404c9..81c01347cd24e6 100644
>> --- a/drivers/md/raid0.c
>> +++ b/drivers/md/raid0.c
>> @@ -365,18 +365,13 @@ static sector_t raid0_size(struct mddev *mddev,
>> sector_t sectors, int raid_disks
>> return array_sectors;
>> }
>> -static void free_conf(struct mddev *mddev, struct r0conf *conf)
>> -{
>> - kfree(conf->strip_zone);
>> - kfree(conf->devlist);
>> - kfree(conf);
>> -}
>> -
>> static void raid0_free(struct mddev *mddev, void *priv)
>> {
>> struct r0conf *conf = priv;
>> - free_conf(mddev, conf);
>> + kfree(conf->strip_zone);
>> + kfree(conf->devlist);
>> + kfree(conf);
>> }
>> static int raid0_set_limits(struct mddev *mddev)
>> @@ -415,7 +410,7 @@ static int raid0_run(struct mddev *mddev)
>> if (!mddev_is_dm(mddev)) {
>> ret = raid0_set_limits(mddev);
>> if (ret)
>> - goto out_free_conf;
>> + return ret;
>> }
>> /* calculate array device size */
>> @@ -427,13 +422,7 @@ static int raid0_run(struct mddev *mddev)
>> dump_zones(mddev);
>> - ret = md_integrity_register(mddev);
>> - if (ret)
>> - goto out_free_conf;
>> - return 0;
>> -out_free_conf:
>> - free_conf(mddev, conf);
>> - return ret;
>> + return md_integrity_register(mddev);
>> }
>> /*
>>
>
> .
>
next prev parent reply other threads:[~2024-06-07 6:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 17:25 fix ->run failure handling Christoph Hellwig
2024-06-04 17:25 ` [PATCH 1/2] md/raid0: don't free conf on raid0_run failure Christoph Hellwig
2024-06-07 6:08 ` Yu Kuai
2024-06-07 6:17 ` Yu Kuai [this message]
2024-06-07 6:19 ` Christoph Hellwig
2024-06-04 17:25 ` [PATCH 2/2] md/raid1: " Christoph Hellwig
2024-06-10 20:58 ` fix ->run failure handling Song Liu
2024-06-11 6:13 ` Christoph Hellwig
2024-06-12 16:36 ` Song Liu
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=703d7cf4-e869-d96c-1778-818b29192a3e@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=hch@lst.de \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yukuai3@huawei.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).