diff options
author | phk <phk@FreeBSD.org> | 2000-04-15 05:54:02 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-04-15 05:54:02 +0000 |
commit | aaaef0b54e307450b19dcd1fb6ec921cc62d1acf (patch) | |
tree | 175dac1aaf0d06b54deb889161091dbcf88c79c6 /sys/kern | |
parent | f2310ef109eccf99c872f4f90eb70f4fc26e39f1 (diff) | |
download | FreeBSD-src-aaaef0b54e307450b19dcd1fb6ec921cc62d1acf.zip FreeBSD-src-aaaef0b54e307450b19dcd1fb6ec921cc62d1acf.tar.gz |
Complete the bio/buf divorce for all code below devfs::strategy
Exceptions:
Vinum untouched. This means that it cannot be compiled.
Greg Lehey is on the case.
CCD not converted yet, casts to struct buf (still safe)
atapi-cd casts to struct buf to examine B_PHYS
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_disk.c | 22 | ||||
-rw-r--r-- | sys/kern/subr_disklabel.c | 22 | ||||
-rw-r--r-- | sys/kern/subr_diskmbr.c | 4 | ||||
-rw-r--r-- | sys/kern/subr_diskslice.c | 80 | ||||
-rw-r--r-- | sys/kern/vfs_bio.c | 10 | ||||
-rw-r--r-- | sys/kern/vfs_cluster.c | 2 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 2 |
7 files changed, 75 insertions, 67 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 6d812e5..0838056 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -173,25 +173,25 @@ diskclose(dev_t dev, int fflag, int devtype, struct proc *p) } static void -diskstrategy(struct buf *bp) +diskstrategy(struct bio *bp) { dev_t pdev; struct disk *dp; - dp = bp->b_dev->si_disk; + dp = bp->bio_dev->si_disk; if (!dp) { - pdev = dkmodpart(dkmodslice(bp->b_dev, WHOLE_DISK_SLICE), RAW_PART); - dp = bp->b_dev->si_disk = pdev->si_disk; - bp->b_dev->si_drv1 = pdev->si_drv1; - bp->b_dev->si_drv2 = pdev->si_drv2; - bp->b_dev->si_iosize_max = pdev->si_iosize_max; - bp->b_dev->si_bsize_phys = pdev->si_bsize_phys; - bp->b_dev->si_bsize_best = pdev->si_bsize_best; + pdev = dkmodpart(dkmodslice(bp->bio_dev, WHOLE_DISK_SLICE), RAW_PART); + dp = bp->bio_dev->si_disk = pdev->si_disk; + bp->bio_dev->si_drv1 = pdev->si_drv1; + bp->bio_dev->si_drv2 = pdev->si_drv2; + bp->bio_dev->si_iosize_max = pdev->si_iosize_max; + bp->bio_dev->si_bsize_phys = pdev->si_bsize_phys; + bp->bio_dev->si_bsize_best = pdev->si_bsize_best; } if (!dp) { - bp->b_error = ENXIO; - bp->b_ioflags |= BIO_ERROR; + bp->bio_error = ENXIO; + bp->bio_flags |= BIO_ERROR; biodone(bp); return; } diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c index 551652f..8a1fc0b 100644 --- a/sys/kern/subr_disklabel.c +++ b/sys/kern/subr_disklabel.c @@ -453,14 +453,14 @@ hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d) */ void diskerr(bp, what, pri, blkdone, lp) - register struct buf *bp; + struct bio *bp; char *what; int pri, blkdone; register struct disklabel *lp; { - int unit = dkunit(bp->b_dev); - int slice = dkslice(bp->b_dev); - int part = dkpart(bp->b_dev); + int unit = dkunit(bp->bio_dev); + int slice = dkslice(bp->bio_dev); + int part = dkpart(bp->bio_dev); register int (*pr) __P((const char *, ...)); char partname[2]; char *sname; @@ -471,21 +471,21 @@ diskerr(bp, what, pri, blkdone, lp) pr = addlog; } else pr = printf; - sname = dsname(bp->b_dev, unit, slice, part, partname); + sname = dsname(bp->bio_dev, unit, slice, part, partname); (*pr)("%s%s: %s %sing fsbn ", sname, partname, what, - bp->b_iocmd == BIO_READ ? "read" : "writ"); - sn = bp->b_blkno; - if (bp->b_bcount <= DEV_BSIZE) + bp->bio_cmd == BIO_READ ? "read" : "writ"); + sn = bp->bio_blkno; + if (bp->bio_bcount <= DEV_BSIZE) (*pr)("%ld", (long)sn); else { if (blkdone >= 0) { sn += blkdone; (*pr)("%ld of ", (long)sn); } - (*pr)("%ld-%ld", (long)bp->b_blkno, - (long)(bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE)); + (*pr)("%ld-%ld", (long)bp->bio_blkno, + (long)(bp->bio_blkno + (bp->bio_bcount - 1) / DEV_BSIZE)); } - if (lp && (blkdone >= 0 || bp->b_bcount <= lp->d_secsize)) { + if (lp && (blkdone >= 0 || bp->bio_bcount <= lp->d_secsize)) { #ifdef tahoe sn *= DEV_BSIZE / lp->d_secsize; /* XXX */ #endif diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index f9e2eba..0d63747 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -190,7 +190,7 @@ reread_mbr: bp->b_iocmd = BIO_READ; DEV_STRATEGY(bp, 1); if (biowait(bp) != 0) { - diskerr(bp, "reading primary partition table: error", + diskerr(&bp->b_io, "reading primary partition table: error", LOG_PRINTF, 0, (struct disklabel *)NULL); printf("\n"); error = EIO; @@ -406,7 +406,7 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors, bp->b_iocmd = BIO_READ; DEV_STRATEGY(bp, 1); if (biowait(bp) != 0) { - diskerr(bp, "reading extended partition table: error", + diskerr(&bp->b_io, "reading extended partition table: error", LOG_PRINTF, 0, (struct disklabel *)NULL); printf("\n"); goto done; diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index fda1901..361bbdb 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -146,7 +146,7 @@ clone_label(lp) */ int dscheck(bp, ssp) - struct buf *bp; + struct bio *bp; struct diskslices *ssp; { daddr_t blkno; @@ -161,34 +161,34 @@ dscheck(bp, ssp) struct diskslice *sp; int s; - blkno = bp->b_blkno; + blkno = bp->bio_blkno; if (blkno < 0) { - printf("dscheck(%s): negative b_blkno %ld\n", - devtoname(bp->b_dev), (long)blkno); - bp->b_error = EINVAL; + printf("dscheck(%s): negative bio_blkno %ld\n", + devtoname(bp->bio_dev), (long)blkno); + bp->bio_error = EINVAL; goto bad; } - sp = &ssp->dss_slices[dkslice(bp->b_dev)]; + sp = &ssp->dss_slices[dkslice(bp->bio_dev)]; lp = sp->ds_label; if (ssp->dss_secmult == 1) { - if (bp->b_bcount % (u_long)DEV_BSIZE) + if (bp->bio_bcount % (u_long)DEV_BSIZE) goto bad_bcount; secno = blkno; - nsec = bp->b_bcount >> DEV_BSHIFT; + nsec = bp->bio_bcount >> DEV_BSHIFT; } else if (ssp->dss_secshift != -1) { - if (bp->b_bcount & (ssp->dss_secsize - 1)) + if (bp->bio_bcount & (ssp->dss_secsize - 1)) goto bad_bcount; if (blkno & (ssp->dss_secmult - 1)) goto bad_blkno; secno = blkno >> ssp->dss_secshift; - nsec = bp->b_bcount >> (DEV_BSHIFT + ssp->dss_secshift); + nsec = bp->bio_bcount >> (DEV_BSHIFT + ssp->dss_secshift); } else { - if (bp->b_bcount % ssp->dss_secsize) + if (bp->bio_bcount % ssp->dss_secsize) goto bad_bcount; if (blkno % ssp->dss_secmult) goto bad_blkno; secno = blkno / ssp->dss_secmult; - nsec = bp->b_bcount / ssp->dss_secsize; + nsec = bp->bio_bcount / ssp->dss_secsize; } if (lp == NULL) { labelsect = -LABELSECTOR - 1; @@ -197,7 +197,7 @@ dscheck(bp, ssp) } else { labelsect = lp->d_partitions[LABEL_PART].p_offset; if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); - pp = &lp->d_partitions[dkpart(bp->b_dev)]; + pp = &lp->d_partitions[dkpart(bp->bio_dev)]; endsecno = pp->p_size; slicerel_secno = pp->p_offset + secno; } @@ -208,16 +208,16 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); #if LABELSECTOR != 0 slicerel_secno + nsec > LABELSECTOR + labelsect && #endif - (bp->b_iocmd == BIO_WRITE) && sp->ds_wlabel == 0) { - bp->b_error = EROFS; + (bp->bio_cmd == BIO_WRITE) && sp->ds_wlabel == 0) { + bp->bio_error = EROFS; goto bad; } #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ - if (slicerel_secno <= DOSBBSECTOR && (bp->b_iocmd == BIO_WRITE) && + if (slicerel_secno <= DOSBBSECTOR && (bp->bio_cmd == BIO_WRITE) && sp->ds_wlabel == 0) { - bp->b_error = EROFS; + bp->bio_error = EROFS; goto bad; } #endif @@ -226,19 +226,19 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); if (secno + nsec > endsecno) { /* if exactly at end of disk, return an EOF */ if (secno == endsecno) { - bp->b_resid = bp->b_bcount; + bp->bio_resid = bp->bio_bcount; return (0); } /* or truncate if part of it fits */ nsec = endsecno - secno; if (nsec <= 0) { - bp->b_error = EINVAL; + bp->bio_error = EINVAL; goto bad; } - bp->b_bcount = nsec * ssp->dss_secsize; + bp->bio_bcount = nsec * ssp->dss_secsize; } - bp->b_pblkno = sp->ds_offset + slicerel_secno; + bp->bio_pblkno = sp->ds_offset + slicerel_secno; /* * Snoop on label accesses if the slice offset is nonzero. Fudge @@ -253,15 +253,15 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); struct iodone_chain *ic; ic = malloc(sizeof *ic , M_DEVBUF, M_WAITOK); - ic->ic_prev_flags = bp->b_flags; - ic->ic_prev_iodone = bp->b_iodone; - ic->ic_prev_iodone_chain = bp->b_iodone_chain; + ic->ic_prev_flags = bp->bio_flags; + ic->ic_prev_iodone = bp->bio_done; + ic->ic_prev_iodone_chain = bp->bio_done_chain; ic->ic_args[0].ia_long = (LABELSECTOR + labelsect - slicerel_secno) * ssp->dss_secsize; ic->ic_args[1].ia_ptr = sp; - bp->b_iodone = dsiodone; - bp->b_iodone_chain = ic; - if (!(bp->b_iocmd == BIO_READ)) { + bp->bio_done = dsiodone; + bp->bio_done_chain = ic; + if (!(bp->bio_cmd == BIO_READ)) { /* * XXX even disklabel(8) writes directly so we need * to adjust writes. Perhaps we should drop support @@ -271,20 +271,22 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); * XXX probably need to copy the data to avoid even * temporarily corrupting the in-core copy. */ +#ifdef notyet if (bp->b_vp != NULL) { s = splbio(); bp->b_vp->v_numoutput++; splx(s); } +#endif /* XXX need name here. */ msg = fixlabel((char *)NULL, sp, (struct disklabel *) - (bp->b_data + ic->ic_args[0].ia_long), + (bp->bio_data + ic->ic_args[0].ia_long), TRUE); if (msg != NULL) { printf("dscheck(%s): %s\n", - devtoname(bp->b_dev), msg); - bp->b_error = EROFS; + devtoname(bp->bio_dev), msg); + bp->bio_error = EROFS; goto bad; } } @@ -293,21 +295,21 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); bad_bcount: printf( - "dscheck(%s): b_bcount %ld is not on a sector boundary (ssize %d)\n", - devtoname(bp->b_dev), bp->b_bcount, ssp->dss_secsize); - bp->b_error = EINVAL; + "dscheck(%s): bio_bcount %ld is not on a sector boundary (ssize %d)\n", + devtoname(bp->bio_dev), bp->bio_bcount, ssp->dss_secsize); + bp->bio_error = EINVAL; goto bad; bad_blkno: printf( - "dscheck(%s): b_blkno %ld is not on a sector boundary (ssize %d)\n", - devtoname(bp->b_dev), (long)blkno, ssp->dss_secsize); - bp->b_error = EINVAL; + "dscheck(%s): bio_blkno %ld is not on a sector boundary (ssize %d)\n", + devtoname(bp->bio_dev), (long)blkno, ssp->dss_secsize); + bp->bio_error = EINVAL; goto bad; bad: - bp->b_resid = bp->b_bcount; - bp->b_ioflags |= BIO_ERROR; + bp->bio_resid = bp->bio_bcount; + bp->bio_flags |= BIO_ERROR; return (-1); } @@ -549,7 +551,7 @@ dsiodone(bp) printf("%s\n", msg); } free(ic, M_DEVBUF); - biodone(bp); + biodone((struct bio *)bp); /* XXX */ } int diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index be40650..222a644 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -703,7 +703,7 @@ vfs_backgroundwritedone(bp) bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_CACHE | B_DONE); bp->b_iodone = 0; - biodone(bp); + bufdone(bp); } /* @@ -2627,7 +2627,13 @@ biowait(register struct buf * bp) * in the biodone routine. */ void -biodone(register struct buf * bp) +biodone(struct bio * bip) +{ + bufdone((struct buf *)bip); +} + +void +bufdone(struct buf *bp) { int s; void (*biodone) __P((struct buf *)); diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 44ac985..a19367a 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -489,7 +489,7 @@ cluster_callback(bp) tbp->b_flags &= ~B_INVAL; tbp->b_ioflags &= ~BIO_ERROR; } - biodone(tbp); + bufdone(tbp); } relpbuf(bp, &cluster_pbuf_freecnt); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 71504a5..b362ff1 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -167,7 +167,7 @@ vop_nostrategy (struct vop_strategy_args *ap) vprint("", ap->a_bp->b_vp); ap->a_bp->b_ioflags |= BIO_ERROR; ap->a_bp->b_error = EOPNOTSUPP; - biodone(ap->a_bp); + bufdone(ap->a_bp); return (EOPNOTSUPP); } |