Subject: brelse() nonsense
To: None <tech-kern@netbsd.org>
From: Pedro Martelletto <pedro@ambientworks.net>
List: tech-kern
Date: 06/13/2005 15:26:54
Hi,

Currently, in brelse(), when disassociating a buffer from a vnode,
the B_DELWRI flag is first removed, then reassignbuf() is called
followed by brelvp().

reassignbuf() first removes the buffer from the vnode's clean or dirty
list, then checks for the B_DELWRI flag, which is absent, and inserts
the buffer in the vnode's clean list. It also checks if the vnode is on
the sync list with no dirty buffers, in which case it is removed.

When brelvp() is called, the buffer is removed from the vnode's clean
list, and the 'on sync list with no dirty buffers' check is performed
again.

I don't think the call to reassignbuf() is necessary, and since it's in
code protected by IPL_BIO, it might be slowing things down a bit.

Here's a diff. Untested.

-p.

Index: vfs_bio.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_bio.c,v
retrieving revision 1.146
diff -u -r1.146 vfs_bio.c
--- vfs_bio.c	9 Jun 2005 02:19:59 -0000	1.146
+++ vfs_bio.c	13 Jun 2005 17:21:21 -0000
@@ -944,10 +944,8 @@
 		if (LIST_FIRST(&bp->b_dep) != NULL && bioops.io_deallocate)
 			(*bioops.io_deallocate)(bp);
 		CLR(bp->b_flags, B_DONE|B_DELWRI);
-		if (bp->b_vp) {
-			reassignbuf(bp, bp->b_vp);
+		if (bp->b_vp)
 			brelvp(bp);
-		}
 		if (bp->b_bufsize <= 0)
 			/* no data */
 			goto already_queued;