Re: [PATCH 004 of 7] md: Allow devices to be shared between md arrays.

Andrew Morton
2007-12-25T22:05:00Z

On Fri, 14 Dec 2007 17:26:28 +1100 NeilBrown <neilb@suse.de> wrote:

> + mddev_unlock(rdev->mddev);
> + ITERATE_MDDEV(mddev, tmp) {
> + mdk_rdev_t *rdev2;
> +
> + mddev_lock(mddev);
> + ITERATE_RDEV(mddev, rdev2, tmp2)
> + if (test_bit(AllReserved, &rdev2->flags) ||
> + (rdev->bdev == rdev2->bdev &&
> + rdev != rdev2 &&
> + overlaps(rdev->data_offset, rdev->size,
> + rdev2->data_offset, rdev2->size))) {
> + overlap = 1;
> + break;
> + }
> + mddev_unlock(mddev);
> + if (overlap) {
> + mddev_put(mddev);
> + break;
> + }
> + }

eww, ITERATE_MDDEV() and ITERATE_RDEV() are an eyesore.

for_each_mddev() and for_each_rdev() would at least mean the reader doesn't
need to check the implementation when wondering what that `break' is
breaking from.

> #define In_sync 2 /* device is in_sync with rest of array */
> #define WriteMostly 4 /* Avoid reading if at all possible */
> #define BarriersNotsupp 5 /* BIO_RW_BARRIER is not supported */
> +#define AllReserved 6 /* If whole device is reserved for

The naming style here is inconsistent.

A task for the keen would be to convert these to an enum and add some
namespacing prefix to them.