Re: [PATCH v1 3/8] md/raid5: Move common stripe count increment code into __find_stripe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux