From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: Qu Wenruo <wqu@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH RFC 1/5] btrfs: scrub: make scrub_ctx::stripes dynamically allocated
Date: Tue, 20 Jun 2023 08:43:01 +0000 [thread overview]
Message-ID: <d085f531-db0c-13ca-217a-a63e804d2ef2@wdc.com> (raw)
In-Reply-To: <93e32d86ead00d7596072aa2f1fbc59022ebb3ad.1686977659.git.wqu@suse.com>
On 17.06.23 07:08, Qu Wenruo wrote:
> @@ -315,9 +318,10 @@ static noinline_for_stack void scrub_free_ctx(struct scrub_ctx *sctx)
> if (!sctx)
> return;
>
> - for (i = 0; i < SCRUB_STRIPES_PER_SCTX; i++)
> - release_scrub_stripe(&sctx->stripes[i]);
> -
> + if (sctx->stripes)
> + for (i = 0; i < sctx->nr_stripes; i++)
> + release_scrub_stripe(&sctx->stripes[i]);
I think we're usually guarding the inner part of the if by {}.
> + kfree(sctx->stripes);
> kfree(sctx);
But it could even be simplified to:
static noinline_for_stack void scrub_free_ctx(struct scrub_ctx *sctx)
{
int i;
if (!sctx)
return;
free_scrub_stripes(sctx);
kfree(sctx);
}
> +static void free_scrub_stripes(struct scrub_ctx *sctx)
> +{
+ if (!sctx->stripes)
return;
> + for (int i = 0; i < sctx->nr_stripes; i++)
> + release_scrub_stripe(&sctx->stripes[i]);
> + kfree(sctx->stripes);
> + sctx->nr_stripes = 0;
> + sctx->stripes = NULL;
> +}
> +
Otherwise looks good to me
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
next prev parent reply other threads:[~2023-06-20 8:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-17 5:07 [PATCH RFC 0/5] btrfs: scrub: introduce SCRUB_LOGICAL flag Qu Wenruo
2023-06-17 5:07 ` [PATCH RFC 1/5] btrfs: scrub: make scrub_ctx::stripes dynamically allocated Qu Wenruo
2023-06-20 8:43 ` Johannes Thumshirn [this message]
2023-06-17 5:07 ` [PATCH RFC 2/5] btrfs: scrub: introduce the skeleton for logical-scrub Qu Wenruo
2023-06-20 8:50 ` Johannes Thumshirn
2023-06-17 5:07 ` [PATCH RFC 3/5] btrfs: scrub: extract the common preparation before scrubbing a block group Qu Wenruo
2023-06-20 8:55 ` Johannes Thumshirn
2023-06-17 5:07 ` [PATCH RFC 4/5] btrfs: scrub: implement the basic extent iteration code Qu Wenruo
2023-06-17 5:07 ` [PATCH RFC 5/5] btrfs: scrub: implement the repair part of scrub logical Qu Wenruo
2023-06-20 9:24 ` Johannes Thumshirn
2023-06-17 5:12 ` [PATCH RFC 0/5] btrfs: scrub: introduce SCRUB_LOGICAL flag Qu Wenruo
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=d085f531-db0c-13ca-217a-a63e804d2ef2@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@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