Re: [md PATCH 4/6] md/raid5: change reshape-progress measurement to cope with reshaping backwards.

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

 



On 06:54, NeilBrown wrote:
> > Is it only me who finds such code hard to comprehend?  Given that
> > the patch adds checks of the form
> >
> > 	(delta < 0 && s < r) || (delta >= 0 && s >= r)
> 
> They are really of the form
>        delta < 0 ? s < r : s >= r

Yeah right. This underlines that it is easy to get wrong :)

>  static inline inorder(mddev_t *mddev, sector_t a, sector_t b)
>  {
>       if (mddev->delta_disks < 0)
>                 return b > a;
>       else
>                 return a <= b;
>  }
> 
> However sometimes it is '<' vs '>=' and sometimes  '<' vs '>',
> so I'm not sure it would apply universally.....

Return -1, 0, or 1, i.e. something like this:

static inline int inorder(int delta, sector_t a, sector_t b)
{
	int x;

	if (a < b)
		x = 1;
	else if (a > b)
		x = -1;
	else x = 0;
	if (delta < 0)
		x = -x;
	return x;
}

Of course, the callers would need to be adapted slightly.

Thanks
Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

Attachment: signature.asc
Description: Digital signature


[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