summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2013-11-21 00:13:33 +0000
committerdlg <dlg@openbsd.org>2013-11-21 00:13:33 +0000
commit27f37992c7cdc39b161d12d3ddece4279978470d (patch)
treec7debb46788f6d3bc7ca81110db36be15bf72332 /sys
parentUpdate comments mentioning `resource maps' to mention `extents' instead. (diff)
downloadwireguard-openbsd-27f37992c7cdc39b161d12d3ddece4279978470d.tar.xz
wireguard-openbsd-27f37992c7cdc39b161d12d3ddece4279978470d.zip
remove the #define b_cylinder b_resid from bufs. i hated the
overloading of that thing. the only hardware that seems to care about cylinders in our tree are floppy drives, and the drivers for those calculate their own cylinders from logical block addresses and ignore whatever the rest of the kernel thought b_cylinders should be. most of this diff is moving the floppy drivers to using b_resid as a resid and using that as part of the calculation for real cylinder values. the rest of the diff is getting rid of the useless assignments to b_cylinder that dont get used by anything (now that disksort is gone). ok miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/dkcsum.c3
-rw-r--r--sys/arch/i386/i386/dkcsum.c3
-rw-r--r--sys/arch/sparc/dev/fd.c34
-rw-r--r--sys/arch/sparc64/dev/fd.c31
-rw-r--r--sys/dev/isa/fd.c29
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c3
-rw-r--r--sys/kern/subr_hibernate.c3
-rw-r--r--sys/sys/buf.h8
-rw-r--r--sys/uvm/uvm_swap.c5
9 files changed, 56 insertions, 63 deletions
diff --git a/sys/arch/amd64/amd64/dkcsum.c b/sys/arch/amd64/amd64/dkcsum.c
index 22108e837c2..44e6fff9984 100644
--- a/sys/arch/amd64/amd64/dkcsum.c
+++ b/sys/arch/amd64/amd64/dkcsum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcsum.c,v 1.19 2011/06/27 01:14:24 krw Exp $ */
+/* $OpenBSD: dkcsum.c,v 1.20 2013/11/21 00:13:33 dlg Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -116,7 +116,6 @@ dkcsumattach(void)
bp->b_error = 0; /* B_ERROR and b_error may have stale data. */
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE | B_ERROR);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
- bp->b_cylinder = 0;
(*bdsw->d_strategy)(bp);
if ((error = biowait(bp))) {
/* XXX What to do here? */
diff --git a/sys/arch/i386/i386/dkcsum.c b/sys/arch/i386/i386/dkcsum.c
index 12e24c8dd06..20ed865be53 100644
--- a/sys/arch/i386/i386/dkcsum.c
+++ b/sys/arch/i386/i386/dkcsum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcsum.c,v 1.30 2011/06/27 01:14:24 krw Exp $ */
+/* $OpenBSD: dkcsum.c,v 1.31 2013/11/21 00:13:33 dlg Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -116,7 +116,6 @@ dkcsumattach(void)
bp->b_error = 0; /* B_ERROR and b_error may have stale data. */
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE | B_ERROR);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
- bp->b_cylinder = 0;
(*bdsw->d_strategy)(bp);
if ((error = biowait(bp))) {
/* XXX What to do here? */
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c
index 7dbb9a57ddc..d1f4352c4c3 100644
--- a/sys/arch/sparc/dev/fd.c
+++ b/sys/arch/sparc/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.87 2013/11/18 01:56:35 dlg Exp $ */
+/* $OpenBSD: fd.c,v 1.88 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */
/*-
@@ -705,6 +705,7 @@ fdstrategy(bp)
if (bp->b_bcount == 0)
goto done;
+ bp->b_resid = bp->b_count;
sz = howmany(bp->b_bcount, DEV_BSIZE);
if (bp->b_blkno + sz > (fd->sc_type->size * DEV_BSIZE) / FD_BSIZE(fd)) {
@@ -712,7 +713,6 @@ fdstrategy(bp)
- bp->b_blkno;
if (sz == 0) {
/* If exactly at end of disk, return EOF. */
- bp->b_resid = bp->b_bcount;
goto done;
}
if (sz < 0) {
@@ -724,14 +724,11 @@ fdstrategy(bp)
bp->b_bcount = sz << DEV_BSHIFT;
}
- bp->b_cylinder = (bp->b_blkno * DEV_BSIZE) /
- (FD_BSIZE(fd) * fd->sc_type->seccyl);
-
#ifdef FD_DEBUG
if (fdc_debug > 1)
- printf("fdstrategy: b_blkno %lld b_bcount %ld blkno %lld "
- "cylin %ld\n", (long long)bp->b_blkno, bp->b_bcount,
- (long long)fd->sc_blkno, bp->b_cylinder);
+ printf("fdstrategy: b_blkno %lld b_bcount %ld blkno %lld\n",
+ (long long)bp->b_blkno, bp->b_bcount,
+ (long long)fd->sc_blkno);
#endif
/* Queue transfer */
@@ -802,7 +799,6 @@ fdfinish(fd, bp)
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
}
- bp->b_resid = fd->sc_bcount;
biodone(bp);
/* turn off motor 5s from now */
timeout_add_sec(&fd->fd_motor_off_to, 5);
@@ -1262,11 +1258,10 @@ fdcstate(fdc)
struct fd_softc *fd;
struct buf *bp;
- int read, head, sec, nblks;
+ int read, head, sec, nblks, cylin;
struct fd_type *type;
struct fd_formb *finfo = NULL;
-
if (fdc->sc_istatus == FDC_ISTATUS_ERROR) {
/* Prevent loop if the reset sequence produces errors */
if (fdc->sc_state != RESETCOMPLETE &&
@@ -1295,6 +1290,9 @@ loop:
goto loop;
}
+ cylin = ((bp->b_blkno * DEV_BSIZE) + (bp->b_bcount - bp->b_resid)) /
+ (FD_BSIZE(fd) * fd->sc_type->seccyl);
+
if (bp->b_flags & B_FORMAT)
finfo = (struct fd_formb *)bp->b_data;
@@ -1336,12 +1334,12 @@ loop:
doseek:
if ((fdc->sc_flags & FDC_EIS) &&
(bp->b_flags & B_FORMAT) == 0) {
- fd->sc_cylin = bp->b_cylinder;
+ fd->sc_cylin = cylin;
/* We use implied seek */
goto doio;
}
- if (fd->sc_cylin == bp->b_cylinder)
+ if (fd->sc_cylin == cylin)
goto doio;
fd->sc_cylin = -1;
@@ -1363,7 +1361,7 @@ loop:
/* seek function */
FDC_WRFIFO(fdc, NE7CMD_SEEK);
FDC_WRFIFO(fdc, fd->sc_drive); /* drive number */
- FDC_WRFIFO(fdc, bp->b_cylinder * fd->sc_type->step);
+ FDC_WRFIFO(fdc, cylin * fd->sc_type->step);
return (1);
@@ -1459,7 +1457,7 @@ loop:
/* Make sure seek really happened. */
if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 ||
- cyl != bp->b_cylinder * fd->sc_type->step) {
+ cyl != cylin * fd->sc_type->step) {
#ifdef FD_DEBUG
if (fdc_debug)
fdcstatus(fdc, "seek failed");
@@ -1467,7 +1465,7 @@ loop:
fdcretry(fdc);
goto loop;
}
- fd->sc_cylin = bp->b_cylinder;
+ fd->sc_cylin = cylin;
goto doio;
case IOTIMEDOUT:
@@ -1574,8 +1572,9 @@ loop:
fd->sc_blkno += fd->sc_nblks;
fd->sc_skip += fd->sc_nbytes;
fd->sc_bcount -= fd->sc_nbytes;
+ bp->b_resid -= fd->sc_nbytes;
if (finfo == NULL && fd->sc_bcount > 0) {
- bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl;
+ cylin = fd->sc_blkno / fd->sc_type->seccyl;
goto doseek;
}
fdfinish(fd, bp);
@@ -1723,6 +1722,7 @@ fdcretry(fdc)
failsilent:
bp->b_flags |= B_ERROR;
bp->b_error = error;
+ bp->b_resid = bp->b_bcount;
fdfinish(fd, bp);
}
fdc->sc_errors++;
diff --git a/sys/arch/sparc64/dev/fd.c b/sys/arch/sparc64/dev/fd.c
index 36436fdfb81..99fef50f537 100644
--- a/sys/arch/sparc64/dev/fd.c
+++ b/sys/arch/sparc64/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.42 2013/11/02 22:58:49 dlg Exp $ */
+/* $OpenBSD: fd.c,v 1.43 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: fd.c,v 1.112 2003/08/07 16:29:35 agc Exp $ */
/*-
@@ -725,6 +725,7 @@ fdstrategy(bp)
if (bp->b_bcount == 0)
goto done;
+ bp->b_resid = bp->b_bcount;
sz = howmany(bp->b_bcount, DEV_BSIZE);
if (bp->b_blkno + sz > (fd->sc_type->size * DEV_BSIZE) / FD_BSIZE(fd)) {
@@ -732,7 +733,6 @@ fdstrategy(bp)
- bp->b_blkno;
if (sz == 0) {
/* If exactly at end of disk, return EOF. */
- bp->b_resid = bp->b_bcount;
goto done;
}
if (sz < 0) {
@@ -744,14 +744,11 @@ fdstrategy(bp)
bp->b_bcount = sz << DEV_BSHIFT;
}
- bp->b_cylinder = (bp->b_blkno * DEV_BSIZE) /
- (FD_BSIZE(fd) * fd->sc_type->seccyl);
-
#ifdef FD_DEBUG
if (fdc_debug > 1)
- printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld cylin %d\n",
+ printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld\n",
(long long)bp->b_blkno, bp->b_bcount,
- (long long)fd->sc_blkno, bp->b_cylinder);
+ (long long)fd->sc_blkno);
#endif
/* Queue transfer */
@@ -822,7 +819,6 @@ fdfinish(fd, bp)
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
}
- bp->b_resid = fd->sc_bcount;
biodone(bp);
/* turn off motor 5s from now */
timeout_add_sec(&fd->sc_motoroff_to, 5);
@@ -1295,7 +1291,7 @@ fdcstate(fdc)
struct fd_softc *fd;
struct buf *bp;
- int read, head, sec, nblks;
+ int read, head, sec, nblks, cylin;
struct fd_type *type;
struct fd_formb *finfo = NULL;
@@ -1330,6 +1326,9 @@ loop:
if (bp->b_flags & B_FORMAT)
finfo = (struct fd_formb *)bp->b_data;
+ cylin = ((bp->b_blkno * DEV_BSIZE) - (bp->b_bcount - bp->b_resid)) /
+ (FD_BSIZE(fd) * fd->sc_type->seccyl);
+
switch (fdc->sc_state) {
case DEVIDLE:
fdc->sc_errors = 0;
@@ -1371,12 +1370,12 @@ loop:
doseek:
if ((fdc->sc_flags & FDC_EIS) &&
(bp->b_flags & B_FORMAT) == 0) {
- fd->sc_cylin = bp->b_cylinder;
+ fd->sc_cylin = cylin;
/* We use implied seek */
goto doio;
}
- if (fd->sc_cylin == bp->b_cylinder)
+ if (fd->sc_cylin == cylin);
goto doio;
fd->sc_cylin = -1;
@@ -1398,7 +1397,7 @@ loop:
/* seek function */
FDC_WRFIFO(fdc, NE7CMD_SEEK);
FDC_WRFIFO(fdc, fd->sc_drive); /* drive number */
- FDC_WRFIFO(fdc, bp->b_cylinder * fd->sc_type->step);
+ FDC_WRFIFO(fdc, cylin * fd->sc_type->step);
return (1);
case DODSKCHG:
@@ -1531,7 +1530,7 @@ loop:
/* Make sure seek really happened. */
if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 ||
- cyl != bp->b_cylinder * fd->sc_type->step) {
+ cyl != cylin * fd->sc_type->step) {
#ifdef FD_DEBUG
if (fdc_debug)
fdcstatus(fdc, "seek failed");
@@ -1539,7 +1538,7 @@ loop:
fdcretry(fdc);
goto loop;
}
- fd->sc_cylin = bp->b_cylinder;
+ fd->sc_cylin = cylin;
goto doio;
case IOTIMEDOUT:
@@ -1647,8 +1646,9 @@ loop:
fd->sc_blkno += fd->sc_nblks;
fd->sc_skip += fd->sc_nbytes;
fd->sc_bcount -= fd->sc_nbytes;
+ bp->b_resid -= fd->sc_nbytes;
if (finfo == NULL && fd->sc_bcount > 0) {
- bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl;
+ cylin = fd->sc_blkno / fd->sc_type->seccyl;
goto doseek;
}
fdfinish(fd, bp);
@@ -1796,6 +1796,7 @@ fdcretry(fdc)
failsilent:
bp->b_flags |= B_ERROR;
bp->b_error = error;
+ bp->b_resid = bp->b_bcount;
fdfinish(fd, bp);
}
fdc->sc_errors++;
diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c
index aa816b3cbc6..335ca1909c8 100644
--- a/sys/dev/isa/fd.c
+++ b/sys/dev/isa/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.96 2013/11/01 17:36:19 krw Exp $ */
+/* $OpenBSD: fd.c,v 1.97 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */
/*-
@@ -409,12 +409,12 @@ fdstrategy(struct buf *bp)
bp->b_bcount = sz << DEV_BSHIFT;
}
- bp->b_cylinder = bp->b_blkno / (fd_bsize / DEV_BSIZE) / fd->sc_type->seccyl;
+ bp->b_resid = bp->b_bcount;
#ifdef FD_DEBUG
- printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld cylin %d "
- "sz %d\n", (long long)bp->b_blkno, bp->b_bcount,
- (long long)fd->sc_blkno, bp->b_cylinder, sz);
+ printf("fdstrategy: b_blkno %lld b_bcount %d blkno %lld sz %d\n",
+ (long long)bp->b_blkno, bp->b_bcount,
+ (long long)fd->sc_blkno, sz);
#endif
/* Queue I/O */
@@ -469,7 +469,6 @@ fdfinish(struct fd_softc *fd, struct buf *bp)
splassert(IPL_BIO);
- bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_bp = bufq_dequeue(&fd->sc_bufq);
@@ -652,7 +651,7 @@ fdintr(struct fdc_softc *fdc)
bus_space_tag_t iot = fdc->sc_iot;
bus_space_handle_t ioh = fdc->sc_ioh;
bus_space_handle_t ioh_ctl = fdc->sc_ioh_ctl;
- int read, head, sec, i, nblks;
+ int read, head, sec, i, nblks, cylin;
struct fd_type *type;
struct fd_formb *finfo = NULL;
int fd_bsize;
@@ -676,6 +675,9 @@ loop:
if (bp->b_flags & B_FORMAT)
finfo = (struct fd_formb *)bp->b_data;
+ cylin = ((bp->b_blkno * DEV_BSIZE) + (bp->b_bcount - bp->b_resid)) /
+ (fd_bsize * fd->sc_type->seccyl);
+
switch (fdc->sc_state) {
case DEVIDLE:
fdc->sc_errors = 0;
@@ -708,7 +710,7 @@ loop:
/* FALLTHROUGH */
case DOSEEK:
doseek:
- if (fd->sc_cylin == bp->b_cylinder)
+ if (fd->sc_cylin == cylin)
goto doio;
out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
@@ -717,7 +719,7 @@ loop:
out_fdc(iot, ioh, NE7CMD_SEEK); /* seek function */
out_fdc(iot, ioh, fd->sc_drive); /* drive number */
- out_fdc(iot, ioh, bp->b_cylinder * fd->sc_type->step);
+ out_fdc(iot, ioh, cylin * fd->sc_type->step);
fd->sc_cylin = -1;
fdc->sc_state = SEEKWAIT;
@@ -805,14 +807,14 @@ loop:
/* Make sure seek really happened. */
out_fdc(iot, ioh, NE7CMD_SENSEI);
if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 ||
- cyl != bp->b_cylinder * fd->sc_type->step) {
+ cyl != cylin * fd->sc_type->step) {
#ifdef FD_DEBUG
fdcstatus(&fd->sc_dev, 2, "seek failed");
#endif
fdretry(fd);
goto loop;
}
- fd->sc_cylin = bp->b_cylinder;
+ fd->sc_cylin = cylin;
goto doio;
case IOTIMEDOUT:
@@ -848,11 +850,13 @@ loop:
printf("\n");
fdc->sc_errors = 0;
}
+
fd->sc_blkno += fd->sc_nblks;
fd->sc_skip += fd->sc_nbytes;
fd->sc_bcount -= fd->sc_nbytes;
+ bp->b_resid -= fd->sc_nbytes;
if (!finfo && fd->sc_bcount > 0) {
- bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl;
+ cylin = fd->sc_blkno / fd->sc_type->seccyl;
goto doseek;
}
fdfinish(fd, bp);
@@ -976,6 +980,7 @@ fdretry(struct fd_softc *fd)
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
+ bp->b_resid = bp->b_bcount;
fdfinish(fd, bp);
}
fdc->sc_errors++;
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 692572108c5..b2ca7736baf 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vfsops.c,v 1.64 2013/06/02 01:07:39 deraadt Exp $ */
+/* $OpenBSD: cd9660_vfsops.c,v 1.65 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */
/*-
@@ -490,7 +490,6 @@ iso_disklabelspoof(dev, strat, lp)
bp->b_bcount = ISO_DEFAULT_BLOCK_SIZE;
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
- bp->b_cylinder = bp->b_blkno / lp->d_secpercyl;
/*printf("d_secsize %d iso_blknum %d b_blkno %d bcount %d\n",
lp->d_secsize, iso_blknum, bp->b_blkno, bp->b_bcount);*/
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index 9ec1dfea257..b724c4a4cfd 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.80 2013/11/09 06:54:00 mlarkin Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.81 2013/11/21 00:13:33 dlg Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -1059,7 +1059,6 @@ hibernate_block_io(union hibernate_info *hib, daddr_t blkctr,
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
SET(bp->b_flags, B_BUSY | (iswrite ? B_WRITE : B_READ) | B_RAW);
bp->b_dev = hib->dev;
- bp->b_cylinder = 0;
(*bdsw->d_strategy)(bp);
error = biowait(bp);
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 8113a3372ff..eeb1ef99244 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.91 2013/11/20 23:52:42 dlg Exp $ */
+/* $OpenBSD: buf.h,v 1.92 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */
/*
@@ -187,12 +187,6 @@ struct buf {
struct workhead b_dep; /* List of filesystem dependencies. */
};
-/*
- * For portability with historic industry practice, the cylinder number has
- * to be maintained in the `b_resid' field.
- */
-#define b_cylinder b_resid /* Cylinder number for disksort(). */
-
/* Device driver compatibility definitions. */
#define b_active b_bcount /* Driver queue head: drive active. */
#define b_errcnt b_resid /* Retry count while I/O in progress. */
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index 6a1c763af6b..f4a2590d0bc 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.122 2013/11/20 23:57:07 miod Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.123 2013/11/21 00:13:33 dlg Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
@@ -1294,9 +1294,6 @@ sw_reg_strategy(struct swapdev *sdp, struct buf *bp, int bn)
/* patch it back to the vnx */
task_set(&nbp->vb_task, sw_reg_iodone_internal, nbp, vnx);
- /* XXX: In case the underlying bufq is disksort: */
- nbp->vb_buf.b_cylinder = nbp->vb_buf.b_blkno;
-
s = splbio();
if (vnx->vx_error != 0) {
putvndbuf(nbp);