geom_ccd.c (38438) | geom_ccd.c (39228) |
---|---|
1/* $Id: ccd.c,v 1.35 1998/07/04 22:30:13 julian Exp $ */ | 1/* $Id: ccd.c,v 1.36 1998/08/19 10:50:32 sos Exp $ */ |
2 3/* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ 4 5/* 6 * Copyright (c) 1995 Jason R. Thorpe. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 88 unchanged lines hidden (view full) --- 98#include <sys/malloc.h> 99#include <sys/namei.h> 100#include <sys/conf.h> 101#include <sys/stat.h> 102#include <sys/sysctl.h> 103#include <sys/disklabel.h> 104#include <ufs/ffs/fs.h> 105#include <sys/device.h> | 2 3/* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ 4 5/* 6 * Copyright (c) 1995 Jason R. Thorpe. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 88 unchanged lines hidden (view full) --- 98#include <sys/malloc.h> 99#include <sys/namei.h> 100#include <sys/conf.h> 101#include <sys/stat.h> 102#include <sys/sysctl.h> 103#include <sys/disklabel.h> 104#include <ufs/ffs/fs.h> 105#include <sys/device.h> |
106#include <sys/devicestat.h> |
|
106#undef KERNEL /* XXX */ 107#include <sys/disk.h> 108#define KERNEL 109#include <sys/fcntl.h> 110#include <sys/vnode.h> 111 112#include <sys/ccdvar.h> 113 --- 173 unchanged lines hidden (view full) --- 287 char tmppath[MAXPATHLEN]; 288 int error; 289 290#ifdef DEBUG 291 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 292 printf("ccdinit: unit %d\n", ccd->ccd_unit); 293#endif 294 | 107#undef KERNEL /* XXX */ 108#include <sys/disk.h> 109#define KERNEL 110#include <sys/fcntl.h> 111#include <sys/vnode.h> 112 113#include <sys/ccdvar.h> 114 --- 173 unchanged lines hidden (view full) --- 288 char tmppath[MAXPATHLEN]; 289 int error; 290 291#ifdef DEBUG 292 if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) 293 printf("ccdinit: unit %d\n", ccd->ccd_unit); 294#endif 295 |
295#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 296 cs->sc_dk = ccd->ccd_dk; 297#endif | |
298 cs->sc_size = 0; 299 cs->sc_ileave = ccd->ccd_interleave; 300 cs->sc_nccdisks = ccd->ccd_ndev; 301 302 /* Allocate space for the component info. */ 303 cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo), 304 M_DEVBUF, M_WAITOK); 305 --- 170 unchanged lines hidden (view full) --- 476 * Create pseudo-geometry based on 1MB cylinders. It's 477 * pretty close. 478 */ 479 ccg->ccg_secsize = maxsecsize; 480 ccg->ccg_ntracks = 1; 481 ccg->ccg_nsectors = 1024 * (1024 / ccg->ccg_secsize); 482 ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors; 483 | 296 cs->sc_size = 0; 297 cs->sc_ileave = ccd->ccd_interleave; 298 cs->sc_nccdisks = ccd->ccd_ndev; 299 300 /* Allocate space for the component info. */ 301 cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo), 302 M_DEVBUF, M_WAITOK); 303 --- 170 unchanged lines hidden (view full) --- 474 * Create pseudo-geometry based on 1MB cylinders. It's 475 * pretty close. 476 */ 477 ccg->ccg_secsize = maxsecsize; 478 ccg->ccg_ntracks = 1; 479 ccg->ccg_nsectors = 1024 * (1024 / ccg->ccg_secsize); 480 ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors; 481 |
484#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 485 if (ccd->ccd_dk >= 0) 486 dk_wpms[ccd->ccd_dk] = 32 * (60 * DEV_BSIZE / 2); /* XXX */ 487#endif | 482 /* 483 * Add an devstat entry for this device. 484 */ 485 devstat_add_entry(&cs->device_stats, "ccd", ccd->ccd_unit, 486 ccg->ccg_secsize, DEVSTAT_ALL_SUPPORTED, 487 DEVSTAT_TYPE_ASC0 |DEVSTAT_TYPE_IF_OTHER); |
488 489 cs->sc_flags |= CCDF_INITED; 490 cs->sc_cflags = ccd->ccd_flags; /* So we can find out later... */ 491 cs->sc_unit = ccd->ccd_unit; 492 return (0); 493} 494 495static void --- 275 unchanged lines hidden (view full) --- 771 daddr_t bn; 772 struct partition *pp; 773 774#ifdef DEBUG 775 if (ccddebug & CCDB_FOLLOW) 776 printf("ccdstart(%x, %x)\n", cs, bp); 777#endif 778 | 488 489 cs->sc_flags |= CCDF_INITED; 490 cs->sc_cflags = ccd->ccd_flags; /* So we can find out later... */ 491 cs->sc_unit = ccd->ccd_unit; 492 return (0); 493} 494 495static void --- 275 unchanged lines hidden (view full) --- 771 daddr_t bn; 772 struct partition *pp; 773 774#ifdef DEBUG 775 if (ccddebug & CCDB_FOLLOW) 776 printf("ccdstart(%x, %x)\n", cs, bp); 777#endif 778 |
779#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 780 /* 781 * Instrumentation (not very meaningful) 782 */ 783 cs->sc_nactive++; 784 if (cs->sc_dk >= 0) { 785 dk_busy |= 1 << cs->sc_dk; 786 dk_xfer[cs->sc_dk]++; 787 dk_wds[cs->sc_dk] += bp->b_bcount >> 6; 788 } 789#endif | 779 /* Record the transaction start */ 780 devstat_start_transaction(&cs->device_stats); |
790 791 /* 792 * Translate the partition-relative block number to an absolute. 793 */ 794 bn = bp->b_blkno; 795 if (ccdpart(bp->b_dev) != RAW_PART) { 796 pp = &cs->sc_dkdev.dk_label.d_partitions[ccdpart(bp->b_dev)]; 797 bn += pp->p_offset; --- 106 unchanged lines hidden (view full) --- 904 cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; 905 cbp->cb_buf.b_proc = bp->b_proc; 906 cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */ 907 cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; 908 cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET); 909 cbp->cb_buf.b_data = addr; 910 cbp->cb_buf.b_vp = ci->ci_vp; 911 LIST_INIT(&cbp->cb_buf.b_dep); | 781 782 /* 783 * Translate the partition-relative block number to an absolute. 784 */ 785 bn = bp->b_blkno; 786 if (ccdpart(bp->b_dev) != RAW_PART) { 787 pp = &cs->sc_dkdev.dk_label.d_partitions[ccdpart(bp->b_dev)]; 788 bn += pp->p_offset; --- 106 unchanged lines hidden (view full) --- 895 cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; 896 cbp->cb_buf.b_proc = bp->b_proc; 897 cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */ 898 cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; 899 cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET); 900 cbp->cb_buf.b_data = addr; 901 cbp->cb_buf.b_vp = ci->ci_vp; 902 LIST_INIT(&cbp->cb_buf.b_dep); |
903 cbp->cb_buf.b_resid = 0; |
|
912 if (cs->sc_ileave == 0) 913 cbp->cb_buf.b_bcount = dbtob(ci->ci_size - cbn); 914 else 915 cbp->cb_buf.b_bcount = dbtob(cs->sc_ileave - cboff); 916 if (cbp->cb_buf.b_bcount > bcount) 917 cbp->cb_buf.b_bcount = bcount; 918 919 cbp->cb_buf.b_bufsize = cbp->cb_buf.b_bcount; --- 38 unchanged lines hidden (view full) --- 958{ 959#ifdef DEBUG 960 if (ccddebug & CCDB_FOLLOW) 961 printf("ccdintr(%x, %x)\n", cs, bp); 962#endif 963 /* 964 * Request is done for better or worse, wakeup the top half. 965 */ | 904 if (cs->sc_ileave == 0) 905 cbp->cb_buf.b_bcount = dbtob(ci->ci_size - cbn); 906 else 907 cbp->cb_buf.b_bcount = dbtob(cs->sc_ileave - cboff); 908 if (cbp->cb_buf.b_bcount > bcount) 909 cbp->cb_buf.b_bcount = bcount; 910 911 cbp->cb_buf.b_bufsize = cbp->cb_buf.b_bcount; --- 38 unchanged lines hidden (view full) --- 950{ 951#ifdef DEBUG 952 if (ccddebug & CCDB_FOLLOW) 953 printf("ccdintr(%x, %x)\n", cs, bp); 954#endif 955 /* 956 * Request is done for better or worse, wakeup the top half. 957 */ |
966#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 967 --cs->sc_nactive; 968#ifdef DIAGNOSTIC 969 if (cs->sc_nactive < 0) 970 panic("ccdintr: ccd%d: sc_nactive < 0", cs->sc_unit); 971#endif | 958 /* Record device statistics */ 959 devstat_end_transaction(&cs->device_stats, 960 bp->b_bcount - bp->b_resid, 961 (bp->b_flags & B_ORDERED) ? 962 DEVSTAT_TAG_ORDERED : DEVSTAT_TAG_SIMPLE, 963 (bp->b_flags & B_READ) ? DEVSTAT_READ : 964 DEVSTAT_WRITE); |
972 | 965 |
973 if (cs->sc_nactive == 0 && cs->sc_dk >= 0) 974 dk_busy &= ~(1 << cs->sc_dk); 975#endif | |
976 if (bp->b_flags & B_ERROR) 977 bp->b_resid = bp->b_bcount; 978 biodone(bp); 979} 980 981/* 982 * Called at interrupt time. 983 * Mark the component as done and if all components are done, --- 66 unchanged lines hidden (view full) --- 1050 int unit = ccdunit(dev); 1051 int i, j, lookedup = 0, error = 0; 1052 int part, pmask, s; 1053 struct ccd_softc *cs; 1054 struct ccd_ioctl *ccio = (struct ccd_ioctl *)data; 1055 struct ccddevice ccd; 1056 char **cpp; 1057 struct vnode **vpp; | 966 if (bp->b_flags & B_ERROR) 967 bp->b_resid = bp->b_bcount; 968 biodone(bp); 969} 970 971/* 972 * Called at interrupt time. 973 * Mark the component as done and if all components are done, --- 66 unchanged lines hidden (view full) --- 1040 int unit = ccdunit(dev); 1041 int i, j, lookedup = 0, error = 0; 1042 int part, pmask, s; 1043 struct ccd_softc *cs; 1044 struct ccd_ioctl *ccio = (struct ccd_ioctl *)data; 1045 struct ccddevice ccd; 1046 char **cpp; 1047 struct vnode **vpp; |
1058#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 1059 extern int dkn; 1060#endif | |
1061 1062 if (unit >= numccd) 1063 return (ENXIO); 1064 cs = &ccd_softc[unit]; 1065 1066 bzero(&ccd, sizeof(ccd)); 1067 1068 switch (cmd) { --- 69 unchanged lines hidden (view full) --- 1138 return (error); 1139 } 1140 ++lookedup; 1141 } 1142 ccd.ccd_cpp = cpp; 1143 ccd.ccd_vpp = vpp; 1144 ccd.ccd_ndev = ccio->ccio_ndisks; 1145 | 1048 1049 if (unit >= numccd) 1050 return (ENXIO); 1051 cs = &ccd_softc[unit]; 1052 1053 bzero(&ccd, sizeof(ccd)); 1054 1055 switch (cmd) { --- 69 unchanged lines hidden (view full) --- 1125 return (error); 1126 } 1127 ++lookedup; 1128 } 1129 ccd.ccd_cpp = cpp; 1130 ccd.ccd_vpp = vpp; 1131 ccd.ccd_ndev = ccio->ccio_ndisks; 1132 |
1146#ifdef WORKING_DISK_STATISTICS /* XXX !! */ | |
1147 /* | 1133 /* |
1148 * Assign disk index first so that init routine 1149 * can use it (saves having the driver drag around 1150 * the ccddevice pointer just to set up the dk_* 1151 * info in the open routine). 1152 */ 1153 if (dkn < DK_NDRIVE) 1154 ccd.ccd_dk = dkn++; 1155 else 1156 ccd.ccd_dk = -1; 1157#endif 1158 1159 /* | |
1160 * Initialize the ccd. Fills in the softc for us. 1161 */ 1162 if (error = ccdinit(&ccd, cpp, p)) { | 1134 * Initialize the ccd. Fills in the softc for us. 1135 */ 1136 if (error = ccdinit(&ccd, cpp, p)) { |
1163#ifdef WORKING_DISK_STATISTICS /* XXX !! */ 1164 if (ccd.ccd_dk >= 0) 1165 --dkn; 1166#endif | |
1167 for (j = 0; j < lookedup; ++j) 1168 (void)vn_close(vpp[j], FREAD|FWRITE, 1169 p->p_ucred, p); 1170 bzero(&ccd_softc[unit], sizeof(struct ccd_softc)); 1171 free(vpp, M_DEVBUF); 1172 free(cpp, M_DEVBUF); 1173 ccdunlock(cs); 1174 return (error); --- 383 unchanged lines hidden --- | 1137 for (j = 0; j < lookedup; ++j) 1138 (void)vn_close(vpp[j], FREAD|FWRITE, 1139 p->p_ucred, p); 1140 bzero(&ccd_softc[unit], sizeof(struct ccd_softc)); 1141 free(vpp, M_DEVBUF); 1142 free(cpp, M_DEVBUF); 1143 ccdunlock(cs); 1144 return (error); --- 383 unchanged lines hidden --- |