Deleted Added
full compact
geom_ccd.c (157581) geom_ccd.c (157740)
1/*-
2 * Copyright (c) 2003 Poul-Henning Kamp.
3 * Copyright (c) 1995 Jason R. Thorpe.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 * All rights reserved.
7 * Copyright (c) 1988 University of Utah.
8 *

--- 36 unchanged lines hidden (view full) ---

45 * Moffett Field, CA 94035
46 *
47 * from: Utah $Hdr: cd.c 1.6 90/11/28$
48 * @(#)cd.c 8.2 (Berkeley) 11/16/93
49 * $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $
50 */
51
52#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Poul-Henning Kamp.
3 * Copyright (c) 1995 Jason R. Thorpe.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 * All rights reserved.
7 * Copyright (c) 1988 University of Utah.
8 *

--- 36 unchanged lines hidden (view full) ---

45 * Moffett Field, CA 94035
46 *
47 * from: Utah $Hdr: cd.c 1.6 90/11/28$
48 * @(#)cd.c 8.2 (Berkeley) 11/16/93
49 * $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $
50 */
51
52#include <sys/cdefs.h>
53__FBSDID("$FreeBSD: head/sys/geom/geom_ccd.c 157581 2006-04-07 16:19:48Z marcel $");
53__FBSDID("$FreeBSD: head/sys/geom/geom_ccd.c 157740 2006-04-13 20:35:31Z cracauer $");
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/kernel.h>
58#include <sys/module.h>
59#include <sys/bio.h>
60#include <sys/malloc.h>
61#include <geom/geom.h>

--- 5 unchanged lines hidden (view full) ---

67 */
68#if !defined(CCD_OFFSET)
69#define CCD_OFFSET 16
70#endif
71
72/* sc_flags */
73#define CCDF_UNIFORM 0x02 /* use LCCD of sizes for uniform interleave */
74#define CCDF_MIRROR 0x04 /* use mirroring */
54
55#include <sys/param.h>
56#include <sys/systm.h>
57#include <sys/kernel.h>
58#include <sys/module.h>
59#include <sys/bio.h>
60#include <sys/malloc.h>
61#include <geom/geom.h>

--- 5 unchanged lines hidden (view full) ---

67 */
68#if !defined(CCD_OFFSET)
69#define CCD_OFFSET 16
70#endif
71
72/* sc_flags */
73#define CCDF_UNIFORM 0x02 /* use LCCD of sizes for uniform interleave */
74#define CCDF_MIRROR 0x04 /* use mirroring */
75#define CCDF_NO_OFFSET 0x08 /* do not leave space in front */
76#define CCDF_LINUX 0x10 /* use Linux compatibility mode */
75
76/* Mask of user-settable ccd flags. */
77#define CCDF_USERMASK (CCDF_UNIFORM|CCDF_MIRROR)
78
79/*
80 * Interleave description table.
81 * Computed at boot time to speed irregular-interleave lookups.
82 * The idea is that we interleave in "groups". First we interleave

--- 48 unchanged lines hidden (view full) ---

131 daddr_t sc_size; /* size of ccd */
132 int sc_ileave; /* interleave */
133 u_int sc_ndisks; /* number of components */
134 struct ccdcinfo *sc_cinfo; /* component info */
135 struct ccdiinfo *sc_itable; /* interleave table */
136 u_int32_t sc_secsize; /* # bytes per sector */
137 int sc_pick; /* side of mirror picked */
138 daddr_t sc_blk[2]; /* mirror localization */
77
78/* Mask of user-settable ccd flags. */
79#define CCDF_USERMASK (CCDF_UNIFORM|CCDF_MIRROR)
80
81/*
82 * Interleave description table.
83 * Computed at boot time to speed irregular-interleave lookups.
84 * The idea is that we interleave in "groups". First we interleave

--- 48 unchanged lines hidden (view full) ---

133 daddr_t sc_size; /* size of ccd */
134 int sc_ileave; /* interleave */
135 u_int sc_ndisks; /* number of components */
136 struct ccdcinfo *sc_cinfo; /* component info */
137 struct ccdiinfo *sc_itable; /* interleave table */
138 u_int32_t sc_secsize; /* # bytes per sector */
139 int sc_pick; /* side of mirror picked */
140 daddr_t sc_blk[2]; /* mirror localization */
141 u_int32_t sc_offset; /* actual offset used */
139};
140
141static g_start_t g_ccd_start;
142static void ccdiodone(struct bio *bp);
143static void ccdinterleave(struct ccd_s *);
144static int ccdinit(struct gctl_req *req, struct ccd_s *);
145static int ccdbuffer(struct bio **ret, struct ccd_s *,
146 struct bio *, daddr_t, caddr_t, long);

--- 63 unchanged lines hidden (view full) ---

210 int maxsecsize;
211 off_t mediasize;
212 u_int sectorsize;
213
214 cs->sc_size = 0;
215
216 maxsecsize = 0;
217 minsize = 0;
142};
143
144static g_start_t g_ccd_start;
145static void ccdiodone(struct bio *bp);
146static void ccdinterleave(struct ccd_s *);
147static int ccdinit(struct gctl_req *req, struct ccd_s *);
148static int ccdbuffer(struct bio **ret, struct ccd_s *,
149 struct bio *, daddr_t, caddr_t, long);

--- 63 unchanged lines hidden (view full) ---

