linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ptb@lab.it.uc3m.es (Peter T. Breuer)
To: linux-raid@vger.kernel.org
Subject: Re: Spares and partitioning huge disks
Date: Mon, 10 Jan 2005 19:37:44 +0100	[thread overview]
Message-ID: <okuab2-u4c.ln1@news.it.uc3m.es> (raw)
In-Reply-To: p0cab2-s27.ln1@news.it.uc3m.es

Peter T. Breuer <ptb@lab.it.uc3m.es> wrote:
> Peter T. Breuer <ptb@lab.it.uc3m.es> wrote:
> > Hmm ...  I must be crackers at 7.39 in the morning.  Surely if the bio
> 
> Perhaps this is more obviously correct (or less obviously incorrect).

So I'll do the commentary for it now. The last hunk of this three hunk
patch is the easiest to explain:


> --- linux-2.6.3/drivers/md/raid1.c.orig Tue Dec 28 00:39:01 2004
> +++ linux-2.6.3/drivers/md/raid1.c      Mon Jan 10 14:05:46 2005
> @@ -708,6 +720,18 @@
>                 read_bio->bi_end_io = raid1_end_request;
>                 read_bio->bi_rw = r1_bio->cmd;
>                 read_bio->bi_private = r1_bio;
> +#ifndef DO_NOT_ADD_ROBUST_READ_SUPPORT
> +               atomic_set(&r1_bio->remaining, 0);
> +               /* count source devices under spinlock */
> +               spin_lock_irq(&conf->device_lock);
> +               for (i = 0;  i < disks; i++) {
> +                       if (conf->mirrors[i].rdev &&
> +                       !conf->mirrors[i].rdev->faulty) {
> +                               atomic_inc(&r1_bio->remaining);
> +                       } 
> +               }
> +               spin_unlock_irq(&conf->device_lock);
> +#endif /* DO_NOT_ADD_ROBUST_READ_SUPPORT */
>  
>                 generic_make_request(read_bio);
>                 return 0;
>

That simply adds to the raid1 make_request code in the READ branch
the same stanza that appears in the WRITE branch already, namely a
calculation of how many working disks there are in the array, which
is put into the "remaining" field of the raid1 master bio being
set up.

So we put the count of valid disks in the "remaining" field during
construction of a raid1 read bio.

If I am off by one, I apologize.  The write size code starts the count
at 1 instead of 0, and I don't know why. 

If anyone wants to see the WRITE side equivalent, it goes:


        for (i = 0;  i < disks; i++) {
                if (conf->mirrors[i].rdev &&
                    !conf->mirrors[i].rdev->faulty) {
                        ...
                        r1_bio->write_bios[i] = bio;
                } else
                        r1_bio->write_bios[i] = NULL;
        }

        atomic_set(&r1_bio->remaining, 1);

        for (i = 0; i < disks; i++) {
                if (!r1_bio->write_bios[i])
                        continue;
                ...
                atomic_inc(&r1_bio->remaining);
                generic_make_request(mbio);
        }

so I reckon that's equivalent, apart from the off-by-one. Explain me
somebody.


In the end_request code, simply, instead of erroring
the current disk out of the array whenever an error happens, do it
only if a WRITE is being handled. We still won't mark the request
uptodate as that's in the else part of the if !uptodate, where we don't
touch. That's the first hunk here.

The second hunk is in the same routine, but down in the READ side of
the code split, further on.  We finish the request not only if we are
utodate (success), but also if we are not uptodate but we are plain out
of disks to try and read from (so the request will be errored since it
is not marked yuptodate still).  We decrement the "remaining" count in
the test.


