]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/vinum/vinumrevive.c
This commit was generated by cvs2svn to compensate for changes in r102514,
[FreeBSD/FreeBSD.git] / sys / dev / vinum / vinumrevive.c
1 /*-
2  * Copyright (c) 1997, 1998, 1999
3  *      Nan Yang Computer Services Limited.  All rights reserved.
4  *
5  *  Parts copyright (c) 1997, 1998 Cybernet Corporation, NetMAX project.
6  *
7  *  Written by Greg Lehey
8  *
9  *  This software is distributed under the so-called ``Berkeley
10  *  License'':
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *      This product includes software developed by Nan Yang Computer
23  *      Services Limited.
24  * 4. Neither the name of the Company nor the names of its contributors
25  *    may be used to endorse or promote products derived from this software
26  *    without specific prior written permission.
27  *
28  * This software is provided ``as is'', and any express or implied
29  * warranties, including, but not limited to, the implied warranties of
30  * merchantability and fitness for a particular purpose are disclaimed.
31  * In no event shall the company or contributors be liable for any
32  * direct, indirect, incidental, special, exemplary, or consequential
33  * damages (including, but not limited to, procurement of substitute
34  * goods or services; loss of use, data, or profits; or business
35  * interruption) however caused and on any theory of liability, whether
36  * in contract, strict liability, or tort (including negligence or
37  * otherwise) arising in any way out of the use of this software, even if
38  * advised of the possibility of such damage.
39  *
40  * $Id: vinumrevive.c,v 1.15 2001/05/23 23:04:48 grog Exp grog $
41  * $FreeBSD$
42  */
43
44 #include <dev/vinum/vinumhdr.h>
45 #include <dev/vinum/request.h>
46
47 /*
48  * Revive a block of a subdisk.  Return an error
49  * indication.  EAGAIN means successful copy, but
50  * that more blocks remain to be copied.  EINVAL
51  * means that the subdisk isn't associated with a
52  * plex (which means a programming error if we get
53  * here at all; FIXME).
54  */
55
56 int
57 revive_block(int sdno)
58 {
59     int s;                                                  /* priority level */
60     struct sd *sd;
61     struct plex *plex;
62     struct volume *vol;
63     struct buf *bp;
64     int error = EAGAIN;
65     int size;                                               /* size of revive block, bytes */
66     daddr_t plexblkno;                                      /* lblkno in plex */
67     int psd;                                                /* parity subdisk number */
68     u_int64_t stripe;                                       /* stripe number */
69     int paritysd = 0;                                       /* set if this is the parity stripe */
70     struct rangelock *lock;                                 /* for locking */
71     daddr_t stripeoffset;                                   /* offset in stripe */
72
73     plexblkno = 0;                                          /* to keep the compiler happy */
74     sd = &SD[sdno];
75     lock = NULL;
76     if (sd->plexno < 0)                                     /* no plex? */
77         return EINVAL;
78     plex = &PLEX[sd->plexno];                               /* point to plex */
79     if (plex->volno >= 0)
80         vol = &VOL[plex->volno];
81     else
82         vol = NULL;
83
84     if ((sd->revive_blocksize == 0)                         /* no block size */
85     ||(sd->revive_blocksize & ((1 << DEV_BSHIFT) - 1)))     /* or invalid block size */
86         sd->revive_blocksize = DEFAULT_REVIVE_BLOCKSIZE;
87     else if (sd->revive_blocksize > MAX_REVIVE_BLOCKSIZE)
88         sd->revive_blocksize = MAX_REVIVE_BLOCKSIZE;
89     size = min(sd->revive_blocksize >> DEV_BSHIFT, sd->sectors - sd->revived) << DEV_BSHIFT;
90     sd->reviver = curproc->p_pid;                           /* note who last had a bash at it */
91
92     /* Now decide where to read from */
93     switch (plex->organization) {
94     case plex_concat:
95         plexblkno = sd->revived + sd->plexoffset;           /* corresponding address in plex */
96         break;
97
98     case plex_striped:
99         stripeoffset = sd->revived % plex->stripesize;      /* offset from beginning of stripe */
100         if (stripeoffset + (size >> DEV_BSHIFT) > plex->stripesize)
101             size = (plex->stripesize - stripeoffset) << DEV_BSHIFT;
102         plexblkno = sd->plexoffset                          /* base */
103             + (sd->revived - stripeoffset) * plex->subdisks /* offset to beginning of stripe */
104             + stripeoffset;                                 /* offset from beginning of stripe */
105         break;
106
107     case plex_raid4:
108     case plex_raid5:
109         stripeoffset = sd->revived % plex->stripesize;      /* offset from beginning of stripe */
110         plexblkno = sd->plexoffset                          /* base */
111             + (sd->revived - stripeoffset) * (plex->subdisks - 1) /* offset to beginning of stripe */
112             +stripeoffset;                                  /* offset from beginning of stripe */
113         stripe = (sd->revived / plex->stripesize);          /* stripe number */
114
115         /* Make sure we don't go beyond the end of the band. */
116         size = min(size, (plex->stripesize - stripeoffset) << DEV_BSHIFT);
117         if (plex->organization == plex_raid4)
118             psd = plex->subdisks - 1;                       /* parity subdisk for this stripe */
119         else
120             psd = plex->subdisks - 1 - stripe % plex->subdisks; /* parity subdisk for this stripe */
121         paritysd = plex->sdnos[psd] == sdno;                /* note if it's the parity subdisk */
122
123         /*
124          * Now adjust for the strangenesses
125          * in RAID-4 and RAID-5 striping.
126          */
127         if (sd->plexsdno > psd)                             /* beyond the parity stripe, */
128             plexblkno -= plex->stripesize;                  /* one stripe less */
129         else if (paritysd)
130             plexblkno -= plex->stripesize * sd->plexsdno;   /* go back to the beginning of the band */
131         break;
132
133     case plex_disorg:                                       /* to keep the compiler happy */
134         break;
135     }
136
137     if (paritysd) {                                         /* we're reviving a parity block, */
138         bp = parityrebuild(plex, sd->revived, size, rebuildparity, &lock, NULL); /* do the grunt work */
139         if (bp == NULL)                                     /* no buffer space */
140             return ENOMEM;                                  /* chicken out */
141     } else {                                                /* data block */
142         s = splbio();
143         bp = geteblk(size);                                 /* Get a buffer */
144         splx(s);
145         if (bp == NULL)
146             return ENOMEM;
147
148         /*
149          * Amount to transfer: block size, unless it
150          * would overlap the end.
151          */
152         bp->b_bcount = size;
153         bp->b_resid = bp->b_bcount;
154         bp->b_blkno = plexblkno;                            /* start here */
155         if (isstriped(plex))                                /* we need to lock striped plexes */
156             lock = lockrange(plexblkno << DEV_BSHIFT, bp, plex); /* lock it */
157         if (vol != NULL)                                    /* it's part of a volume, */
158             /*
159                * First, read the data from the volume.  We
160                * don't care which plex, that's bre's job.
161              */
162             bp->b_dev = VINUMDEV(plex->volno, 0, 0, VINUM_VOLUME_TYPE); /* create the device number */
163         else                                                /* it's an unattached plex */
164             bp->b_dev = VINUM_PLEX(sd->plexno);             /* create the device number */
165
166         bp->b_iocmd = BIO_READ;                             /* either way, read it */
167         bp->b_flags = 0;
168         vinumstart(bp, 1);
169         bufwait(bp);
170     }
171
172     if (bp->b_ioflags & BIO_ERROR)
173         error = bp->b_error;
174     else
175         /* Now write to the subdisk */
176     {
177         bp->b_dev = VINUM_SD(sdno);                         /* create the device number */
178         bp->b_flags &= ~B_DONE;                             /* no longer done */
179         bp->b_ioflags = 0;
180         bp->b_iocmd = BIO_WRITE;
181         bp->b_resid = bp->b_bcount;
182         bp->b_blkno = sd->revived;                          /* write it to here */
183         sdio(bp);                                           /* perform the I/O */
184         bufwait(bp);
185         if (bp->b_ioflags & BIO_ERROR)
186             error = bp->b_error;
187         else {
188             sd->revived += bp->b_bcount >> DEV_BSHIFT;      /* moved this much further down */
189             if (sd->revived >= sd->sectors) {               /* finished */
190                 sd->revived = 0;
191                 set_sd_state(sdno, sd_up, setstate_force);  /* bring the sd up */
192                 log(LOG_INFO, "vinum: %s is %s\n", sd->name, sd_state(sd->state));
193                 save_config();                              /* and save the updated configuration */
194                 error = 0;                                  /* we're done */
195             }
196         }
197         if (lock)                                           /* we took a lock, */
198             unlockrange(sd->plexno, lock);                  /* give it back */
199         while (sd->waitlist) {                              /* we have waiting requests */
200 #ifdef VINUMDEBUG
201             struct request *rq = sd->waitlist;
202
203             if (debug & DEBUG_REVIVECONFLICT)
204                 log(LOG_DEBUG,
205                     "Relaunch revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%llx, length %ld\n",
206                     rq->sdno,
207                     rq,
208                     rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
209                     major(rq->bp->b_dev),
210                     minor(rq->bp->b_dev),
211                     rq->bp->b_blkno,
212                     rq->bp->b_bcount);
213 #endif
214             launch_requests(sd->waitlist, 1);               /* do them now */
215             sd->waitlist = sd->waitlist->next;              /* and move on to the next */
216         }
217     }
218     if (bp->b_qindex == 0) {                                /* not on a queue, */
219         bp->b_flags |= B_INVAL;
220         bp->b_ioflags &= ~BIO_ERROR;
221         brelse(bp);                                         /* is this kosher? */
222     }
223     return error;
224 }
225
226 /*
227  * Check or rebuild the parity blocks of a RAID-4
228  * or RAID-5 plex.
229  *
230  * The variables plex->checkblock and
231  * plex->rebuildblock represent the
232  * subdisk-relative address of the stripe we're
233  * looking at, not the plex-relative address.  We
234  * store it in the plex and not as a local
235  * variable because this function could be
236  * stopped, and we don't want to repeat the part
237  * we've already done.  This is also the reason
238  * why we don't initialize it here except at the
239  * end.  It gets initialized with the plex on
240  * creation.
241  *
242  * Each call to this function processes at most
243  * one stripe.  We can't loop in this function,
244  * because we're unstoppable, so we have to be
245  * called repeatedly from userland.
246  */
247 void
248 parityops(struct vinum_ioctl_msg *data)
249 {
250     int plexno;
251     struct plex *plex;
252     int size;                                               /* I/O transfer size, bytes */
253     int stripe;                                             /* stripe number in plex */
254     int psd;                                                /* parity subdisk number */
255     struct rangelock *lock;                                 /* lock on stripe */
256     struct _ioctl_reply *reply;
257     off_t pstripe;                                          /* pointer to our stripe counter */
258     struct buf *pbp;
259     off_t errorloc;                                         /* offset of parity error */
260     enum parityop op;                                       /* operation to perform */
261
262     plexno = data->index;
263     op = data->op;
264     pbp = NULL;
265     reply = (struct _ioctl_reply *) data;
266     reply->error = EAGAIN;                                  /* expect to repeat this call */
267     plex = &PLEX[plexno];
268     if (!isparity(plex)) {                                  /* not RAID-4 or RAID-5 */
269         reply->error = EINVAL;
270         return;
271     } else if (plex->state < plex_flaky) {
272         reply->error = EIO;
273         strcpy(reply->msg, "Plex is not completely accessible\n");
274         return;
275     }
276     pstripe = data->offset;
277     stripe = pstripe / plex->stripesize;                    /* stripe number */
278     psd = plex->subdisks - 1 - stripe % plex->subdisks;     /* parity subdisk for this stripe */
279     size = min(DEFAULT_REVIVE_BLOCKSIZE,                    /* one block at a time */
280         plex->stripesize << DEV_BSHIFT);
281
282     pbp = parityrebuild(plex, pstripe, size, op, &lock, &errorloc); /* do the grunt work */
283     if (pbp == NULL) {                                      /* no buffer space */
284         reply->error = ENOMEM;
285         return;                                             /* chicken out */
286     }
287     /*
288      * Now we have a result in the data buffer of
289      * the parity buffer header, which we have kept.
290      * Decide what to do with it.
291      */
292     reply->msg[0] = '\0';                                   /* until shown otherwise */
293     if ((pbp->b_ioflags & BIO_ERROR) == 0) {                /* no error */
294         if ((op == rebuildparity)
295             || (op == rebuildandcheckparity)) {
296             pbp->b_iocmd = BIO_WRITE;
297             pbp->b_resid = pbp->b_bcount;
298             sdio(pbp);                                      /* write the parity block */
299             bufwait(pbp);
300         }
301         if (((op == checkparity)
302                 || (op == rebuildandcheckparity))
303             && (errorloc != -1)) {
304             if (op == checkparity)
305                 reply->error = EIO;
306             sprintf(reply->msg,
307                 "Parity incorrect at offset 0x%llx\n",
308                 errorloc);
309         }
310         if (reply->error == EAGAIN) {                       /* still OK, */
311             plex->checkblock = pstripe + (pbp->b_bcount >> DEV_BSHIFT); /* moved this much further down */
312             if (plex->checkblock >= SD[plex->sdnos[0]].sectors) { /* finished */
313                 plex->checkblock = 0;
314                 reply->error = 0;
315             }
316         }
317     }
318     if (pbp->b_ioflags & BIO_ERROR)
319         reply->error = pbp->b_error;
320     pbp->b_flags |= B_INVAL;
321     pbp->b_ioflags &= ~BIO_ERROR;
322     brelse(pbp);
323     unlockrange(plexno, lock);
324 }
325
326 /*
327  * Rebuild a parity stripe.  Return pointer to
328  * parity bp.  On return,
329  *
330  * 1.  The band is locked.  The caller must unlock
331  *     the band and release the buffer header.
332  *
333  * 2.  All buffer headers except php have been
334  *     released.  The caller must release pbp.
335  *
336  * 3.  For checkparity and rebuildandcheckparity,
337  *     the parity is compared with the current
338  *     parity block.  If it's different, the
339  *     offset of the error is returned to
340  *     errorloc.  The caller can set the value of
341  *     the pointer to NULL if this is called for
342  *     rebuilding parity.
343  *
344  * pstripe is the subdisk-relative base address of
345  * the data to be reconstructed, size is the size
346  * of the transfer in bytes.
347  */
348 struct buf *
349 parityrebuild(struct plex *plex,
350     u_int64_t pstripe,
351     int size,
352     enum parityop op,
353     struct rangelock **lockp,
354     off_t * errorloc)
355 {
356     int error;
357     int s;
358     int sdno;
359     u_int64_t stripe;                                       /* stripe number */
360     int *parity_buf;                                        /* buffer address for current parity block */
361     int *newparity_buf;                                     /* and for new parity block */
362     int mysize;                                             /* I/O transfer size for this transfer */
363     int isize;                                              /* mysize in ints */
364     int i;
365     int psd;                                                /* parity subdisk number */
366     int newpsd;                                             /* and "subdisk number" of new parity */
367     struct buf **bpp;                                       /* pointers to our bps */
368     struct buf *pbp;                                        /* buffer header for parity stripe */
369     int *sbuf;
370     int bufcount;                                           /* number of buffers we need */
371
372     stripe = pstripe / plex->stripesize;                    /* stripe number */
373     psd = plex->subdisks - 1 - stripe % plex->subdisks;     /* parity subdisk for this stripe */
374     parity_buf = NULL;                                      /* to keep the compiler happy */
375     error = 0;
376
377     /*
378      * It's possible that the default transfer size
379      * we chose is not a factor of the stripe size.
380      * We *must* limit this operation to a single
381      * stripe, at least for RAID-5 rebuild, since
382      * the parity subdisk changes between stripes,
383      * so in this case we need to perform a short
384      * transfer.  Set variable mysize to reflect
385      * this.
386      */
387     mysize = min(size, (plex->stripesize * (stripe + 1) - pstripe) << DEV_BSHIFT);
388     isize = mysize / (sizeof(int));                         /* number of ints in the buffer */
389     bufcount = plex->subdisks + 1;                          /* sd buffers plus result buffer */
390     newpsd = plex->subdisks;
391     bpp = (struct buf **) Malloc(bufcount * sizeof(struct buf *)); /* array of pointers to bps */
392
393     /* First, build requests for all subdisks */
394     for (sdno = 0; sdno < bufcount; sdno++) {               /* for each subdisk */
395         if ((sdno != psd) || (op != rebuildparity)) {
396             /* Get a buffer header and initialize it. */
397             s = splbio();
398             bpp[sdno] = geteblk(mysize);                    /* Get a buffer */
399             if (bpp[sdno] == NULL) {
400                 while (sdno-- > 0) {                        /* release the ones we got */
401                     bpp[sdno]->b_flags |= B_INVAL;
402                     brelse(bpp[sdno]);                      /* give back our resources */
403                 }
404                 splx(s);
405                 printf("vinum: can't allocate buffer space for parity op.\n");
406                 return NULL;                                /* no bpps */
407             }
408             splx(s);
409             if (sdno == psd)
410                 parity_buf = (int *) bpp[sdno]->b_data;
411             if (sdno == newpsd)                             /* the new one? */
412                 bpp[sdno]->b_dev = VINUM_SD(plex->sdnos[psd]); /* write back to the parity SD */
413             else
414                 bpp[sdno]->b_dev = VINUM_SD(plex->sdnos[sdno]); /* device number */
415             bpp[sdno]->b_iocmd = BIO_READ;                  /* either way, read it */
416             bpp[sdno]->b_flags = 0;
417             bpp[sdno]->b_bcount = mysize;
418             bpp[sdno]->b_resid = bpp[sdno]->b_bcount;
419             bpp[sdno]->b_blkno = pstripe;                   /* transfer from here */
420         }
421     }
422
423     /* Initialize result buffer */
424     pbp = bpp[newpsd];
425     newparity_buf = (int *) bpp[newpsd]->b_data;
426     bzero(newparity_buf, mysize);
427
428     /*
429      * Now lock the stripe with the first non-parity
430      * bp as locking bp.
431      */
432     *lockp = lockrange(pstripe * plex->stripesize * (plex->subdisks - 1),
433         bpp[psd ? 0 : 1],
434         plex);
435
436     /*
437      * Then issue requests for all subdisks in
438      * parallel.  Don't transfer the parity stripe
439      * if we're rebuilding parity, unless we also
440      * want to check it.
441      */
442     for (sdno = 0; sdno < plex->subdisks; sdno++) {         /* for each real subdisk */
443         if ((sdno != psd) || (op != rebuildparity)) {
444             sdio(bpp[sdno]);
445         }
446     }
447
448     /*
449      * Next, wait for the requests to complete.
450      * We wait in the order in which they were
451      * issued, which isn't necessarily the order in
452      * which they complete, but we don't have a
453      * convenient way of doing the latter, and the
454      * delay is minimal.
455      */
456     for (sdno = 0; sdno < plex->subdisks; sdno++) {         /* for each subdisk */
457         if ((sdno != psd) || (op != rebuildparity)) {
458             bufwait(bpp[sdno]);
459             if (bpp[sdno]->b_ioflags & BIO_ERROR)           /* can't read, */
460                 error = bpp[sdno]->b_error;
461             else if (sdno != psd) {                         /* update parity */
462                 sbuf = (int *) bpp[sdno]->b_data;
463                 for (i = 0; i < isize; i++)
464                     ((int *) newparity_buf)[i] ^= sbuf[i];  /* xor in the buffer */
465             }
466         }
467         if (sdno != psd) {                                  /* release all bps except parity */
468             bpp[sdno]->b_flags |= B_INVAL;
469             brelse(bpp[sdno]);                              /* give back our resources */
470         }
471     }
472
473     /*
474      * If we're checking, compare the calculated
475      * and the read parity block.  If they're
476      * different, return the plex-relative offset;
477      * otherwise return -1.
478      */
479     if ((op == checkparity)
480         || (op == rebuildandcheckparity)) {
481         *errorloc = -1;                                     /* no error yet */
482         for (i = 0; i < isize; i++) {
483             if (parity_buf[i] != newparity_buf[i]) {
484                 *errorloc = (off_t) (pstripe << DEV_BSHIFT) * (plex->subdisks - 1)
485                     + i * sizeof(int);
486                 break;
487             }
488         }
489         bpp[psd]->b_flags |= B_INVAL;
490         brelse(bpp[psd]);                                   /* give back our resources */
491     }
492     /* release our resources */
493     Free(bpp);
494     if (error) {
495         pbp->b_ioflags |= BIO_ERROR;
496         pbp->b_error = error;
497     }
498     return pbp;
499 }
500
501 /*
502  * Initialize a subdisk by writing zeroes to the
503  * complete address space.  If verify is set,
504  * check each transfer for correctness.
505  *
506  * Each call to this function writes (and maybe
507  * checks) a single block.
508  */
509 int
510 initsd(int sdno, int verify)
511 {
512     int s;                                                  /* priority level */
513     struct sd *sd;
514     struct plex *plex;
515     struct volume *vol;
516     struct buf *bp;
517     int error;
518     int size;                                               /* size of init block, bytes */
519     daddr_t plexblkno;                                      /* lblkno in plex */
520     int verified;                                           /* set when we're happy with what we wrote */
521
522     error = 0;
523     plexblkno = 0;                                          /* to keep the compiler happy */
524     sd = &SD[sdno];
525     if (sd->plexno < 0)                                     /* no plex? */
526         return EINVAL;
527     plex = &PLEX[sd->plexno];                               /* point to plex */
528     if (plex->volno >= 0)
529         vol = &VOL[plex->volno];
530     else
531         vol = NULL;
532
533     if (sd->init_blocksize == 0) {
534         if (plex->stripesize != 0)                          /* we're striped, don't init more than */
535             sd->init_blocksize = min(DEFAULT_REVIVE_BLOCKSIZE, /* one block at a time */
536                 plex->stripesize << DEV_BSHIFT);
537         else
538             sd->init_blocksize = DEFAULT_REVIVE_BLOCKSIZE;
539     } else if (sd->init_blocksize > MAX_REVIVE_BLOCKSIZE)
540         sd->init_blocksize = MAX_REVIVE_BLOCKSIZE;
541
542     size = min(sd->init_blocksize >> DEV_BSHIFT, sd->sectors - sd->initialized) << DEV_BSHIFT;
543
544     verified = 0;
545     while (!verified) {                                     /* until we're happy with it, */
546         s = splbio();
547         bp = geteblk(size);                                 /* Get a buffer */
548         splx(s);
549         if (bp == NULL)
550             return ENOMEM;
551
552         bp->b_bcount = size;
553         bp->b_resid = bp->b_bcount;
554         bp->b_blkno = sd->initialized;                      /* write it to here */
555         bzero(bp->b_data, bp->b_bcount);
556         bp->b_dev = VINUM_SD(sdno);                         /* create the device number */
557         bp->b_iocmd = BIO_WRITE;
558         sdio(bp);                                           /* perform the I/O */
559         bufwait(bp);
560         if (bp->b_ioflags & BIO_ERROR)
561             error = bp->b_error;
562         if (bp->b_qindex == 0) {                            /* not on a queue, */
563             bp->b_flags |= B_INVAL;
564             bp->b_ioflags &= ~BIO_ERROR;
565             brelse(bp);                                     /* is this kosher? */
566         }
567         if ((error == 0) && verify) {                       /* check that it got there */
568             s = splbio();
569             bp = geteblk(size);                             /* get a buffer */
570             if (bp == NULL) {
571                 splx(s);
572                 error = ENOMEM;
573             } else {
574                 bp->b_bcount = size;
575                 bp->b_resid = bp->b_bcount;
576                 bp->b_blkno = sd->initialized;              /* read from here */
577                 bp->b_dev = VINUM_SD(sdno);                 /* create the device number */
578                 bp->b_iocmd = BIO_READ;                     /* read it back */
579                 splx(s);
580                 sdio(bp);
581                 bufwait(bp);
582                 /*
583                  * XXX Bug fix code.  This is hopefully no
584                  * longer needed (21 February 2000).
585                  */
586                 if (bp->b_ioflags & BIO_ERROR)
587                     error = bp->b_error;
588                 else if ((*bp->b_data != 0)                 /* first word spammed */
589                 ||(bcmp(bp->b_data, &bp->b_data[1], bp->b_bcount - 1))) { /* or one of the others */
590                     printf("vinum: init error on %s, offset 0x%llx sectors\n",
591                         sd->name,
592                         (long long) sd->initialized);
593                     verified = 0;
594                 } else
595                     verified = 1;
596                 if (bp->b_qindex == 0) {                    /* not on a queue, */
597                     bp->b_flags |= B_INVAL;
598                     bp->b_ioflags &= ~BIO_ERROR;
599                     brelse(bp);                             /* is this kosher? */
600                 }
601             }
602         } else
603             verified = 1;
604     }
605     if (error == 0) {                                       /* did it, */
606         sd->initialized += size >> DEV_BSHIFT;              /* moved this much further down */
607         if (sd->initialized >= sd->sectors) {               /* finished */
608             sd->initialized = 0;
609             set_sd_state(sdno, sd_initialized, setstate_force); /* bring the sd up */
610             log(LOG_INFO, "vinum: %s is %s\n", sd->name, sd_state(sd->state));
611             save_config();                                  /* and save the updated configuration */
612         } else                                              /* more to go, */
613             error = EAGAIN;                                 /* ya'll come back, see? */
614     }
615     return error;
616 }
617
618 /* Local Variables: */
619 /* fill-column: 50 */
620 /* End: */