PERFORCE change 212957 for review
John Baldwin
jhb at FreeBSD.org
Sat Jun 16 16:14:17 UTC 2012
http://p4web.freebsd.org/@@212957?ac=10
Change 212957 by jhb at jhb_jhbbsd on 2012/06/16 16:13:23
WILLNEED experimenting:
- Add a variant of breada() that uses GB_LOCK_NOWAIT.
NOREUSE changes:
- Add counters to instrument what happens during DONTNEED requests.
Affected files ...
.. //depot/projects/fadvise/sys/kern/vfs_bio.c#7 edit
.. //depot/projects/fadvise/sys/sys/buf.h#4 edit
.. //depot/projects/fadvise/sys/ufs/ffs/ffs_vnops.c#10 edit
Differences ...
==== //depot/projects/fadvise/sys/kern/vfs_bio.c#7 (text+ko) ====
@@ -94,6 +94,8 @@
static struct proc *bufdaemonproc;
+static void breada_flags(struct vnode * vp, daddr_t * rablkno, int * rabsize,
+ int cnt, struct ucred * cred, int gbflags);
static int inmem(struct vnode *vp, daddr_t blkno);
static void vm_hold_free_pages(struct buf *bp, int newbsize);
static void vm_hold_load_pages(struct buf *bp, vm_offset_t from,
@@ -788,8 +790,8 @@
* the buffer is valid and we do not have to do anything.
*/
void
-breada(struct vnode * vp, daddr_t * rablkno, int * rabsize,
- int cnt, struct ucred * cred)
+breada_flags(struct vnode * vp, daddr_t * rablkno, int * rabsize,
+ int cnt, struct ucred * cred, int gbflags)
{
struct buf *rabp;
int i;
@@ -797,7 +799,7 @@
for (i = 0; i < cnt; i++, rablkno++, rabsize++) {
if (inmem(vp, *rablkno))
continue;
- rabp = getblk(vp, *rablkno, *rabsize, 0, 0, 0);
+ rabp = getblk(vp, *rablkno, *rabsize, 0, 0, gbflags);
if ((rabp->b_flags & B_CACHE) == 0) {
if (!TD_IS_IDLETHREAD(curthread))
@@ -818,6 +820,22 @@
}
}
+void
+breada(struct vnode * vp, daddr_t * rablkno, int * rabsize,
+ int cnt, struct ucred * cred)
+{
+
+ breada_flags(vp, rablkno, rabsize, cnt, cred, 0);
+}
+
+void
+breada_nowait(struct vnode * vp, daddr_t * rablkno, int * rabsize,
+ int cnt, struct ucred * cred)
+{
+
+ breada_flags(vp, rablkno, rabsize, cnt, cred, GB_LOCK_NOWAIT);
+}
+
/*
* Entry point for bread() and breadn() via #defines in sys/buf.h.
*
@@ -1212,6 +1230,36 @@
return vm_page_count_severe();
}
+static SYSCTL_NODE(_vfs, OID_AUTO, brelse, CTLFLAG_RD, NULL, "brelse stats");
+
+static int brelse_discard1;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, discard1, CTLFLAG_RD, &brelse_discard1, 0,
+ "");
+static int brelse_rundown1;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, rundown1, CTLFLAG_RD, &brelse_rundown1, 0,
+ "");
+static int brelse_rundown2;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, rundown2, CTLFLAG_RD, &brelse_rundown2, 0,
+ "");
+static int brelse_rundown3;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, rundown3, CTLFLAG_RD, &brelse_rundown3, 0,
+ "");
+static int brelse_inval;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, inval, CTLFLAG_RD, &brelse_inval, 0,
+ "");
+static int brelse_discard_nocache;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, discard_nocache, CTLFLAG_RD,
+ &brelse_discard_nocache, 0, "");
+static int brelse_discard_inval;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, discard_inval, CTLFLAG_RD,
+ &brelse_discard_inval, 0, "");
+static int brelse_discard_error;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, discard_error, CTLFLAG_RD,
+ &brelse_discard_error, 0, "");
+static int brelse_discard_badsize;
+SYSCTL_INT(_vfs_brelse, OID_AUTO, discard_badsize, CTLFLAG_RD,
+ &brelse_discard_badsize, 0, "");
+
/*
* brelse:
*
@@ -1248,6 +1296,15 @@
* Either a failed I/O or we were asked to free or not
* cache the buffer.
*/
+ brelse_discard1++;
+ if (bp->b_flags & B_NOCACHE)
+ brelse_discard_nocache++;
+ if (bp->b_flags & B_INVAL)
+ brelse_discard_inval++;
+ if (bp->b_ioflags & BIO_ERROR)
+ brelse_discard_error++;
+ if (bp->b_bufsize <= 0)
+ brelse_discard_badsize++;
bp->b_flags |= B_INVAL;
if (!LIST_EMPTY(&bp->b_dep))
buf_deallocate(bp);
@@ -1387,16 +1444,18 @@
foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK;
}
VM_OBJECT_UNLOCK(obj);
+ brelse_rundown1++;
if (bp->b_flags & (B_INVAL | B_RELBUF))
vfs_vmio_release(bp);
} else if (bp->b_flags & B_VMIO) {
-
+ brelse_rundown2++;
if (bp->b_flags & (B_INVAL | B_RELBUF)) {
vfs_vmio_release(bp);
}
} else if ((bp->b_flags & (B_INVAL | B_RELBUF)) != 0) {
+ brelse_rundown3++;
if (bp->b_bufsize != 0)
allocbuf(bp, 0);
if (bp->b_vp != NULL)
@@ -1434,6 +1493,8 @@
(bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF)) != 0)
bp->b_flags |= B_INVAL;
if (bp->b_flags & B_INVAL) {
+ if (bp->b_bufsize != 0)
+ brelse_inval++;
if (bp->b_flags & B_DELWRI)
bundirty(bp);
if (bp->b_vp)
==== //depot/projects/fadvise/sys/sys/buf.h#4 (text+ko) ====
@@ -490,6 +490,7 @@
int breadn_flags(struct vnode *, daddr_t, int, daddr_t *, int *, int,
struct ucred *, int, struct buf **);
void breada(struct vnode *, daddr_t *, int *, int, struct ucred *);
+void breada_nowait(struct vnode *, daddr_t *, int *, int, struct ucred *);
void bdwrite(struct buf *);
void bawrite(struct buf *);
void bdirty(struct buf *);
==== //depot/projects/fadvise/sys/ufs/ffs/ffs_vnops.c#10 (text+ko) ====
@@ -530,7 +530,7 @@
xfersize = fs->fs_bsize - blkoffset;
if (resid < xfersize)
xfersize = resid;
- breada(vp, &lbn, &xfersize, 1, NOCRED);
+ breada_nowait(vp, &lbn, &xfersize, 1, NOCRED);
}
resid -= xfersize;
start += xfersize;
More information about the p4-projects
mailing list