[Ocfs2-commits] mfasheh commits r1572 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Oct 13 20:36:17 CDT 2004


Author: mfasheh
Date: 2004-10-13 20:36:15 -0500 (Wed, 13 Oct 2004)
New Revision: 1572

Modified:
   trunk/src/suballoc.c
Log:
* reorg the block group relinking code just a tad.



Modified: trunk/src/suballoc.c
===================================================================
--- trunk/src/suballoc.c	2004-10-14 01:35:29 UTC (rev 1571)
+++ trunk/src/suballoc.c	2004-10-14 01:36:15 UTC (rev 1572)
@@ -85,7 +85,8 @@
 				   struct buffer_head *bg_bh,
 				   struct buffer_head *prev_bg_bh,
 				   u16 chain);
-static inline int ocfs_block_group_reasonably_empty(ocfs2_group_desc *bg);
+static inline int ocfs_block_group_reasonably_empty(ocfs2_group_desc *bg,
+						    u32 wanted);
 static inline u64 ocfs_which_suballoc_group(u64 block, unsigned int bit);
 
 static int ocfs2_block_group_fill(ocfs_journal_handle *handle, 
@@ -711,9 +712,10 @@
 	return status;
 }
 
-static inline int ocfs_block_group_reasonably_empty(ocfs2_group_desc *bg)
+static inline int ocfs_block_group_reasonably_empty(ocfs2_group_desc *bg,
+						    u32 wanted)
 {
-	return bg->bg_free_bits_count >= (bg->bg_bits / 2);
+	return bg->bg_free_bits_count > wanted;
 }
 
 /* will give out up to bits_wanted contiguous bits. */
@@ -793,6 +795,19 @@
 		OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
 	}
 
+	status = ocfs_block_group_find_clear_bits(osb, 
+						  bg, 
+						  bits_wanted, 
+						  bit_off,
+						  &tmp_bits);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	*num_bits = tmp_bits;
+
+	OCFS_ASSERT(*num_bits);
+
 #define OCFS2_BG_RELINK_TRIGGER 1
 	/*
 	 * Keep track of previous block descriptor read. When
@@ -800,17 +815,16 @@
 	 * number of descriptors, and the target is reasonably
 	 * empty, relink him to top of his chain.
 	 *
-	 * prev_bg->bg_next_group = bg->bg_next_group;
-	 * bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
-	 * fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; 
-	 *
 	 * We've read 0 extra blocks and only send one more to
 	 * the transaction, yet the next guy to search has a
 	 * much easier time.
+	 *
+	 * Do this *after* figuring out how many bits we're taking out
+	 * of our target group.
 	 */
 	if ((prev_group_bh) 
 	    && (groups_read > OCFS2_BG_RELINK_TRIGGER) 
-	    && (ocfs_block_group_reasonably_empty(bg))) {
+	    && (ocfs_block_group_reasonably_empty(bg, *num_bits))) {
 		status = ocfs_relink_block_group(handle, alloc_inode,
 						 ac->ac_bh, group_bh, 
 						 prev_group_bh, chain);
@@ -820,21 +834,8 @@
 		}
 	}
 
-	status = ocfs_block_group_find_clear_bits(osb, 
-						  bg, 
-						  bits_wanted, 
-						  bit_off,
-						  &tmp_bits);
-	if (status < 0) {
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-	*num_bits = tmp_bits;
-
-	OCFS_ASSERT(*num_bits);
-
-	/* we found some. set the info on dinode, chainlist and then
-	 * the group */
+	/* Ok, claim our bits now: set the info on dinode, chainlist
+	 * and then the group */
 	status = ocfs_journal_access(handle, 
 				     alloc_inode,
 				     ac->ac_bh,



More information about the Ocfs2-commits mailing list