lkml.org 
[lkml]   [2022]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2022-04-08 08:03    [W:0.119 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site