More removals of vnode->v_lastr, replaced by preexisting seqcount
heuristic to detect sequential operation. VM-related forced clustering code removed from ufs in preparation for a commit to vm/vm_fault.c that does it more generally. Reviewed by: David Greenman <dg@root.com>, Alan Cox <alc@cs.rice.edu>
This commit is contained in:
parent
01d4ea186e
commit
ffc7764cb8
@ -275,8 +275,11 @@ cd9660_read(ap)
|
||||
daddr_t lbn, rablock;
|
||||
off_t diff;
|
||||
int rasize, error = 0;
|
||||
int seqcount;
|
||||
long size, n, on;
|
||||
|
||||
seqcount = ap->a_ioflag >> 16;
|
||||
|
||||
if (uio->uio_resid == 0)
|
||||
return (0);
|
||||
if (uio->uio_offset < 0)
|
||||
@ -303,7 +306,7 @@ cd9660_read(ap)
|
||||
else
|
||||
error = bread(vp, lbn, size, NOCRED, &bp);
|
||||
} else {
|
||||
if (vp->v_lastr + 1 == lbn &&
|
||||
if (seqcount > 1 &&
|
||||
lblktosize(imp, rablock) < ip->i_size) {
|
||||
rasize = blksize(imp, ip, rablock);
|
||||
error = breadn(vp, lbn, size, &rablock,
|
||||
@ -311,7 +314,6 @@ cd9660_read(ap)
|
||||
} else
|
||||
error = bread(vp, lbn, size, NOCRED, &bp);
|
||||
}
|
||||
vp->v_lastr = lbn;
|
||||
n = min(n, size - bp->b_resid);
|
||||
if (error) {
|
||||
brelse(bp);
|
||||
|
@ -769,8 +769,8 @@ msdosfs_unmount(mp, mntflags, p)
|
||||
printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
|
||||
printf("flag %08lx, usecount %d, writecount %d, holdcnt %ld\n",
|
||||
vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
|
||||
printf("lastr %d, id %lu, mount %p, op %p\n",
|
||||
vp->v_lastr, vp->v_id, vp->v_mount, vp->v_op);
|
||||
printf("id %lu, mount %p, op %p\n",
|
||||
vp->v_id, vp->v_mount, vp->v_op);
|
||||
printf("freef %p, freeb %p, mount %p\n",
|
||||
vp->v_freelist.tqe_next, vp->v_freelist.tqe_prev,
|
||||
vp->v_mount);
|
||||
|
@ -559,6 +559,7 @@ msdosfs_read(ap)
|
||||
daddr_t lbn;
|
||||
daddr_t rablock;
|
||||
int rasize;
|
||||
int seqcount;
|
||||
struct buf *bp;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct denode *dep = VTODE(vp);
|
||||
@ -575,6 +576,8 @@ msdosfs_read(ap)
|
||||
if (orig_resid <= 0)
|
||||
return (0);
|
||||
|
||||
seqcount = ap->a_ioflag >> 16;
|
||||
|
||||
isadir = dep->de_Attributes & ATTR_DIRECTORY;
|
||||
do {
|
||||
lbn = de_cluster(pmp, uio->uio_offset);
|
||||
@ -600,15 +603,15 @@ msdosfs_read(ap)
|
||||
error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
|
||||
} else {
|
||||
rablock = lbn + 1;
|
||||
if (vp->v_lastr + 1 == lbn &&
|
||||
if (seqcount > 1 &&
|
||||
de_cn2off(pmp, rablock) < dep->de_FileSize) {
|
||||
rasize = pmp->pm_bpcluster;
|
||||
error = breadn(vp, lbn, pmp->pm_bpcluster,
|
||||
&rablock, &rasize, 1, NOCRED, &bp);
|
||||
} else
|
||||
} else {
|
||||
error = bread(vp, lbn, pmp->pm_bpcluster,
|
||||
NOCRED, &bp);
|
||||
vp->v_lastr = lbn;
|
||||
}
|
||||
}
|
||||
n = min(n, pmp->pm_bpcluster - bp->b_resid);
|
||||
if (error) {
|
||||
|
@ -37,6 +37,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ufs_readwrite.c 8.7 (Berkeley) 1/21/94
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define BLKSIZE(a, b, c) blksize(a, b, c)
|
||||
@ -69,6 +70,7 @@ READ(ap)
|
||||
off_t bytesinfile;
|
||||
long size, xfersize, blkoffset;
|
||||
int error, orig_resid;
|
||||
int seqcount = ap->a_ioflag >> 16;
|
||||
u_short mode;
|
||||
|
||||
vp = ap->a_vp;
|
||||
@ -113,7 +115,7 @@ READ(ap)
|
||||
error = cluster_read(vp,
|
||||
ip->i_size, lbn, size, NOCRED,
|
||||
uio->uio_resid, (ap->a_ioflag >> 16), &bp);
|
||||
else if (lbn - 1 == vp->v_lastr) {
|
||||
else if (seqcount > 1) {
|
||||
int nextsize = BLKSIZE(fs, ip, nextlbn);
|
||||
error = breadn(vp, lbn,
|
||||
size, &nextlbn, &nextsize, 1, NOCRED, &bp);
|
||||
@ -124,7 +126,6 @@ READ(ap)
|
||||
bp = NULL;
|
||||
break;
|
||||
}
|
||||
vp->v_lastr = lbn;
|
||||
|
||||
/*
|
||||
* We should only get non-zero b_resid when an I/O error
|
||||
|
@ -37,6 +37,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ufs_readwrite.c 8.7 (Berkeley) 1/21/94
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define BLKSIZE(a, b, c) blksize(a, b, c)
|
||||
@ -69,6 +70,7 @@ READ(ap)
|
||||
off_t bytesinfile;
|
||||
long size, xfersize, blkoffset;
|
||||
int error, orig_resid;
|
||||
int seqcount = ap->a_ioflag >> 16;
|
||||
u_short mode;
|
||||
|
||||
vp = ap->a_vp;
|
||||
@ -113,7 +115,7 @@ READ(ap)
|
||||
error = cluster_read(vp,
|
||||
ip->i_size, lbn, size, NOCRED,
|
||||
uio->uio_resid, (ap->a_ioflag >> 16), &bp);
|
||||
else if (lbn - 1 == vp->v_lastr) {
|
||||
else if (seqcount > 1) {
|
||||
int nextsize = BLKSIZE(fs, ip, nextlbn);
|
||||
error = breadn(vp, lbn,
|
||||
size, &nextlbn, &nextsize, 1, NOCRED, &bp);
|
||||
@ -124,7 +126,6 @@ READ(ap)
|
||||
bp = NULL;
|
||||
break;
|
||||
}
|
||||
vp->v_lastr = lbn;
|
||||
|
||||
/*
|
||||
* We should only get non-zero b_resid when an I/O error
|
||||
|
@ -275,8 +275,11 @@ cd9660_read(ap)
|
||||
daddr_t lbn, rablock;
|
||||
off_t diff;
|
||||
int rasize, error = 0;
|
||||
int seqcount;
|
||||
long size, n, on;
|
||||
|
||||
seqcount = ap->a_ioflag >> 16;
|
||||
|
||||
if (uio->uio_resid == 0)
|
||||
return (0);
|
||||
if (uio->uio_offset < 0)
|
||||
@ -303,7 +306,7 @@ cd9660_read(ap)
|
||||
else
|
||||
error = bread(vp, lbn, size, NOCRED, &bp);
|
||||
} else {
|
||||
if (vp->v_lastr + 1 == lbn &&
|
||||
if (seqcount > 1 &&
|
||||
lblktosize(imp, rablock) < ip->i_size) {
|
||||
rasize = blksize(imp, ip, rablock);
|
||||
error = breadn(vp, lbn, size, &rablock,
|
||||
@ -311,7 +314,6 @@ cd9660_read(ap)
|
||||
} else
|
||||
error = bread(vp, lbn, size, NOCRED, &bp);
|
||||
}
|
||||
vp->v_lastr = lbn;
|
||||
n = min(n, size - bp->b_resid);
|
||||
if (error) {
|
||||
brelse(bp);
|
||||
|
@ -769,8 +769,8 @@ msdosfs_unmount(mp, mntflags, p)
|
||||
printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
|
||||
printf("flag %08lx, usecount %d, writecount %d, holdcnt %ld\n",
|
||||
vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
|
||||
printf("lastr %d, id %lu, mount %p, op %p\n",
|
||||
vp->v_lastr, vp->v_id, vp->v_mount, vp->v_op);
|
||||
printf("id %lu, mount %p, op %p\n",
|
||||
vp->v_id, vp->v_mount, vp->v_op);
|
||||
printf("freef %p, freeb %p, mount %p\n",
|
||||
vp->v_freelist.tqe_next, vp->v_freelist.tqe_prev,
|
||||
vp->v_mount);
|
||||
|
@ -559,6 +559,7 @@ msdosfs_read(ap)
|
||||
daddr_t lbn;
|
||||
daddr_t rablock;
|
||||
int rasize;
|
||||
int seqcount;
|
||||
struct buf *bp;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct denode *dep = VTODE(vp);
|
||||
@ -575,6 +576,8 @@ msdosfs_read(ap)
|
||||
if (orig_resid <= 0)
|
||||
return (0);
|
||||
|
||||
seqcount = ap->a_ioflag >> 16;
|
||||
|
||||
isadir = dep->de_Attributes & ATTR_DIRECTORY;
|
||||
do {
|
||||
lbn = de_cluster(pmp, uio->uio_offset);
|
||||
@ -600,15 +603,15 @@ msdosfs_read(ap)
|
||||
error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
|
||||
} else {
|
||||
rablock = lbn + 1;
|
||||
if (vp->v_lastr + 1 == lbn &&
|
||||
if (seqcount > 1 &&
|
||||
de_cn2off(pmp, rablock) < dep->de_FileSize) {
|
||||
rasize = pmp->pm_bpcluster;
|
||||
error = breadn(vp, lbn, pmp->pm_bpcluster,
|
||||
&rablock, &rasize, 1, NOCRED, &bp);
|
||||
} else
|
||||
} else {
|
||||
error = bread(vp, lbn, pmp->pm_bpcluster,
|
||||
NOCRED, &bp);
|
||||
vp->v_lastr = lbn;
|
||||
}
|
||||
}
|
||||
n = min(n, pmp->pm_bpcluster - bp->b_resid);
|
||||
if (error) {
|
||||
|
@ -135,16 +135,15 @@ READ(ap)
|
||||
if ((uio->uio_resid == 0) || (error != 0)) {
|
||||
/*
|
||||
* If we finished or there was an error
|
||||
* then finish up.
|
||||
* then finish up (the reference previously
|
||||
* obtained on object must be released).
|
||||
*/
|
||||
if ((error == 0 ||
|
||||
uio->uio_resid != orig_resid) &&
|
||||
(vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
|
||||
ip->i_flag |= IN_ACCESS;
|
||||
|
||||
if (object)
|
||||
/*
|
||||
* This I don't understand
|
||||
*/
|
||||
vm_object_vndeallocate(object);
|
||||
return error;
|
||||
}
|
||||
@ -178,6 +177,12 @@ READ(ap)
|
||||
if (toread >= PAGE_SIZE) {
|
||||
error = uioread(toread, uio, object, &nread);
|
||||
if ((uio->uio_resid == 0) || (error != 0)) {
|
||||
/*
|
||||
* If we finished or there was an
|
||||
* error then finish up (the reference
|
||||
* previously obtained on object must
|
||||
* be released).
|
||||
*/
|
||||
if ((error == 0 ||
|
||||
uio->uio_resid != orig_resid) &&
|
||||
(vp->v_mount->mnt_flag &
|
||||
@ -243,7 +248,7 @@ READ(ap)
|
||||
*/
|
||||
error = cluster_read(vp, ip->i_size, lbn,
|
||||
size, NOCRED, uio->uio_resid, seqcount, &bp);
|
||||
else if (lbn - 1 == vp->v_lastr) {
|
||||
else if (seqcount > 1) {
|
||||
/*
|
||||
* If we are NOT allowed to cluster, then
|
||||
* if we appear to be acting sequentially,
|
||||
@ -268,12 +273,6 @@ READ(ap)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remember where we read so we can see latter if we start
|
||||
* acting sequential.
|
||||
*/
|
||||
vp->v_lastr = lbn;
|
||||
|
||||
/*
|
||||
* We should only get non-zero b_resid when an I/O error
|
||||
* has occurred, which should cause us to break above.
|
||||
@ -543,7 +542,7 @@ ffs_getpages(ap)
|
||||
struct vnode *dp, *vp;
|
||||
vm_object_t obj;
|
||||
vm_pindex_t pindex, firstindex;
|
||||
vm_page_t m, mreq;
|
||||
vm_page_t mreq;
|
||||
int bbackwards, bforwards;
|
||||
int pbackwards, pforwards;
|
||||
int firstpage;
|
||||
@ -586,71 +585,6 @@ ffs_getpages(ap)
|
||||
return vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
|
||||
ap->a_count,
|
||||
ap->a_reqpage);
|
||||
|
||||
|
||||
if (firstindex == 0)
|
||||
vp->v_lastr = 0;
|
||||
|
||||
if ((firstindex != 0) &&
|
||||
(firstindex <= vp->v_lastr) &&
|
||||
((firstindex + pcount) > vp->v_lastr)) {
|
||||
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
int error;
|
||||
|
||||
for (i = 0; i < pcount; i++) {
|
||||
m = ap->a_m[i];
|
||||
vm_page_activate(m);
|
||||
vm_page_io_start(m);
|
||||
vm_page_wakeup(m);
|
||||
}
|
||||
|
||||
auio.uio_iov = &aiov;
|
||||
auio.uio_iovcnt = 1;
|
||||
aiov.iov_base = 0;
|
||||
aiov.iov_len = MAXBSIZE;
|
||||
auio.uio_resid = MAXBSIZE;
|
||||
auio.uio_offset = foff;
|
||||
auio.uio_segflg = UIO_NOCOPY;
|
||||
auio.uio_rw = UIO_READ;
|
||||
auio.uio_procp = curproc;
|
||||
error = VOP_READ(vp, &auio,
|
||||
IO_VMIO | ((MAXBSIZE / bsize) << 16), curproc->p_ucred);
|
||||
|
||||
for (i = 0; i < pcount; i++) {
|
||||
m = ap->a_m[i];
|
||||
vm_page_io_finish(m);
|
||||
|
||||
if ((m != mreq) && (m->wire_count == 0) && (m->hold_count == 0) &&
|
||||
(m->valid == 0) && (m->busy == 0) &&
|
||||
(m->flags & PG_BUSY) == 0) {
|
||||
vm_page_busy(m);
|
||||
vm_page_free(m);
|
||||
} else if (m == mreq) {
|
||||
while (vm_page_sleep_busy(m, FALSE, "ffspwt"))
|
||||
;
|
||||
vm_page_busy(m);
|
||||
vp->v_lastr = m->pindex + 1;
|
||||
} else {
|
||||
if (m->wire_count == 0) {
|
||||
if (m->busy || (m->flags & PG_MAPPED) ||
|
||||
(m->flags & (PG_WANTED | PG_BUSY)) == PG_WANTED) {
|
||||
vm_page_activate(m);
|
||||
} else {
|
||||
vm_page_deactivate(m);
|
||||
}
|
||||
}
|
||||
vp->v_lastr = m->pindex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mreq->valid == 0)
|
||||
return VM_PAGER_ERROR;
|
||||
if (mreq->valid != VM_PAGE_BITS_ALL)
|
||||
vm_page_zero_invalid(mreq, TRUE);
|
||||
return VM_PAGER_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* foff is the file offset of the required page
|
||||
@ -717,7 +651,6 @@ ffs_getpages(ap)
|
||||
*/
|
||||
|
||||
size = pcount * PAGE_SIZE;
|
||||
vp->v_lastr = mreq->pindex + pcount;
|
||||
|
||||
if ((IDX_TO_OFF(ap->a_m[firstpage]->pindex) + size) >
|
||||
obj->un_pager.vnp.vnp_size)
|
||||
|
Loading…
Reference in New Issue
Block a user