[Ocfs2-commits] mfasheh commits r1515 - branches/dlm-changes/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Sep 29 19:05:38 CDT 2004


Author: mfasheh
Date: 2004-09-29 19:05:36 -0500 (Wed, 29 Sep 2004)
New Revision: 1515

Modified:
   branches/dlm-changes/src/bitmap.c
   branches/dlm-changes/src/bitmap.h
Log:
* fix the best try code in ocfs_find_clear_bits

* remove the unused 'offset' parameter

* get rid of StuDLy CaPS



Modified: branches/dlm-changes/src/bitmap.c
===================================================================
--- branches/dlm-changes/src/bitmap.c	2004-09-30 00:02:24 UTC (rev 1514)
+++ branches/dlm-changes/src/bitmap.c	2004-09-30 00:05:36 UTC (rev 1515)
@@ -170,10 +170,10 @@
  *
  * if you pass in best_fit_bits we return -ENOSPC only if we're
  * completely full, otherwise we'll always set best_fit_bits to at max
- * numBits, and of course *bitoff to your starting offset.
+ * bits_wanted, and of course *bitoff to your starting offset.
  */
 int ocfs_find_clear_bits(ocfs_super *osb, ocfs_alloc_bm * bitmap,
-			 u32 numBits, u32 offset, u32 *bitoff,
+			 u32 bits_wanted, u32 *bitoff,
 			 u32 *best_fit_bits)
 {
 	int status = 0;
@@ -185,13 +185,12 @@
 	int c;
 	struct buffer_head *currbh = NULL;
 
-	LOG_ENTRY_ARGS ("(0x%p, 0x%p, %u, %u)\n", osb, bitmap, numBits,
-			offset);
+	LOG_ENTRY_ARGS ("(0x%p, 0x%p, %u)\n", osb, bitmap, bits_wanted);
 
 	/* We keep track of the biggest contiguous chunk we've seen so
 	 * far in these two variables. If we never completely fulfull
 	 * the request, we can pass them back for a best try. */
-	largest_start = offset;
+	largest_start = 0;
 	largest_size = 0;
 
 	if (best_fit_bits)
@@ -201,7 +200,7 @@
 	globalsize = bitmap->validbits;
 	lastbh = ocfs_blocks_for_bits(osb->sb, globalsize) - 1;
 
-	globaloff = offset;
+	globaloff = 0;
 	ocfs_bitmap_block_for_off(osb->sb, globaloff, &c, &localstart);
 
 	if (lastbh == 0)
@@ -271,10 +270,6 @@
 			count++;
 			localstart++;
 			globaloff++;
-			if (count > largest_size) {
-				largest_size = count;
-				largest_start = globaloff - count;
-			}
 		} else {
 			/*LOG_TRACE_ARGS("*bitoff (%u) != localstart (%u)\n", 
 			  *bitoff, localstart);*/
@@ -286,7 +281,12 @@
 			localstart = *bitoff + 1;
 		}
 
-		if (count == numBits) {
+		if (count > largest_size) {
+			largest_size = count;
+			largest_start = globaloff - count;
+		}
+
+		if (count == bits_wanted) {
 			/* we've found everything we wanted. */
 			LOG_TRACE_ARGS("Found it all! (count=%u)\n", count);
 			buffer = NULL;
@@ -294,10 +294,10 @@
 		}
 	}
 
-	if (count == numBits) {
+	if (count == bits_wanted) {
 		*bitoff = globaloff - count;
 		if (best_fit_bits)
-			*best_fit_bits = numBits;
+			*best_fit_bits = bits_wanted;
 	} else if (best_fit_bits && largest_size) {
 #warning "can we go off the end of the bitmap here?"
 			*best_fit_bits = largest_size;

Modified: branches/dlm-changes/src/bitmap.h
===================================================================
--- branches/dlm-changes/src/bitmap.h	2004-09-30 00:02:24 UTC (rev 1514)
+++ branches/dlm-changes/src/bitmap.h	2004-09-30 00:05:36 UTC (rev 1515)
@@ -34,8 +34,7 @@
 		     ocfs_journal_handle *handle, ocfs_alloc_bm *bitmap,
 		     __u32 start, __u32 num);
 int ocfs_find_clear_bits(ocfs_super *osb, ocfs_alloc_bm * bitmap,
-			 u32 numBits, u32 offset, u32 *bitoff,
-			 u32 *best_fit_bits);
+			 u32 numBits, u32 *bitoff, u32 *best_fit_bits);
 void ocfs_initialize_bitmap(struct super_block *sb,
 			    ocfs_alloc_bm *bitmap, __u32 validbits,
 			    __u32 allocbits);



More information about the Ocfs2-commits mailing list