Re: [md PATCH 4/6] md/raid5: change reshape-progress measurement to cope with reshaping backwards.
From: Andre Noll <hidden>
Date: 2009-03-30 09:09:38
Attachments
- signature.asc [application/pgp-signature] 189 bytes
From: Andre Noll <hidden>
Date: 2009-03-30 09:09:38
On 06:54, NeilBrown wrote:
quoted
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