PERFORCE change 143941 for review

Nick Barkas snb at FreeBSD.org
Mon Jun 23 01:12:39 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=143941

Change 143941 by snb at snb_toro on 2008/06/23 01:12:33

	Return number of bytes freed by ufsdirhash_destroy() rather than 0 upon
	       success. Also increment a counter vfs.ufs.dirhash_lowmemcount rather
	       than printing a message when ufsdirhash_lowmem() is called. 

Affected files ...

.. //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#4 edit

Differences ...

==== //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#4 (text+ko) ====

@@ -81,6 +81,9 @@
 static int ufs_dirhashcheck = 0;
 SYSCTL_INT(_vfs_ufs, OID_AUTO, dirhash_docheck, CTLFLAG_RW, &ufs_dirhashcheck,
     0, "enable extra sanity tests");
+static int ufs_dirhashlowmemcount = 0;
+SYSCTL_INT(_vfs_ufs, OID_AUTO, dirhash_lowmemcount, CTLFLAG_RD, 
+    &ufs_dirhashlowmemcount, 0, "number of times low memory hook called");
 
 
 static int ufsdirhash_hash(struct dirhash *dh, char *name, int namelen);
@@ -1082,7 +1085,8 @@
  * Assumes that ufsdirhash_list is locked, and leaves it locked. 
  * If unable to obtain a lock on the first dirhash, moves down 
  * the list until it can lock a dirhash and destroys it. Returns 
- * -1 if unable to find any dirhashes that can be destroyed.
+ * the amount of memory freed, or -1 if unable to find any 
+ * dirhashes that can be destroyed.
  */
 static int
 ufsdirhash_destroy()
@@ -1130,7 +1134,7 @@
 	DIRHASHLIST_LOCK();
 	ufs_dirhashmem -= mem;	
 
-	return (0);
+	return (mem);
 }
 
 /*
@@ -1168,15 +1172,15 @@
 static void
 ufsdirhash_lowmem()
 {
-	/* XXX: temporary silly way of notifying when this is called */
-	printf("dirhash: ufsdirhash_lowmem() called\n");
+	ufs_dirhashlowmemcount++;
 
 	DIRHASHLIST_LOCK();
-	/* 
-	 * Try deleting only one dirhash for now, and don't bother  
-	 * to check if it worked.
-	 */
-	ufsdirhash_destroy();
+	if (ufs_dirhashmem > 0)
+		/* 
+		 * Try deleting only one dirhash for now, and don't bother  
+		 * to check if it worked.
+		 */
+		ufsdirhash_destroy();
 	DIRHASHLIST_UNLOCK();
 }
 


More information about the p4-projects mailing list