Index: sys/buf.h =================================================================== RCS file: /home/ncvs/src/sys/sys/buf.h,v retrieving revision 1.207 diff -p -u -r1.207 buf.h --- sys/buf.h 28 Mar 2008 12:30:12 -0000 1.207 +++ sys/buf.h 2 Apr 2008 10:23:43 -0000 @@ -219,12 +219,12 @@ struct buf { #define B_NEEDSGIANT 0x02000000 /* Buffer's vnode needs giant. */ #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ #define B_MANAGED 0x08000000 /* Managed by FS. */ -#define B_RAM 0x10000000 /* Read ahead mark (flag) */ +#define B_100000000 0x10000000 /* Available flag. */ #define B_VMIO 0x20000000 /* VMIO flag */ #define B_CLUSTER 0x40000000 /* pagein op, so swap() can count it */ #define B_REMFREE 0x80000000 /* Delayed bremfree */ -#define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35ram\34b27" \ +#define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35b28\34paging" \ "\33paging\32b25\31b24\30b23\27relbuf\26dirty\25b20" \ "\24b19\23b18\22clusterok\21malloc\20nocache\17b14\16inval" \ "\15b12\14b11\13eintr\12done\11persist\10delwri\7validsuspwrt" \ Index: kern/vfs_cluster.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_cluster.c,v retrieving revision 1.177 diff -p -u -r1.177 vfs_cluster.c --- kern/vfs_cluster.c 22 Mar 2008 09:15:14 -0000 1.177 +++ kern/vfs_cluster.c 2 Apr 2008 10:23:44 -0000 @@ -98,7 +98,6 @@ cluster_read(vp, filesize, lblkno, size, daddr_t blkno, origblkno; int maxra, racluster; int error, ncontig; - int i; error = 0; bo = &vp->v_bufobj; @@ -121,46 +120,21 @@ cluster_read(vp, filesize, lblkno, size, origblkno = lblkno; /* - * if it is in the cache, then check to see if the reads have been - * sequential. If they have, then try some read-ahead, otherwise - * back-off on prospective read-aheads. + * if it is in the cache, then check to see if the next block is + * also. We initiate read-ahead when the next block is not availble + * to achieve some concurrency while still doing optimal io sizes. */ if (bp->b_flags & B_CACHE) { - if (!seqcount) { + if (!seqcount) return 0; - } else if ((bp->b_flags & B_RAM) == 0) { + lblkno++; + BO_LOCK(bo); + rbp = gbincore(&vp->v_bufobj, lblkno); + if (rbp != NULL && (rbp->b_flags & B_INVAL)) + rbp = NULL; + BO_UNLOCK(bo); + if (rbp != NULL) return 0; - } else { - bp->b_flags &= ~B_RAM; - BO_LOCK(bo); - for (i = 1; i < maxra; i++) { - /* - * Stop if the buffer does not exist or it - * is invalid (about to go away?) - */ - rbp = gbincore(&vp->v_bufobj, lblkno+i); - if (rbp == NULL || (rbp->b_flags & B_INVAL)) - break; - - /* - * Set another read-ahead mark so we know - * to check again. (If we can lock the - * buffer without waiting) - */ - if ((((i % racluster) == (racluster - 1)) || - (i == (maxra - 1))) - && (0 == BUF_LOCK(rbp, - LK_EXCLUSIVE | LK_NOWAIT, NULL))) { - rbp->b_flags |= B_RAM; - BUF_UNLOCK(rbp); - } - } - BO_UNLOCK(bo); - if (i >= maxra) { - return 0; - } - lblkno += i; - } reqbp = bp = NULL; /* * If it isn't in the cache, then get a chunk from @@ -211,7 +185,6 @@ cluster_read(vp, filesize, lblkno, size, blkno, size, nblks, bp); lblkno += (bp->b_bufsize / size); } else { - bp->b_flags |= B_RAM; bp->b_iocmd = BIO_READ; lblkno += 1; } @@ -265,7 +238,7 @@ cluster_read(vp, filesize, lblkno, size, bqrelse(rbp); continue; } - rbp->b_flags |= B_ASYNC | B_RAM; + rbp->b_flags |= B_ASYNC; rbp->b_iocmd = BIO_READ; rbp->b_blkno = blkno; } @@ -330,7 +303,7 @@ cluster_rbuild(vp, filesize, lbn, blkno, tbp = getblk(vp, lbn, size, 0, 0, 0); if (tbp->b_flags & B_CACHE) return tbp; - tbp->b_flags |= B_ASYNC | B_RAM; + tbp->b_flags |= B_ASYNC; tbp->b_iocmd = BIO_READ; } tbp->b_blkno = blkno; @@ -416,12 +389,6 @@ cluster_rbuild(vp, filesize, lbn, blkno, } /* - * Set a read-ahead mark as appropriate - */ - if ((fbp && (i == 1)) || (i == (run - 1))) - tbp->b_flags |= B_RAM; - - /* * Set the buffer up for an async read (XXX should * we do this only if we do not wind up brelse()ing?). * Set the block number if it isn't set, otherwise