From: NeilBrown <neilb@suse.de>
To: Namhyung Kim <namhyung@gmail.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [md PATCH 16/36] md/raid1: factor several functions out or raid1d()
Date: Thu, 28 Jul 2011 11:39:07 +1000 [thread overview]
Message-ID: <20110728113907.59687a3c@notabene.brown> (raw)
In-Reply-To: <8762mnn2f6.fsf@gmail.com>
On Thu, 28 Jul 2011 00:55:41 +0900 Namhyung Kim <namhyung@gmail.com> wrote:
> NeilBrown <neilb@suse.de> writes:
>
> > raid1d is too big with several deep branches.
> > So separate them out into their own functions.
> >
> > Signed-off-by: NeilBrown <neilb@suse.de>
>
> Reviewed-by: Namhyung Kim <namhyung@gmail.com>
>
> with some whitespace changes below..
Thanks. I made those changes and a couple of other similar ones.
NeilBrown
>
>
> > ---
> >
> > drivers/md/raid1.c | 318 ++++++++++++++++++++++++++--------------------------
> > 1 files changed, 159 insertions(+), 159 deletions(-)
> >
> > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> > index 08ff21a..d7518dc 100644
> > --- a/drivers/md/raid1.c
> > +++ b/drivers/md/raid1.c
> > @@ -1862,21 +1862,168 @@ static int narrow_write_error(r1bio_t *r1_bio, int i)
> > return ok;
> > }
> >
> > +static void handle_sync_write_finished(conf_t *conf, r1bio_t *r1_bio)
> > +{
> > + int m;
> > + int s = r1_bio->sectors;
> > + for (m = 0; m < conf->raid_disks ; m++) {
> > + mdk_rdev_t *rdev = conf->mirrors[m].rdev;
> > + struct bio *bio = r1_bio->bios[m];
> > + if (bio->bi_end_io == NULL)
> > + continue;
> > + if (test_bit(BIO_UPTODATE, &bio->bi_flags) &&
> > + test_bit(R1BIO_MadeGood, &r1_bio->state)) {
> > + rdev_clear_badblocks(rdev,
> > + r1_bio->sector,
> > + r1_bio->sectors);
> rdev_clear_badblocks(rdev, r1_bio->sector, s);
>
> > + }
> > + if (!test_bit(BIO_UPTODATE, &bio->bi_flags) &&
> > + test_bit(R1BIO_WriteError, &r1_bio->state)) {
> > + if (!rdev_set_badblocks(rdev,
> > + r1_bio->sector,
> > + r1_bio->sectors, 0))
> if (!rdev_set_badblocks(rdev, r1_bio->sector, s, 0))
>
> > + md_error(conf->mddev, rdev);
> > + }
> > + }
> > + put_buf(r1_bio);
> > + md_done_sync(conf->mddev, s, 1);
> > +}
> > +
> > +static void handle_write_finished(conf_t *conf, r1bio_t *r1_bio)
> > +{
> > + int m;
> > + for (m = 0; m < conf->raid_disks ; m++)
> > + if (r1_bio->bios[m] == IO_MADE_GOOD) {
> > + mdk_rdev_t *rdev = conf->mirrors[m].rdev;
> > + rdev_clear_badblocks(rdev,
> > + r1_bio->sector,
> > + r1_bio->sectors);
> > + rdev_dec_pending(rdev, conf->mddev);
> > + } else if (r1_bio->bios[m] != NULL) {
> > + /* This drive got a write error. We need to
> > + * narrow down and record precise write
> > + * errors.
> > + */
> > + if (!narrow_write_error(r1_bio, m)) {
> > + md_error(conf->mddev,
> > + conf->mirrors[m].rdev);
> > + /* an I/O failed, we can't clear the bitmap */
> > + set_bit(R1BIO_Degraded, &r1_bio->state);
> > + }
> > + rdev_dec_pending(conf->mirrors[m].rdev,
> > + conf->mddev);
> > + }
> > + if (test_bit(R1BIO_WriteError, &r1_bio->state))
> > + close_write(r1_bio);
> > + raid_end_bio_io(r1_bio);
> > +}
> > +
> > +static void handle_read_error(conf_t *conf, r1bio_t *r1_bio)
> > +{
> > + int disk;
> > + int max_sectors;
> > + mddev_t *mddev = conf->mddev;
> > + struct bio *bio;
> > + char b[BDEVNAME_SIZE];
> > + mdk_rdev_t *rdev;
> > +
> > + clear_bit(R1BIO_ReadError, &r1_bio->state);
> > + /* we got a read error. Maybe the drive is bad. Maybe just
> > + * the block and we can fix it.
> > + * We freeze all other IO, and try reading the block from
> > + * other devices. When we find one, we re-write
> > + * and check it that fixes the read error.
> > + * This is all done synchronously while the array is
> > + * frozen
> > + */
> > + if (mddev->ro == 0) {
> > + freeze_array(conf);
> > + fix_read_error(conf, r1_bio->read_disk,
> > + r1_bio->sector,
> > + r1_bio->sectors);
> r1_bio->sector, r1_bio->sectors);
>
> > + unfreeze_array(conf);
> > + } else
> > + md_error(mddev,
> > + conf->mirrors[r1_bio->read_disk].rdev);
> > +
> > + bio = r1_bio->bios[r1_bio->read_disk];
> > + bdevname(bio->bi_bdev, b);
> > +read_more:
> > + disk = read_balance(conf, r1_bio, &max_sectors);
> > + if (disk == -1) {
> > + printk(KERN_ALERT "md/raid1:%s: %s: unrecoverable I/O"
> > + " read error for block %llu\n",
> > + mdname(mddev), b,
> > + (unsigned long long)r1_bio->sector);
> > + raid_end_bio_io(r1_bio);
> > + } else {
> > + const unsigned long do_sync
> > + = r1_bio->master_bio->bi_rw & REQ_SYNC;
> > + if (bio) {
> > + r1_bio->bios[r1_bio->read_disk] =
> > + mddev->ro ? IO_BLOCKED : NULL;
> > + bio_put(bio);
> > + }
> > + r1_bio->read_disk = disk;
> > + bio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev);
> > + md_trim_bio(bio,
> > + r1_bio->sector - bio->bi_sector,
> > + max_sectors);
> md_trim_bio(bio, r1_bio->sector - bio->bi_sector, max_sectors);
>
> Thanks.
next prev parent reply other threads:[~2011-07-28 1:39 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-21 2:58 [md PATCH 00/36] md patches for 3.1 - part 2: bad block logs NeilBrown
2011-07-21 2:58 ` [md PATCH 03/36] md: don't allow arrays to contain devices with bad blocks NeilBrown
2011-07-22 15:47 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 04/36] md: load/store badblock list from v1.x metadata NeilBrown
2011-07-22 16:34 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 02/36] md/bad-block-log: add sysfs interface for accessing bad-block-log NeilBrown
2011-07-22 15:43 ` Namhyung Kim
2011-07-26 2:29 ` NeilBrown
2011-07-26 5:17 ` Namhyung Kim
2011-07-26 8:48 ` Namhyung Kim
2011-07-26 15:03 ` [PATCH v2] md: add documentation for bad block log Namhyung Kim
2011-07-27 1:05 ` [md PATCH 02/36] md/bad-block-log: add sysfs interface for accessing bad-block-log NeilBrown
2011-07-21 2:58 ` [md PATCH 01/36] md: beginnings of bad block management NeilBrown
2011-07-22 15:03 ` Namhyung Kim
2011-07-26 2:26 ` NeilBrown
2011-07-26 5:17 ` Namhyung Kim
2011-07-22 16:52 ` Namhyung Kim
2011-07-26 3:20 ` NeilBrown
2011-07-21 2:58 ` [md PATCH 09/36] md: make it easier to wait for bad blocks to be acknowledged NeilBrown
2011-07-26 16:04 ` Namhyung Kim
2011-07-27 1:18 ` NeilBrown
2011-07-21 2:58 ` [md PATCH 12/36] md/raid1: store behind-write pages in bi_vecs NeilBrown
2011-07-27 15:16 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 10/36] md/raid1: avoid writing to known-bad blocks on known-bad drives NeilBrown
2011-07-27 4:09 ` Namhyung Kim
2011-07-27 4:19 ` NeilBrown
2011-07-21 2:58 ` [md PATCH 06/36] md/raid1: avoid reading from known bad blocks NeilBrown
2011-07-26 14:06 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 11/36] md/raid1: clear bad-block record when write succeeds NeilBrown
2011-07-27 5:05 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 07/36] md/raid1: avoid reading known bad blocks during resync NeilBrown
2011-07-26 14:25 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 14/36] md/raid1: record badblocks found during resync etc NeilBrown
2011-07-27 15:39 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 13/36] md/raid1: Handle write errors by updating badblock log NeilBrown
2011-07-27 15:28 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 08/36] md: add 'write_error' flag to component devices NeilBrown
2011-07-26 15:22 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 05/36] md: Disable bad blocks and v0.90 metadata NeilBrown
2011-07-22 17:02 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 20/36] md/raid5. Don't write to known bad block on doubtful devices NeilBrown
2011-07-21 2:58 ` [md PATCH 22/36] md/raid10: simplify/reindent some loops NeilBrown
2011-07-21 2:58 ` [md PATCH 18/36] md/raid5: use bad-block log to improve handling of uncorrectable read errors NeilBrown
2011-07-21 2:58 ` [md PATCH 17/36] md/raid5: avoid reading from known bad blocks NeilBrown
2011-07-21 2:58 ` [md PATCH 15/36] md/raid1: improve handling of read failure during recovery NeilBrown
2011-07-27 15:45 ` Namhyung Kim
2011-07-21 2:58 ` [md PATCH 21/36] md/raid5: Clear bad blocks on successful write NeilBrown
2011-07-21 2:58 ` [md PATCH 24/36] md/raid10: avoid reading from known bad blocks - part 1 NeilBrown
2011-07-21 2:58 ` [md PATCH 16/36] md/raid1: factor several functions out or raid1d() NeilBrown
2011-07-27 15:55 ` Namhyung Kim
2011-07-28 1:39 ` NeilBrown [this message]
2011-07-21 2:58 ` [md PATCH 23/36] md/raid10: Split handle_read_error out from raid10d NeilBrown
2011-07-21 2:58 ` [md PATCH 19/36] md/raid5: write errors should be recorded as bad blocks if possible NeilBrown
2011-07-21 2:58 ` [md PATCH 28/36] md/raid10 record bad blocks as needed during recovery NeilBrown
2011-07-21 2:58 ` [md PATCH 25/36] md/raid10: avoid reading from known bad blocks - part 2 NeilBrown
2011-07-21 2:58 ` [md PATCH 34/36] md/raid10: simplify read error handling during recovery NeilBrown
2011-07-21 2:58 ` [md PATCH 31/36] md/raid10: Handle write errors by updating badblock log NeilBrown
2011-07-21 2:58 ` [md PATCH 26/36] md/raid10 - avoid reading from known bad blocks - part 3 NeilBrown
2011-07-21 2:58 ` [md PATCH 32/36] md/raid10: attempt to fix read errors during resync/check NeilBrown
2011-07-21 2:58 ` [md PATCH 30/36] md/raid10: clear bad-block record when write succeeds NeilBrown
2011-07-21 2:58 ` [md PATCH 29/36] md/raid10: avoid writing to known bad blocks on known bad drives NeilBrown
2011-07-21 2:58 ` [md PATCH 33/36] md/raid10: record bad blocks due to write errors during resync/recovery NeilBrown
2011-07-21 2:58 ` [md PATCH 27/36] md/raid10: avoid reading known bad blocks " NeilBrown
2011-07-21 2:58 ` [md PATCH 35/36] md/raid10: Handle read errors during recovery better NeilBrown
2011-07-21 2:58 ` [md PATCH 36/36] md/raid10: handle further errors during fix_read_error better NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110728113907.59687a3c@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=namhyung@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).