diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-02-23 14:42:40 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-02-23 14:42:40 +0000 |
commit | 96e821437735f981862bb50be47e2c291a615907 (patch) | |
tree | 163b1a3c8a068ad3cf4e4e6e3ba48d03a79eec2c | |
parent | 51008faf3223ac4bc87038c7550574709c459445 (diff) |
Remove the clustering fields from the vnodes and place them in the
file system inode instead
-rw-r--r-- | sys/adosfs/advnops.c | 3 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_node.h | 3 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vnops.c | 10 | ||||
-rw-r--r-- | sys/kern/spec_vnops.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_cluster.c | 117 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 11 | ||||
-rw-r--r-- | sys/miscfs/specfs/spec_vnops.c | 4 | ||||
-rw-r--r-- | sys/miscfs/specfs/specdev.h | 3 | ||||
-rw-r--r-- | sys/msdosfs/denode.h | 3 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/nfs/nfs_bio.c | 3 | ||||
-rw-r--r-- | sys/sys/buf.h | 22 | ||||
-rw-r--r-- | sys/sys/specdev.h | 3 | ||||
-rw-r--r-- | sys/sys/vnode.h | 10 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_readwrite.c | 10 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 6 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_readwrite.c | 14 |
18 files changed, 124 insertions, 111 deletions
diff --git a/sys/adosfs/advnops.c b/sys/adosfs/advnops.c index 9c900a82d90..2ea1c91f482 100644 --- a/sys/adosfs/advnops.c +++ b/sys/adosfs/advnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: advnops.c,v 1.15 1998/08/21 23:03:16 csapuntz Exp $ */ +/* $OpenBSD: advnops.c,v 1.16 2001/02/23 14:42:37 csapuntz Exp $ */ /* $NetBSD: advnops.c,v 1.32 1996/10/13 02:52:09 christos Exp $ */ /* @@ -310,7 +310,6 @@ adosfs_read(v) */ error = bread(sp->a_vp, lbn * amp->secsperblk, amp->bsize, NOCRED, &bp); - sp->a_vp->v_lastr = lbn; if (!IS_FFS(amp)) { if (bp->b_resid > 0) diff --git a/sys/isofs/cd9660/cd9660_node.h b/sys/isofs/cd9660/cd9660_node.h index 357d1b414f4..6990d0872a3 100644 --- a/sys/isofs/cd9660/cd9660_node.h +++ b/sys/isofs/cd9660/cd9660_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_node.h,v 1.7 1998/08/21 23:31:34 csapuntz Exp $ */ +/* $OpenBSD: cd9660_node.h,v 1.8 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: cd9660_node.h,v 1.15 1997/04/11 21:52:01 kleink Exp $ */ /*- @@ -94,6 +94,7 @@ struct iso_node { long iso_start; /* actual start of data of file (may be different */ /* from iso_extent, if file has extended attributes) */ ISO_RRIP_INODE inode; + struct cluster_info i_ci; }; #define i_forw i_chain[0] diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 86fb0318fb5..65d3d7f1289 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.12 1999/11/13 03:48:09 angelos Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.13 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -343,12 +343,12 @@ cd9660_read(v) rablock = lbn + 1; if (cd9660_doclusterread) { if (lblktosize(imp, rablock) <= ip->i_size) - error = cluster_read(vp, (off_t)ip->i_size, - lbn, size, NOCRED, &bp); + error = cluster_read(vp, &ip->i_ci, + (off_t)ip->i_size, lbn, size, NOCRED, &bp); else error = bread(vp, lbn, size, NOCRED, &bp); } else { - if (vp->v_lastr + 1 == lbn && + if (ip->i_ci.ci_lastr + 1 == lbn && lblktosize(imp, rablock) < ip->i_size) { rasize = blksize(imp, ip, rablock); error = breadn(vp, lbn, size, &rablock, @@ -356,7 +356,7 @@ cd9660_read(v) } else error = bread(vp, lbn, size, NOCRED, &bp); } - vp->v_lastr = lbn; + ip->i_ci.ci_lastr = lbn; n = min(n, size - bp->b_resid); if (error) { brelse(bp); diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c index ca03010b899..234073b5d61 100644 --- a/sys/kern/spec_vnops.c +++ b/sys/kern/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.15 1998/02/23 17:40:58 niklas Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.16 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -54,6 +54,8 @@ #include <miscfs/specfs/specdev.h> +#define v_lastr v_specinfo->si_lastr + /* symbolic sleep message strings for devices */ char devopn[] = "devopn"; char devio[] = "devio"; diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 1839e585f0f..46fbe3ae206 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_cluster.c,v 1.18 2001/02/21 23:24:30 csapuntz Exp $ */ +/* $OpenBSD: vfs_cluster.c,v 1.19 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: vfs_cluster.c,v 1.12 1996/04/22 01:39:05 christos Exp $ */ /*- @@ -50,13 +50,15 @@ /* * Local declarations */ +void cluster_callback __P((struct buf *)); struct buf *cluster_newbuf __P((struct vnode *, struct buf *, long, daddr_t, daddr_t, long, int)); struct buf *cluster_rbuild __P((struct vnode *, u_quad_t, struct buf *, daddr_t, daddr_t, long, int, long)); void cluster_wbuild __P((struct vnode *, struct buf *, long, daddr_t, int, daddr_t)); -struct cluster_save *cluster_collectbufs __P((struct vnode *, struct buf *)); +struct cluster_save *cluster_collectbufs __P((struct vnode *, + struct cluster_info *, struct buf *)); #ifdef DIAGNOSTIC /* @@ -72,12 +74,12 @@ struct cluster_save *cluster_collectbufs __P((struct vnode *, struct buf *)); * showed that the latter performed better from a system-wide point of view. */ int doclusterraz = 0; -#define ISSEQREAD(vp, blk) \ +#define ISSEQREAD(ci, blk) \ (((blk) != 0 || doclusterraz) && \ - ((blk) == (vp)->v_lastr + 1 || (blk) == (vp)->v_lastr)) + ((blk) == (ci)->ci_lastr + 1 || (blk) == (ci)->ci_lastr)) #else -#define ISSEQREAD(vp, blk) \ - ((blk) != 0 && ((blk) == (vp)->v_lastr + 1 || (blk) == (vp)->v_lastr)) +#define ISSEQREAD(ci, blk) \ + ((blk) != 0 && ((blk) == (ci)->ci_lastr + 1 || (blk) == (ci)->ci_lastr)) #endif /* @@ -101,8 +103,9 @@ int doclusterraz = 0; * If either is NULL, then you don't have to do the I/O. */ int -cluster_read(vp, filesize, lblkno, size, cred, bpp) +cluster_read(vp, ci, filesize, lblkno, size, cred, bpp) struct vnode *vp; + struct cluster_info *ci; u_quad_t filesize; daddr_t lblkno; long size; @@ -128,7 +131,7 @@ cluster_read(vp, filesize, lblkno, size, cred, bpp) * Case 1, 2. */ flags |= B_ASYNC; - ioblkno = lblkno + (vp->v_ralen ? vp->v_ralen : 1); + ioblkno = lblkno + (ci->ci_ralen ? ci->ci_ralen : 1); alreadyincore = incore(vp, ioblkno) != NULL; bp = NULL; } else { @@ -150,9 +153,9 @@ cluster_read(vp, filesize, lblkno, size, cred, bpp) * but at smaller than the filesystem block size. */ rbp = NULL; - if (!ISSEQREAD(vp, lblkno)) { - vp->v_ralen = 0; - vp->v_maxra = lblkno; + if (!ISSEQREAD(ci, lblkno)) { + ci->ci_ralen = 0; + ci->ci_maxra = lblkno; } else if ((u_quad_t)(ioblkno + 1) * (u_quad_t)size <= filesize && !alreadyincore && !(error = VOP_BMAP(vp, ioblkno, NULL, &blkno, &num_ra)) && @@ -169,19 +172,19 @@ cluster_read(vp, filesize, lblkno, size, cred, bpp) * or are not using our readahead very rapidly. * In this case we scale back the window. */ - if (!alreadyincore && ioblkno <= vp->v_maxra) - vp->v_ralen = max(vp->v_ralen >> 1, 1); + if (!alreadyincore && ioblkno <= ci->ci_maxra) + ci->ci_ralen = max(ci->ci_ralen >> 1, 1); /* * There are more sequential blocks than our current * window allows, scale up. Ideally we want to get * in sync with the filesystem maxcontig value. */ - else if (num_ra > vp->v_ralen && lblkno != vp->v_lastr) - vp->v_ralen = vp->v_ralen ? - min(num_ra, vp->v_ralen << 1) : 1; + else if (num_ra > ci->ci_ralen && lblkno != ci->ci_lastr) + ci->ci_ralen = ci->ci_ralen ? + min(num_ra, ci->ci_ralen << 1) : 1; - if (num_ra > vp->v_ralen) - num_ra = vp->v_ralen; + if (num_ra > ci->ci_ralen) + num_ra = ci->ci_ralen; } if (num_ra) /* case 2, 4 */ @@ -202,14 +205,14 @@ cluster_read(vp, filesize, lblkno, size, cred, bpp) * the previous conditional. */ if (num_ra) { - if (ioblkno <= vp->v_maxra) - vp->v_ralen = max(vp->v_ralen >> 1, 1); - else if (num_ra > vp->v_ralen && - lblkno != vp->v_lastr) - vp->v_ralen = vp->v_ralen ? - min(num_ra,vp->v_ralen<<1) : 1; - if (num_ra > vp->v_ralen) - num_ra = vp->v_ralen; + if (ioblkno <= ci->ci_maxra) + ci->ci_ralen = max(ci->ci_ralen >> 1, 1); + else if (num_ra > ci->ci_ralen && + lblkno != ci->ci_lastr) + ci->ci_ralen = ci->ci_ralen ? + min(num_ra,ci->ci_ralen<<1) : 1; + if (num_ra > ci->ci_ralen) + num_ra = ci->ci_ralen; } flags |= B_ASYNC; if (num_ra) @@ -256,7 +259,7 @@ skip_readahead: if (rbp == NULL) rbp = bp; if (rbp) - vp->v_maxra = rbp->b_lblkno + (rbp->b_bcount / size) - 1; + ci->ci_maxra = rbp->b_lblkno + (rbp->b_bcount / size) - 1; if (bp) return(biowait(bp)); @@ -478,8 +481,9 @@ cluster_callback(bp) * 4. end of a cluster - asynchronously write cluster */ void -cluster_write(bp, filesize) +cluster_write(bp, ci, filesize) struct buf *bp; + struct cluster_info *ci; u_quad_t filesize; { struct vnode *vp; @@ -491,12 +495,12 @@ cluster_write(bp, filesize) /* Initialize vnode to beginning of file. */ if (lbn == 0) - vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; + ci->ci_lasta = ci->ci_clen = ci->ci_cstart = ci->ci_lastw = 0; - if (vp->v_clen == 0 || lbn != vp->v_lastw + 1 || - (bp->b_blkno != vp->v_lasta + btodb(bp->b_bcount))) { + if (ci->ci_clen == 0 || lbn != ci->ci_lastw + 1 || + (bp->b_blkno != ci->ci_lasta + btodb(bp->b_bcount))) { maxclen = MAXBSIZE / vp->v_mount->mnt_stat.f_iosize - 1; - if (vp->v_clen != 0) { + if (ci->ci_clen != 0) { /* * Next block is not sequential. * @@ -506,16 +510,16 @@ cluster_write(bp, filesize) * cluster size, then push the previous cluster. * Otherwise try reallocating to make it sequential. */ - cursize = vp->v_lastw - vp->v_cstart + 1; + cursize = ci->ci_lastw - ci->ci_cstart + 1; if (((u_quad_t)(lbn + 1)) * bp->b_bcount != filesize || - lbn != vp->v_lastw + 1 || vp->v_clen <= cursize) { + lbn != ci->ci_lastw + 1 || ci->ci_clen <= cursize) { cluster_wbuild(vp, NULL, bp->b_bcount, - vp->v_cstart, cursize, lbn); + ci->ci_cstart, cursize, lbn); } else { struct buf **bpp, **endbp; struct cluster_save *buflist; - buflist = cluster_collectbufs(vp, bp); + buflist = cluster_collectbufs(vp, ci, bp); endbp = &buflist->bs_children [buflist->bs_nchildren - 1]; if (VOP_REALLOCBLKS(vp, buflist)) { @@ -527,7 +531,7 @@ cluster_write(bp, filesize) brelse(*bpp); free(buflist, M_SEGMENT); cluster_wbuild(vp, NULL, bp->b_bcount, - vp->v_cstart, cursize, lbn); + ci->ci_cstart, cursize, lbn); } else { /* * Succeeded, keep building cluster. @@ -536,8 +540,8 @@ cluster_write(bp, filesize) bpp <= endbp; bpp++) bdwrite(*bpp); free(buflist, M_SEGMENT); - vp->v_lastw = lbn; - vp->v_lasta = bp->b_blkno; + ci->ci_lastw = lbn; + ci->ci_lasta = bp->b_blkno; return; } } @@ -551,36 +555,36 @@ cluster_write(bp, filesize) (VOP_BMAP(vp, lbn, NULL, &bp->b_blkno, &maxclen) || bp->b_blkno == -1)) { bawrite(bp); - vp->v_clen = 0; - vp->v_lasta = bp->b_blkno; - vp->v_cstart = lbn + 1; - vp->v_lastw = lbn; + ci->ci_clen = 0; + ci->ci_lasta = bp->b_blkno; + ci->ci_cstart = lbn + 1; + ci->ci_lastw = lbn; return; } - vp->v_clen = maxclen; + ci->ci_clen = maxclen; if (maxclen == 0) { /* I/O not contiguous */ - vp->v_cstart = lbn + 1; + ci->ci_cstart = lbn + 1; bawrite(bp); } else { /* Wait for rest of cluster */ - vp->v_cstart = lbn; + ci->ci_cstart = lbn; bdwrite(bp); } - } else if (lbn == vp->v_cstart + vp->v_clen) { + } else if (lbn == ci->ci_cstart + ci->ci_clen) { /* * At end of cluster, write it out. */ - cluster_wbuild(vp, bp, bp->b_bcount, vp->v_cstart, - vp->v_clen + 1, lbn); - vp->v_clen = 0; - vp->v_cstart = lbn + 1; + cluster_wbuild(vp, bp, bp->b_bcount, ci->ci_cstart, + ci->ci_clen + 1, lbn); + ci->ci_clen = 0; + ci->ci_cstart = lbn + 1; } else /* * In the middle of a cluster, so just delay the * I/O for now. */ bdwrite(bp); - vp->v_lastw = lbn; - vp->v_lasta = bp->b_blkno; + ci->ci_lastw = lbn; + ci->ci_lasta = bp->b_blkno; } @@ -741,20 +745,21 @@ redo: * Plus add one additional buffer. */ struct cluster_save * -cluster_collectbufs(vp, last_bp) +cluster_collectbufs(vp, ci, last_bp) struct vnode *vp; + struct cluster_info *ci; struct buf *last_bp; { struct cluster_save *buflist; daddr_t lbn; int i, len; - len = vp->v_lastw - vp->v_cstart + 1; + len = ci->ci_lastw - ci->ci_cstart + 1; buflist = malloc(sizeof(struct buf *) * (len + 1) + sizeof(*buflist), M_SEGMENT, M_WAITOK); buflist->bs_nchildren = 0; buflist->bs_children = (struct buf **)(buflist + 1); - for (lbn = vp->v_cstart, i = 0; i < len; lbn++, i++) + for (lbn = ci->ci_cstart, i = 0; i < len; lbn++, i++) (void)bread(vp, lbn, last_bp->b_bcount, NOCRED, &buflist->bs_children[i]); buflist->bs_children[i] = last_bp; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index bee6b56c1ae..abb8b66970f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.49 2001/02/21 23:24:30 csapuntz Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.50 2001/02/23 14:42:37 csapuntz Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -72,6 +72,7 @@ #include <uvm/uvm_extern.h> #endif + enum vtype iftovt_tab[16] = { VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON, VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VBAD, @@ -426,7 +427,6 @@ getnewvnode(tag, mp, vops, vpp) vp->v_flag &= ~VONFREELIST; simple_unlock(&vnode_free_list_slock); - vp->v_lease = NULL; if (vp->v_type != VBAD) vgonel(vp, p); else @@ -442,13 +442,6 @@ getnewvnode(tag, mp, vops, vpp) splx(s); #endif vp->v_flag = 0; - vp->v_lastr = 0; - vp->v_ralen = 0; - vp->v_maxra = 0; - vp->v_lastw = 0; - vp->v_lasta = 0; - vp->v_cstart = 0; - vp->v_clen = 0; vp->v_socket = 0; } vp->v_type = VNON; diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index ca03010b899..234073b5d61 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.15 1998/02/23 17:40:58 niklas Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.16 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -54,6 +54,8 @@ #include <miscfs/specfs/specdev.h> +#define v_lastr v_specinfo->si_lastr + /* symbolic sleep message strings for devices */ char devopn[] = "devopn"; char devio[] = "devio"; diff --git a/sys/miscfs/specfs/specdev.h b/sys/miscfs/specfs/specdev.h index 2f6db5186f2..3d7de64876b 100644 --- a/sys/miscfs/specfs/specdev.h +++ b/sys/miscfs/specfs/specdev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specdev.h,v 1.7 1998/08/06 19:34:48 csapuntz Exp $ */ +/* $OpenBSD: specdev.h,v 1.8 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: specdev.h,v 1.12 1996/02/13 13:13:01 mycroft Exp $ */ /* @@ -47,6 +47,7 @@ struct specinfo { struct mount *si_mountpoint; dev_t si_rdev; struct lockf *si_lockf; + daddr_t si_lastr; }; /* * Exported shorthand diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h index 23aa4c78889..6a573fa2ada 100644 --- a/sys/msdosfs/denode.h +++ b/sys/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: denode.h,v 1.8 1999/11/17 09:27:22 art Exp $ */ +/* $OpenBSD: denode.h,v 1.9 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: denode.h,v 1.24 1997/10/17 11:23:39 ws Exp $ */ /*- @@ -141,6 +141,7 @@ struct denode { struct vnode *de_devvp; /* vnode of blk dev we live on */ u_long de_flag; /* flag bits */ dev_t de_dev; /* device where direntry lives */ + daddr_t de_lastr; u_long de_dirclust; /* cluster of the directory file containing this entry */ u_long de_diroffset; /* offset of this entry in the directory cluster */ u_long de_fndoffset; /* offset of found dir entry */ diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index bd93befb3d2..f2fa0cadeda 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.22 2000/06/07 15:04:06 art Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.23 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */ /*- @@ -469,7 +469,7 @@ msdosfs_read(v) error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp); } else { rablock = lbn + 1; - if (vp->v_lastr + 1 == lbn && + if (dep->de_lastr + 1 == lbn && de_cn2off(pmp, rablock) < dep->de_FileSize) error = breada(vp, de_cn2bn(pmp, lbn), pmp->pm_bpcluster, de_cn2bn(pmp, rablock), @@ -477,7 +477,7 @@ msdosfs_read(v) else error = bread(vp, de_cn2bn(pmp, lbn), pmp->pm_bpcluster, NOCRED, &bp); - vp->v_lastr = lbn; + dep->de_lastr = lbn; } n = min(n, pmp->pm_bpcluster - bp->b_resid); if (error) { diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index a216e9a87e0..a7c8598f465 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_bio.c,v 1.16 2000/06/23 02:14:40 mickey Exp $ */ +/* $OpenBSD: nfs_bio.c,v 1.17 2001/02/23 14:42:38 csapuntz Exp $ */ /* $NetBSD: nfs_bio.c,v 1.25.4.2 1996/07/08 20:47:04 jtc Exp $ */ /* @@ -271,7 +271,6 @@ again: goto again; } } - vp->v_lastr = lbn; diff = (on >= bp->b_validend) ? 0 : (bp->b_validend - on); if (diff < n) n = diff; diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 0ea3baee7b2..276d047bc96 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.16 2001/02/21 23:24:30 csapuntz Exp $ */ +/* $OpenBSD: buf.h,v 1.17 2001/02/23 14:42:37 csapuntz Exp $ */ /* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */ /* @@ -206,10 +206,6 @@ void bremfree __P((struct buf *)); void bufinit __P((void)); void bdirty __P((struct buf *)); int bwrite __P((struct buf *)); -void cluster_callback __P((struct buf *)); -int cluster_read __P((struct vnode *, u_quad_t, daddr_t, long, - struct ucred *, struct buf **)); -void cluster_write __P((struct buf *, u_quad_t)); struct buf *getblk __P((struct vnode *, daddr_t, int, int, int)); struct buf *geteblk __P((int)); struct buf *getnewbuf __P((int slpflag, int slptimeo)); @@ -259,6 +255,22 @@ buf_countdeps(struct buf *bp, int i) return (0); } +struct cluster_info { + daddr_t ci_lastr; /* last read (read-ahead) */ + daddr_t ci_lastw; /* last write (write cluster) */ + daddr_t ci_cstart; /* start block of cluster */ + daddr_t ci_lasta; /* last allocation */ + int ci_clen; /* length of current cluster */ + int ci_ralen; /* Read-ahead length */ + daddr_t ci_maxra; /* last readahead block */ +}; + + +int cluster_read __P((struct vnode *, struct cluster_info *, + u_quad_t, daddr_t, long, + struct ucred *, struct buf **)); +void cluster_write __P((struct buf *, struct cluster_info *, u_quad_t)); + __END_DECLS #endif #endif /* !_SYS_BUF_H_ */ diff --git a/sys/sys/specdev.h b/sys/sys/specdev.h index 2f6db5186f2..3d7de64876b 100644 --- a/sys/sys/specdev.h +++ b/sys/sys/specdev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specdev.h,v 1.7 1998/08/06 19:34:48 csapuntz Exp $ */ +/* $OpenBSD: specdev.h,v 1.8 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: specdev.h,v 1.12 1996/02/13 13:13:01 mycroft Exp $ */ /* @@ -47,6 +47,7 @@ struct specinfo { struct mount *si_mountpoint; dev_t si_rdev; struct lockf *si_lockf; + daddr_t si_lastr; }; /* * Exported shorthand diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 8251fb22e7e..b33a081cd93 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.27 2001/02/21 23:24:30 csapuntz Exp $ */ +/* $OpenBSD: vnode.h,v 1.28 2001/02/23 14:42:37 csapuntz Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -94,7 +94,6 @@ struct vnode { int v_usecount; /* reference count of users */ int v_writecount; /* reference count of writers */ long v_holdcnt; /* page & buffer references */ - daddr_t v_lastr; /* last read (read-ahead) */ u_long v_id; /* capability identifier */ struct mount *v_mount; /* ptr to vfs we are in */ int (**v_op) __P((void *)); /* vnode operations vector */ @@ -113,12 +112,7 @@ struct vnode { struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ } v_un; struct nqlease *v_lease; /* Soft reference to lease */ - daddr_t v_lastw; /* last write (write cluster) */ - daddr_t v_cstart; /* start block of cluster */ - daddr_t v_lasta; /* last allocation */ - int v_clen; /* length of current cluster */ - int v_ralen; /* Read-ahead length */ - daddr_t v_maxra; /* last readahead block */ + struct simplelock v_interlock; /* lock on usecount and flag */ struct lock *v_vnlock; /* used for non-locking fs's */ #ifdef UVM diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index 8535646acf4..8985d4c1918 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_readwrite.c,v 1.5 1999/02/26 03:22:00 art Exp $ */ +/* $OpenBSD: ext2fs_readwrite.c,v 1.6 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: ext2fs_readwrite.c,v 1.1 1997/06/11 09:34:01 bouyer Exp $ */ /*- @@ -128,9 +128,9 @@ ext2fs_read(v) if (lblktosize(fs, nextlbn) >= ip->i_e2fs_size) error = bread(vp, lbn, size, NOCRED, &bp); else if (doclusterread) - error = cluster_read(vp, + error = cluster_read(vp, &ip->i_ci, ip->i_e2fs_size, lbn, size, NOCRED, &bp); - else if (lbn - 1 == vp->v_lastr) { + else if (lbn - 1 == ip->i_ci.ci_lastr) { int nextsize = fs->e2fs_bsize; error = breadn(vp, lbn, size, &nextlbn, &nextsize, 1, NOCRED, &bp); @@ -138,7 +138,7 @@ ext2fs_read(v) error = bread(vp, lbn, size, NOCRED, &bp); if (error) break; - vp->v_lastr = lbn; + ip->i_ci.ci_lastr = lbn; /* * We should only get non-zero b_resid when an I/O error @@ -278,7 +278,7 @@ ext2fs_write(v) (void)bwrite(bp); else if (xfersize + blkoffset == fs->e2fs_bsize) { if (doclusterwrite) - cluster_write(bp, ip->i_e2fs_size); + cluster_write(bp, &ip->i_ci, ip->i_e2fs_size); else bawrite(bp); } else diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 6607642eae3..1eb8f2e81ca 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.17 2001/02/21 23:24:31 csapuntz Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.18 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -208,7 +208,9 @@ ffs_truncate(v) #else vnode_pager_setsize(ovp, (u_long)length); #endif - ovp->v_lasta = ovp->v_clen = ovp->v_cstart = ovp->v_lastw = 0; + oip->i_ci.ci_lasta = oip->i_ci.ci_clen + = oip->i_ci.ci_cstart = oip->i_ci.ci_lastw = 0; + if (DOINGSOFTDEP(ovp)) { if (length > 0 || softdep_slowdown(ovp)) { /* diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 7d23b147966..96b7ee6be18 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.12 2001/02/21 23:24:31 csapuntz Exp $ */ +/* $OpenBSD: inode.h,v 1.13 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -82,6 +82,7 @@ struct inode { #define i_lfs inode_u.lfs #define i_e2fs inode_u.e2fs + struct cluster_info i_ci; struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 4eb92eb225c..04bd52787bf 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_readwrite.c,v 1.16 2000/11/21 21:49:57 provos Exp $ */ +/* $OpenBSD: ufs_readwrite.c,v 1.17 2001/02/23 14:42:39 csapuntz Exp $ */ /* $NetBSD: ufs_readwrite.c,v 1.9 1996/05/11 18:27:57 mycroft Exp $ */ /*- @@ -126,15 +126,15 @@ READ(v) #ifdef LFS_READWRITE (void)lfs_check(vp, lbn); - error = cluster_read(vp, ip->i_ffs_size, lbn, size, NOCRED, - &bp); + error = cluster_read(vp, &ip->i_ci, ip->i_ffs_size, lbn, + size, NOCRED, &bp); #else if (lblktosize(fs, nextlbn) >= ip->i_ffs_size) error = bread(vp, lbn, size, NOCRED, &bp); else if (doclusterread) - error = cluster_read(vp, + error = cluster_read(vp, &ip->i_ci, ip->i_ffs_size, lbn, size, NOCRED, &bp); - else if (lbn - 1 == vp->v_lastr) { + else if (lbn - 1 == ip->i_ci.ci_lastr) { int nextsize = BLKSIZE(fs, ip, nextlbn); error = breadn(vp, lbn, size, &nextlbn, &nextsize, 1, NOCRED, &bp); @@ -143,7 +143,7 @@ READ(v) #endif if (error) break; - vp->v_lastr = lbn; + ip->i_ci.ci_lastr = lbn; /* * We should only get non-zero b_resid when an I/O error @@ -288,7 +288,7 @@ WRITE(v) (void)bwrite(bp); else if (xfersize + blkoffset == fs->fs_bsize) { if (doclusterwrite) - cluster_write(bp, ip->i_ffs_size); + cluster_write(bp, &ip->i_ci, ip->i_ffs_size); else bawrite(bp); } else |