Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Sep 1997 20:51:50 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        current@freebsd.org
Subject:   Minor patch to vfs_op_init() behaviour
Message-ID:  <199709092051.NAA09777@usr06.primenet.com>

next in thread | raw e-mail | index | archive | help
Here are some minor VFS initialization patches.

These patches remove the ** array sizing problem for *vfs_op_descs[].

They also move the initialization of the vfs_opv_numops to an agregate
value dependent on the vnode_if.src instead of on a traversal of the
vfs_op_descs[] array (that's how it was done).

They correct a misleading comment about how dynamic the adding of VOPS
actually is.  Armed with this information, someone will be more likely
to fix it some day now...

They pave the way in kern/vfs_init.c:vfs_op_init() for removing the
extra function call overhead associatied with each VOP call (yes, I
know it's inlined, but the assignments of arguments to structure
elements for an auto variable structure can go away in the near
future.  This overhead occurs for each and every VOP_ call).  This
intent is also commented.

Hopefully *this* change is small enough for people to wrap their
heads around, and it will make it in...

Context diff follows signature.

					Regards,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-------------------------------------------------------------------------------
Index: kern/vfs_init.c
===================================================================
RCS file: /b/cvstree/ncvs/src/sys/kern/vfs_init.c,v
retrieving revision 1.26
diff -c -r1.26 vfs_init.c
*** 1.26	1997/08/02 14:31:44
--- vfs_init.c	1997/09/09 20:40:47
***************
*** 70,82 ****
  
  extern struct vnodeop_desc *vfs_op_descs[];
  				/* and the operations they perform */
- /*
-  * This code doesn't work if the defn is **vnodop_defns with cc.
-  * The problem is because of the compiler sometimes putting in an
-  * extra level of indirection for arrays.  It's an interesting
-  * "feature" of C.
-  */
- static int vfs_opv_numops;
  
  /*
   * A miscellaneous routine.
--- 70,75 ----
***************
*** 104,109 ****
--- 97,108 ----
   * listing those new operations Ficus adds to NFS, all without modifying the
   * NFS code. (Of couse, the OTW NFS protocol still needs to be munged, but
   * that is a(whole)nother story.) This is a feature.
+  *
+  * Without an explicit reserve area, however, you must replace vnode_if.c
+  * and vnode_if.h when you do this, or you will be derefrencing of the
+  * end of vfs_op_descs[].  This is a flaw in the use of a structure
+  * pointer array rather than an agregate to define vfs_op_descs.  So
+  * it's not a very dynamic "feature".
   */
  void
  vfs_opv_init(struct vnodeopv_desc **them)
***************
*** 197,216 ****
  	int i;
  
  	DODEBUG(printf("Vnode_interface_init.\n"));
  	/*
  	 * Set all vnode vectors to a well known value.
  	 */
  	for (i = 0; vfs_opv_descs[i]; i++)
  		*(vfs_opv_descs[i]->opv_desc_vector_p) = NULL;
  	/*
! 	 * Figure out how many ops there are by counting the table,
! 	 * and assign each its offset.
  	 */
! 	for (vfs_opv_numops = 0, i = 0; vfs_op_descs[i]; i++) {
! 		vfs_op_descs[i]->vdesc_offset = vfs_opv_numops;
! 		vfs_opv_numops++;
! 	}
! 	DODEBUG(printf ("vfs_opv_numops=%d\n", vfs_opv_numops));
  }
  
  /*
--- 196,219 ----
  	int i;
  
  	DODEBUG(printf("Vnode_interface_init.\n"));
+ 	DODEBUG(printf ("vfs_opv_numops=%d\n", vfs_opv_numops));
  	/*
  	 * Set all vnode vectors to a well known value.
  	 */
  	for (i = 0; vfs_opv_descs[i]; i++)
  		*(vfs_opv_descs[i]->opv_desc_vector_p) = NULL;
  	/*
! 	 * assign each op to its offset
! 	 *
! 	 * XXX This should not be needed, but is because the per
! 	 * XXX FS ops tables are not sorted according to the
! 	 * XXX vnodeop_desc's offset in vfs_op_descs.  This
! 	 * XXX is the same reason we have to take the hit for
! 	 * XXX the static inline function calls instead of using
! 	 * XXX simple macro references.
  	 */
! 	for (i = 0; i < vfs_opv_numops; i++)
! 		vfs_op_descs[i]->vdesc_offset = i;
  }
  
  /*
Index: kern/vnode_if.sh
===================================================================
RCS file: /b/cvstree/ncvs/src/sys/kern/vnode_if.sh,v
retrieving revision 1.11
diff -c -r1.11 vnode_if.sh
*** 1.11	1997/02/22 09:39:36
--- vnode_if.sh	1997/09/09 19:32:47
***************
*** 397,402 ****
--- 397,404 ----
  	a.a_bp = bp;
  	return (VCALL((bp)->b_vp, VOFFSET(vop_bwrite), &a));
  }
+ 
+ extern int vfs_opv_numops;
  END_OF_SPECIAL_CASES
  
  cat << END_OF_SPECIAL_CASES >> $CFILE
***************
*** 457,459 ****
--- 459,469 ----
  		}
  	}' < $SRC >> $CFILE
  
+ cat << END_OF_NUMOPS_CODE >> $CFILE
+ 
+ /*
+  * the -1 is to account for the NULL
+  * XXX is the NULL still necessary?  I don't think so...
+  */
+ int vfs_opv_numops = (sizeof(vfs_op_descs)/sizeof(struct vnodeop_desc *)) - 1;
+ END_OF_NUMOPS_CODE
-------------------------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709092051.NAA09777>