[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yk/P0e6E7uVLkMnZ@infradead.org>
Date: Thu, 7 Apr 2022 23:01:53 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Logan Gunthorpe <logang@...tatee.com>
Cc: linux-kernel@...r.kernel.org, linux-raid@...r.kernel.org,
Song Liu <song@...nel.org>, Shaohua Li <shli@...nel.org>,
Guoqing Jiang <guoqing.jiang@...ux.dev>,
Stephen Bates <sbates@...thlin.com>,
Martin Oliveira <Martin.Oliveira@...eticom.com>,
David Sloan <David.Sloan@...eticom.com>
Subject: Re: [PATCH v1 3/8] md/raid5: Move common stripe count increment code
into __find_stripe()
On Thu, Apr 07, 2022 at 10:45:06AM -0600, Logan Gunthorpe wrote:
> static struct stripe_head *__find_stripe(struct r5conf *conf, sector_t sector,
> - short generation)
> + short generation, int hash)
> {
> + int inc_empty_inactive_list_flag;
> struct stripe_head *sh;
>
> pr_debug("__find_stripe, sector %llu\n", (unsigned long long)sector);
> hlist_for_each_entry(sh, stripe_hash(conf, sector), hash)
> if (sh->sector == sector && sh->generation == generation)
> - return sh;
> + goto found;
> pr_debug("__stripe %llu not in cache\n", (unsigned long long)sector);
> return NULL;
> +
> +found:
> + if (!atomic_inc_not_zero(&sh->count)) {
There is a way on list iterators outside the loop body waging right
now. So maybe just leave __find_stripe as-is and add a new
find_get_stripe that wraps it. And then just return early when the
atomic_inc_not_zero dos not succeed and save on one level of
indentation.
Powered by blists - more mailing lists