diff options
author | Matthew Dillon <dillon@FreeBSD.org> | 1999-09-27 00:12:36 +0000 |
---|---|---|
committer | Matthew Dillon <dillon@FreeBSD.org> | 1999-09-27 00:12:36 +0000 |
commit | 74427f90f29ab1ab321166eb3ffcb490bf6ca3a3 (patch) | |
tree | c0535429f89fdd283acb77405ef15600d2a3b003 /sys/geom | |
parent | 889c1efb8dbdd3bde33c15e168d21c59436e0367 (diff) | |
download | src-test-74427f90f29ab1ab321166eb3ffcb490bf6ca3a3.tar.gz src-test-74427f90f29ab1ab321166eb3ffcb490bf6ca3a3.zip |
Notes
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_ccd.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index f5309b8502128..f2c9a6e97b86a 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -254,6 +254,7 @@ getccdbuf(struct ccdbuf *cpy) LIST_INIT(&cbp->cb_buf.b_dep); BUF_LOCKINIT(&cbp->cb_buf); BUF_LOCK(&cbp->cb_buf, LK_EXCLUSIVE); + BUF_KERNPROC(&cbp->cb_buf); return(cbp); } @@ -268,6 +269,9 @@ static __inline void putccdbuf(struct ccdbuf *cbp) { + BUF_UNLOCK(&cbp->cb_buf); + BUF_LOCKFREE(&cbp->cb_buf); + if (numccdfreebufs < NCCDFREEHIWAT) { cbp->cb_freenext = ccdfreebufs; ccdfreebufs = cbp; @@ -812,9 +816,38 @@ ccdstrategy(bp) * error, the bounds check will flag that for us. */ wlabel = cs->sc_flags & (CCDF_WLABEL|CCDF_LABELLING); - if (ccdpart(bp->b_dev) != RAW_PART) + if (ccdpart(bp->b_dev) != RAW_PART) { if (bounds_check_with_label(bp, lp, wlabel) <= 0) goto done; + } else { + int pbn; /* in sc_secsize chunks */ + long sz; /* in sc_secsize chunks */ + + pbn = bp->b_blkno / (cs->sc_geom.ccg_secsize / DEV_BSIZE); + sz = howmany(bp->b_bcount, cs->sc_geom.ccg_secsize); + + /* + * If out of bounds return an error. If at the EOF point, + * simply read or write less. + */ + + if (pbn < 0 || pbn >= cs->sc_size) { + bp->b_resid = bp->b_bcount; + if (pbn != cs->sc_size) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR | B_INVAL; + } + goto done; + } + + /* + * If the request crosses EOF, truncate the request. + */ + if (pbn + sz > cs->sc_size) { + bp->b_bcount = (cs->sc_size - pbn) * + cs->sc_geom.ccg_secsize; + } + } bp->b_resid = bp->b_bcount; |