> @@ -354,9 +354,15 @@
>         /*
>          * this branch is our 'one mirror IO has finished' event handler:
>          */
> -       if (!uptodate)
> -               md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
> -       else
> +       if (!uptodate) {
> +#ifndef DO_NOT_ADD_ROBUST_READ_SUPPORT
> +                /*
> +                 * Only fault disk out of array on write error, not read.
> +                 */
> +                if (r1_bio->cmd == WRITE)
> +#endif /* DO_NOT_ADD_ROBUST_READ_SUPPORT */
> +                       md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
> +        } else
>                 /*
>                  * Set R1BIO_Uptodate in our master bio, so that
>                  * we will return a good error code for to the higher
> @@ -375,7 +381,12 @@
>                 /*
>                  * we have only one bio on the read side
>                  */
> -               if (uptodate)
> +               if (uptodate
> +#ifndef DO_NOT_ADD_ROBUST_READ_SUPPORT
> +                        /* Give up and error if we're last */
> +                        || atomic_dec_and_test(&r1_bio->remaining)
> +#endif /* DO_NOT_ADD_ROBUST_READ_SUPPORT */
> +                        )
>                         raid_end_bio_io(r1_bio);
>                 else {
>                         /*
 

Peter


  reply	other threads:[~2005-01-10 18:37 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-06 14:16 Spares and partitioning huge disks maarten
2005-01-06 16:46 ` Guy
2005-01-06 17:08   ` maarten
2005-01-06 17:31 ` Guy
2005-01-06 18:18   ` maarten
     [not found]     ` <41DD83DA.9040609@h3c.com>
2005-01-06 19:42       ` maarten
2005-01-07 20:59 ` Mario Holbe
2005-01-07 21:57   ` Guy
2005-01-08 10:22     ` Mario Holbe
2005-01-08 12:19       ` maarten
2005-01-08 16:33         ` Guy
2005-01-08 16:58           ` maarten
2005-01-08 14:52     ` Frank van Maarseveen
2005-01-08 15:50       ` Mario Holbe
2005-01-08 16:32       ` Guy
2005-01-08 17:16         ` maarten
2005-01-08 18:55           ` Guy
2005-01-08 19:25             ` maarten
2005-01-08 20:33               ` Mario Holbe
2005-01-08 23:01                 ` maarten
2005-01-09 10:10                   ` Mario Holbe
2005-01-09 16:23                     ` Guy
2005-01-09 16:36                       ` Michael Tokarev
2005-01-09 17:52                         ` Peter T. Breuer
2005-01-09 17:59                           ` Michael Tokarev
2005-01-09 18:34                             ` Peter T. Breuer
2005-01-09 20:28                             ` Guy
2005-01-09 20:47                               ` Peter T. Breuer
2005-01-10  7:19                                 ` Peter T. Breuer
2005-01-10  9:05                                   ` Guy
2005-01-10  9:38                                     ` Peter T. Breuer
2005-01-10 12:31                                   ` Peter T. Breuer
2005-01-10 13:19                                     ` Peter T. Breuer
2005-01-10 18:37                                       ` Peter T. Breuer [this message]
2005-01-11 11:34                                         ` Peter T. Breuer
2005-01-08 23:09               ` Guy
2005-01-09  0:56                 ` maarten
2005-01-13  2:05                 ` Neil Brown
2005-01-13  4:55                   ` Guy
2005-01-13  9:27                   ` Peter T. Breuer
2005-01-13 15:53                     ` Guy
2005-01-13 17:16                       ` Peter T. Breuer
2005-01-13 20:40                         ` Guy
2005-01-13 23:32                           ` Peter T. Breuer
2005-01-14  2:43                             ` Guy
2005-01-08 16:49       ` maarten
2005-01-08 19:01         ` maarten
2005-01-10 16:34           ` maarten
2005-01-10 16:36             ` Gordon Henderson
2005-01-10 17:10               ` maarten
2005-01-16 16:19                 ` 4 questions. Chieftec chassis case CA-01B, resync times, selecting ide driver module loading, raid5 :2 drives on same ide channel Mitchell Laks
2005-01-16 17:53                   ` Gordon Henderson
2005-01-16 18:22                   ` Maarten
2005-01-16 19:39                   ` Guy
2005-01-16 20:55                     ` Maarten
2005-01-16 21:58                       ` Guy
2005-01-10 17:13             ` Spares and partitioning huge disks Guy
2005-01-10 17:35               ` hard disk re-locates bad block on read Guy
2005-01-11 14:34                 ` Tom Coughlan
2005-01-11 22:43                   ` Guy
2005-01-12 13:51                     ` Tom Coughlan
2005-01-10 18:24               ` Spares and partitioning huge disks maarten
2005-01-10 20:09                 ` Guy
2005-01-10 21:21                   ` maarten
2005-01-11  1:04                   ` maarten
2005-01-10 18:40               ` maarten
2005-01-10 19:41                 ` Guy
2005-01-12 11:41               ` RAID-6 Gordon Henderson
2005-01-13  2:11                 ` RAID-6 Neil Brown
2005-01-15 16:12                   ` RAID-6 Gordon Henderson
2005-01-17  8:04                     ` RAID-6 Turbo Fredriksson
2005-01-11 10:09             ` Spares and partitioning huge disks KELEMEN Peter
2005-01-09 19:33         ` Frank van Maarseveen
2005-01-09 21:26           ` maarten
2005-01-09 22:29             ` Frank van Maarseveen
2005-01-09 23:16               ` maarten
2005-01-10  8:15                 ` Frank van Maarseveen
2005-01-14 17:29                   ` Dieter Stueken
2005-01-14 17:46                     ` maarten
2005-01-14 19:14                       ` Derek Piper
2005-01-15  0:13                     ` Michael Tokarev
2005-01-15  9:34                       ` Peter T. Breuer
2005-01-15  9:54                         ` Mikael Abrahamsson
2005-01-15 10:31                           ` Brad Campbell
2005-01-15 11:10                             ` Mikael Abrahamsson
2005-01-15 10:33                           ` Peter T. Breuer
2005-01-15 11:07                             ` Mikael Abrahamsson
2005-01-09 23:20             ` Guy
2005-01-10  7:42               ` Gordon Henderson
2005-01-10  9:03                 ` Guy
2005-01-10 12:21                   ` Stats... [RE: Spares and partitioning huge disks] Gordon Henderson
2005-01-10  0:42             ` Spares and partitioning huge disks Guy
  -- strict thread matches above, loose matches on Subject: below --
2005-01-13  9:53 Bene Martin
2005-01-13 10:11 ` Peter T. Breuer

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=okuab2-u4c.ln1@news.it.uc3m.es \
    --to=ptb@lab.it.uc3m.es \
    --cc=linux-raid@vger.kernel.org \
    /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).