2007-01-23 00:28:11

by NeilBrown

[permalink] [raw]
Subject: [PATCH 002 of 4] md: Make 'repair' actually work for raid1.


When 'repair' finds a block that is different one the various
parts of the mirror. it is meant to write a chosen good version
to the others. However it currently writes out the original data
to each. The memcpy to make all the data the same is missing.


Signed-off-by: Neil Brown <[email protected]>

### Diffstat output
./drivers/md/raid1.c | 5 +++++
1 file changed, 5 insertions(+)

diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
--- .prev/drivers/md/raid1.c 2007-01-23 11:13:45.000000000 +1100
+++ ./drivers/md/raid1.c 2007-01-23 11:23:43.000000000 +1100
@@ -1221,6 +1221,11 @@ static void sync_request_write(mddev_t *
sbio->bi_sector = r1_bio->sector +
conf->mirrors[i].rdev->data_offset;
sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
+ for (j = 0; j < vcnt ; j++)
+ memcpy(page_address(sbio->bi_io_vec[j].bv_page),
+ page_address(pbio->bi_io_vec[j].bv_page),
+ PAGE_SIZE);
+
}
}
}


2007-01-24 06:58:00

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 002 of 4] md: Make 'repair' actually work for raid1.

On Tue, 23 Jan 2007 11:26:52 +1100
NeilBrown <[email protected]> wrote:

> + for (j = 0; j < vcnt ; j++)
> + memcpy(page_address(sbio->bi_io_vec[j].bv_page),
> + page_address(pbio->bi_io_vec[j].bv_page),
> + PAGE_SIZE);

I trust these BIOs are known to only contain suitably-allocated, MD-private
pages? Because if these pages can be user pages then this change is
spectacularly buggy ;)

2007-01-24 07:27:50

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH 002 of 4] md: Make 'repair' actually work for raid1.

On Tuesday January 23, [email protected] wrote:
> On Tue, 23 Jan 2007 11:26:52 +1100
> NeilBrown <[email protected]> wrote:
>
> > + for (j = 0; j < vcnt ; j++)
> > + memcpy(page_address(sbio->bi_io_vec[j].bv_page),
> > + page_address(pbio->bi_io_vec[j].bv_page),
> > + PAGE_SIZE);
>
> I trust these BIOs are known to only contain suitably-allocated, MD-private
> pages? Because if these pages can be user pages then this change is
> spectacularly buggy ;)

Your trust is well placed.
This is in the 'resync' path, were all buffers are allocated in lowmem
and are full pages and so-forth, so this is perfectly safe.

NeilBrown