213 int maxsecsize;
214 off_t mediasize;
215 u_int sectorsize;
216
217 cs->sc_size = 0;
218
219 maxsecsize = 0;
220 minsize = 0;
221
222 if (cs->sc_flags & CCDF_LINUX) {
223 cs->sc_offset = 0;
224 cs->sc_ileave *= 2;
225 if (cs->sc_flags & CCDF_MIRROR && cs->sc_ndisks != 2)
226 gctl_error(req, "Mirror mode for Linux raids is "
227 "only supported with 2 devices");
228 } else {
229 if (cs->sc_flags & CCDF_NO_OFFSET)
230 cs->sc_offset = 0;
231 else
232 cs->sc_offset = CCD_OFFSET;
233
234 }
218 for (ix = 0; ix < cs->sc_ndisks; ix++) {
219 ci = &cs->sc_cinfo[ix];
220
221 mediasize = ci->ci_provider->mediasize;
222 sectorsize = ci->ci_provider->sectorsize;
223 if (sectorsize > maxsecsize)
224 maxsecsize = sectorsize;
235 for (ix = 0; ix < cs->sc_ndisks; ix++) {
236 ci = &cs->sc_cinfo[ix];
237
238 mediasize = ci->ci_provider->mediasize;
239 sectorsize = ci->ci_provider->sectorsize;
240 if (sectorsize > maxsecsize)
241 maxsecsize = sectorsize;
225 size = mediasize / DEV_BSIZE - CCD_OFFSET;
242 size = mediasize / DEV_BSIZE - cs->sc_offset;
226
227 /* Truncate to interleave boundary */
228
229 if (cs->sc_ileave > 1)
230 size -= size % cs->sc_ileave;
231
232 if (size == 0) {
233 gctl_error(req, "Component %s has effective size zero",

--- 365 unchanged lines hidden (view full) ---

599
600 /*
601 * Fill in the component buf structure.
602 */
603 cbp = g_clone_bio(bp);
604 if (cbp == NULL)
605 return (ENOMEM);
606 cbp->bio_done = g_std_done;
243
244 /* Truncate to interleave boundary */
245
246 if (cs->sc_ileave > 1)
247 size -= size % cs->sc_ileave;
248
249 if (size == 0) {
250 gctl_error(req, "Component %s has effective size zero",

--- 365 unchanged lines hidden (view full) ---

616
617 /*
618 * Fill in the component buf structure.
619 */
620 cbp = g_clone_bio(bp);
621 if (cbp == NULL)
622 return (ENOMEM);
623 cbp->bio_done = g_std_done;
607 cbp->bio_offset = dbtob(cbn + cboff + CCD_OFFSET);
624 cbp->bio_offset = dbtob(cbn + cboff + cs->sc_offset);
608 cbp->bio_data = addr;
609 if (cs->sc_ileave == 0)
610 cbc = dbtob((off_t)(ci->ci_size - cbn));
611 else
612 cbc = dbtob((off_t)(cs->sc_ileave - cboff));
613 cbp->bio_length = (cbc < bcount) ? cbc : bcount;
614
615 cbp->bio_from = ci->ci_consumer;

--- 119 unchanged lines hidden (view full) ---

735 KASSERT(error == 0, ("attach to %s failed", pp->name));
736 sc->sc_cinfo[i].ci_consumer = cp;
737 sc->sc_cinfo[i].ci_provider = pp;
738 }
739
740 sc->sc_unit = *unit;
741 sc->sc_ileave = *ileave;
742
625 cbp->bio_data = addr;
626 if (cs->sc_ileave == 0)
627 cbc = dbtob((off_t)(ci->ci_size - cbn));
628 else
629 cbc = dbtob((off_t)(cs->sc_ileave - cboff));
630 cbp->bio_length = (cbc < bcount) ? cbc : bcount;
631
632 cbp->bio_from = ci->ci_consumer;

--- 119 unchanged lines hidden (view full) ---

752 KASSERT(error == 0, ("attach to %s failed", pp->name));
753 sc->sc_cinfo[i].ci_consumer = cp;
754 sc->sc_cinfo[i].ci_provider = pp;
755 }
756
757 sc->sc_unit = *unit;
758 sc->sc_ileave = *ileave;
759
760 if (gctl_get_param(req, "no_offset", NULL))
761 sc->sc_flags |= CCDF_NO_OFFSET;
762 if (gctl_get_param(req, "linux", NULL))
763 sc->sc_flags |= CCDF_LINUX;
764
743 if (gctl_get_param(req, "uniform", NULL))
744 sc->sc_flags |= CCDF_UNIFORM;
745 if (gctl_get_param(req, "mirror", NULL))
746 sc->sc_flags |= CCDF_MIRROR;
747
748 if (sc->sc_ileave == 0 && (sc->sc_flags & CCDF_MIRROR)) {
749 printf("%s: disabling mirror, interleave is 0\n", gp->name);
750 sc->sc_flags &= ~(CCDF_MIRROR);

--- 119 unchanged lines hidden ---
765 if (gctl_get_param(req, "uniform", NULL))
766 sc->sc_flags |= CCDF_UNIFORM;
767 if (gctl_get_param(req, "mirror", NULL))
768 sc->sc_flags |= CCDF_MIRROR;
769
770 if (sc->sc_ileave == 0 && (sc->sc_flags & CCDF_MIRROR)) {
771 printf("%s: disabling mirror, interleave is 0\n", gp->name);
772 sc->sc_flags &= ~(CCDF_MIRROR);

--- 119 unchanged lines hidden ---