Deleted Added
full compact
geom_ccd.c (109535) geom_ccd.c (109623)
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 *
49 * @(#)cd.c 8.2 (Berkeley) 11/16/93
50 *
51 * $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $
52 *
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 *
49 * @(#)cd.c 8.2 (Berkeley) 11/16/93
50 *
51 * $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $
52 *
53 * $FreeBSD: head/sys/geom/geom_ccd.c 109535 2003-01-19 15:00:58Z phk $
53 * $FreeBSD: head/sys/geom/geom_ccd.c 109623 2003-01-21 08:56:16Z alfred $
54 */
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/kernel.h>
59#include <sys/module.h>
60#include <sys/proc.h>
61#include <sys/bio.h>

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

201ccdnew(int unit)
202{
203 struct ccd_s *sc;
204
205 /* XXX: LOCK(unique unit numbers) */
206 if (IS_ALLOCATED(unit) || unit > 32)
207 return (NULL);
208
54 */
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/kernel.h>
59#include <sys/module.h>
60#include <sys/proc.h>
61#include <sys/bio.h>

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

201ccdnew(int unit)
202{
203 struct ccd_s *sc;
204
205 /* XXX: LOCK(unique unit numbers) */
206 if (IS_ALLOCATED(unit) || unit > 32)
207 return (NULL);
208
209 MALLOC(sc, struct ccd_s *, sizeof(*sc), M_CCD, M_WAITOK | M_ZERO);
209 MALLOC(sc, struct ccd_s *, sizeof(*sc), M_CCD, M_ZERO);
210 sc->sc_unit = unit;
211 LIST_INSERT_HEAD(&ccd_softc_list, sc, list);
212 /* XXX: UNLOCK(unique unit numbers) */
213 return (sc);
214}
215
216static int
217ccddestroy(struct ccd_s *sc)

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

278 off_t mediasize;
279 u_int sectorsize;
280
281
282 cs->sc_size = 0;
283
284 /* Allocate space for the component info. */
285 cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo),
210 sc->sc_unit = unit;
211 LIST_INSERT_HEAD(&ccd_softc_list, sc, list);
212 /* XXX: UNLOCK(unique unit numbers) */
213 return (sc);
214}
215
216static int
217ccddestroy(struct ccd_s *sc)

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

278 off_t mediasize;
279 u_int sectorsize;
280
281
282 cs->sc_size = 0;
283
284 /* Allocate space for the component info. */
285 cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo),
286 M_CCD, M_WAITOK);
286 M_CCD, 0);
287
288 /*
289 * Verify that each component piece exists and record
290 * relevant information about it.
291 */
292 maxsecsize = 0;
293 minsize = 0;
287
288 /*
289 * Verify that each component piece exists and record
290 * relevant information about it.
291 */
292 maxsecsize = 0;
293 minsize = 0;
294 tmppath = malloc(MAXPATHLEN, M_CCD, M_WAITOK);
294 tmppath = malloc(MAXPATHLEN, M_CCD, 0);
295 for (ix = 0; ix < cs->sc_nccdisks; ix++) {
296 vp = cs->sc_vpp[ix];
297 ci = &cs->sc_cinfo[ix];
298 ci->ci_vp = vp;
299
300 /*
301 * Copy in the pathname of the component.
302 */
303 if ((error = copyinstr(cpaths[ix], tmppath,
304 MAXPATHLEN, &ci->ci_pathlen)) != 0) {
305 goto fail;
306 }
295 for (ix = 0; ix < cs->sc_nccdisks; ix++) {
296 vp = cs->sc_vpp[ix];
297 ci = &cs->sc_cinfo[ix];
298 ci->ci_vp = vp;
299
300 /*
301 * Copy in the pathname of the component.
302 */
303 if ((error = copyinstr(cpaths[ix], tmppath,
304 MAXPATHLEN, &ci->ci_pathlen)) != 0) {
305 goto fail;
306 }
307 ci->ci_path = malloc(ci->ci_pathlen, M_CCD, M_WAITOK);
307 ci->ci_path = malloc(ci->ci_pathlen, M_CCD, 0);
308 bcopy(tmppath, ci->ci_path, ci->ci_pathlen);
309
310 ci->ci_dev = vn_todev(vp);
311
312 /*
313 * Get partition information for the component.
314 */
315 error = VOP_IOCTL(vp, DIOCGMEDIASIZE, (caddr_t)&mediasize,

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

454 * Allocate an interleave table. The worst case occurs when each
455 * of N disks is of a different size, resulting in N interleave
456 * tables.
457 *
458 * Chances are this is too big, but we don't care.
459 */
460 size = (cs->sc_nccdisks + 1) * sizeof(struct ccdiinfo);
461 cs->sc_itable = (struct ccdiinfo *)malloc(size, M_CCD,
308 bcopy(tmppath, ci->ci_path, ci->ci_pathlen);
309
310 ci->ci_dev = vn_todev(vp);
311
312 /*
313 * Get partition information for the component.
314 */
315 error = VOP_IOCTL(vp, DIOCGMEDIASIZE, (caddr_t)&mediasize,

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

454 * Allocate an interleave table. The worst case occurs when each
455 * of N disks is of a different size, resulting in N interleave
456 * tables.
457 *
458 * Chances are this is too big, but we don't care.
459 */
460 size = (cs->sc_nccdisks + 1) * sizeof(struct ccdiinfo);
461 cs->sc_itable = (struct ccdiinfo *)malloc(size, M_CCD,
462 M_WAITOK | M_ZERO);
462 M_ZERO);
463
464 /*
465 * Trivial case: no interleave (actually interleave of disk size).
466 * Each table entry represents a single component in its entirety.
467 *
468 * An interleave of 0 may not be used with a mirror setup.
469 */
470 if (cs->sc_ileave == 0) {
471 bn = 0;
472 ii = cs->sc_itable;
473
474 for (ix = 0; ix < cs->sc_nccdisks; ix++) {
475 /* Allocate space for ii_index. */
463
464 /*
465 * Trivial case: no interleave (actually interleave of disk size).
466 * Each table entry represents a single component in its entirety.
467 *
468 * An interleave of 0 may not be used with a mirror setup.
469 */
470 if (cs->sc_ileave == 0) {
471 bn = 0;
472 ii = cs->sc_itable;
473
474 for (ix = 0; ix < cs->sc_nccdisks; ix++) {
475 /* Allocate space for ii_index. */
476 ii->ii_index = malloc(sizeof(int), M_CCD, M_WAITOK);
476 ii->ii_index = malloc(sizeof(int), M_CCD, 0);
477 ii->ii_ndisk = 1;
478 ii->ii_startblk = bn;
479 ii->ii_startoff = 0;
480 ii->ii_index[0] = ix;
481 bn += cs->sc_cinfo[ix].ci_size;
482 ii++;
483 }
484 ii->ii_ndisk = 0;

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

491 size = 0;
492 bn = lbn = 0;
493 for (ii = cs->sc_itable; ; ii++) {
494 /*
495 * Allocate space for ii_index. We might allocate more then
496 * we use.
497 */
498 ii->ii_index = malloc((sizeof(int) * cs->sc_nccdisks),
477 ii->ii_ndisk = 1;
478 ii->ii_startblk = bn;
479 ii->ii_startoff = 0;
480 ii->ii_index[0] = ix;
481 bn += cs->sc_cinfo[ix].ci_size;
482 ii++;
483 }
484 ii->ii_ndisk = 0;

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

491 size = 0;
492 bn = lbn = 0;
493 for (ii = cs->sc_itable; ; ii++) {
494 /*
495 * Allocate space for ii_index. We might allocate more then
496 * we use.
497 */
498 ii->ii_index = malloc((sizeof(int) * cs->sc_nccdisks),
499 M_CCD, M_WAITOK);
499 M_CCD, 0);
500
501 /*
502 * Locate the smallest of the remaining components
503 */
504 smallci = NULL;
505 for (ci = cs->sc_cinfo; ci < &cs->sc_cinfo[cs->sc_nccdisks];
506 ci++) {
507 if (ci->ci_size > size &&

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

1102 }
1103 cs->sc_flags = ccio->ccio_flags & CCDF_USERMASK;
1104
1105 /*
1106 * Allocate space for and copy in the array of
1107 * componet pathnames and device numbers.
1108 */
1109 cpp = malloc(ccio->ccio_ndisks * sizeof(char *),
500
501 /*
502 * Locate the smallest of the remaining components
503 */
504 smallci = NULL;
505 for (ci = cs->sc_cinfo; ci < &cs->sc_cinfo[cs->sc_nccdisks];
506 ci++) {
507 if (ci->ci_size > size &&

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

1102 }
1103 cs->sc_flags = ccio->ccio_flags & CCDF_USERMASK;
1104
1105 /*
1106 * Allocate space for and copy in the array of
1107 * componet pathnames and device numbers.
1108 */
1109 cpp = malloc(ccio->ccio_ndisks * sizeof(char *),
1110 M_CCD, M_WAITOK);
1110 M_CCD, 0);
1111 vpp = malloc(ccio->ccio_ndisks * sizeof(struct vnode *),
1111 vpp = malloc(ccio->ccio_ndisks * sizeof(struct vnode *),
1112 M_CCD, M_WAITOK);
1112 M_CCD, 0);
1113
1114 error = copyin((caddr_t)ccio->ccio_disks, (caddr_t)cpp,
1115 ccio->ccio_ndisks * sizeof(char **));
1116 if (error) {
1117 free(vpp, M_CCD);
1118 free(cpp, M_CCD);
1119 ccdunlock(cs);
1120 return (error);

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

1159 free(cpp, M_CCD);
1160
1161 /*
1162 * The ccd has been successfully initialized, so
1163 * we can place it into the array and read the disklabel.
1164 */
1165 ccio->ccio_unit = unit;
1166 ccio->ccio_size = cs->sc_size;
1113
1114 error = copyin((caddr_t)ccio->ccio_disks, (caddr_t)cpp,
1115 ccio->ccio_ndisks * sizeof(char **));
1116 if (error) {
1117 free(vpp, M_CCD);
1118 free(cpp, M_CCD);
1119 ccdunlock(cs);
1120 return (error);

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

1159 free(cpp, M_CCD);
1160
1161 /*
1162 * The ccd has been successfully initialized, so
1163 * we can place it into the array and read the disklabel.
1164 */
1165 ccio->ccio_unit = unit;
1166 ccio->ccio_size = cs->sc_size;
1167 cs->sc_disk = malloc(sizeof(struct disk), M_CCD, M_WAITOK);
1167 cs->sc_disk = malloc(sizeof(struct disk), M_CCD, 0);
1168 cs->sc_dev = disk_create(unit, cs->sc_disk, 0,
1169 &ccd_cdevsw, &ccddisk_cdevsw);
1170 cs->sc_dev->si_drv1 = cs;
1171 ccg = &cs->sc_geom;
1172 cs->sc_disk->d_sectorsize = ccg->ccg_secsize;
1173 cs->sc_disk->d_mediasize =
1174 cs->sc_size * (off_t)ccg->ccg_secsize;
1175 cs->sc_disk->d_fwsectors = ccg->ccg_nsectors;

--- 140 unchanged lines hidden ---
1168 cs->sc_dev = disk_create(unit, cs->sc_disk, 0,
1169 &ccd_cdevsw, &ccddisk_cdevsw);
1170 cs->sc_dev->si_drv1 = cs;
1171 ccg = &cs->sc_geom;
1172 cs->sc_disk->d_sectorsize = ccg->ccg_secsize;
1173 cs->sc_disk->d_mediasize =
1174 cs->sc_size * (off_t)ccg->ccg_secsize;
1175 cs->sc_disk->d_fwsectors = ccg->ccg_nsectors;

--- 140 unchanged lines hidden ---