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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Oct 12 16:28:36 CDT 2004


Author: mfasheh
Date: 2004-10-12 16:28:34 -0500 (Tue, 12 Oct 2004)
New Revision: 1564

Modified:
   trunk/src/dir.c
   trunk/src/file.c
   trunk/src/ocfs_journal.h
   trunk/src/suballoc.c
Log:
* tighten up some of our journal credits and bitmap reservation
  calculations.



Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c	2004-10-12 02:01:09 UTC (rev 1563)
+++ trunk/src/dir.c	2004-10-12 21:28:34 UTC (rev 1564)
@@ -451,11 +451,10 @@
 			goto bail;
 		}
 
-		credits = ocfs_calc_extend_credits(sb, 1);
+		credits = ocfs_calc_extend_credits(sb, fe, 1);
 	} else {
 		up(&OCFS_I(dir)->ip_sem);
-		/* one for the dinode, one for the new block. */
-		credits = 2;
+		credits = OCFS_SIMPLE_DIR_EXTEND_CREDITS;
 	}
 
 	handle = ocfs_start_trans(osb, handle, credits);

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-10-12 02:01:09 UTC (rev 1563)
+++ trunk/src/file.c	2004-10-12 21:28:34 UTC (rev 1564)
@@ -1045,15 +1045,13 @@
 			   enum ocfs2_alloc_restarted *reason)
 {
 	int status = 0;
-	int credits_needed, free_extents, multi_pass;
+	int free_extents;
 	ocfs2_dinode *fe = (ocfs2_dinode *) fe_bh->b_data;
 	u32 bit_off, num_bits;
 	u64 block;
 
 	OCFS_ASSERT(clusters_to_add);
 
-	multi_pass = 0;
-again:
 	free_extents = ocfs_num_free_extents(osb, inode, fe);
 	if (free_extents < 0) {
 		status = free_extents;
@@ -1082,32 +1080,6 @@
 		goto leave;
 	}
 
-	/* do we have enough credits for another single extend, of
-	 * what's left? */
-	/* fe + main bitmap fe + main bitmap bits */
-	if (!multi_pass)
-		credits_needed = 1 + 1 + 
-			ocfs_blocks_for_bits(osb->sb, clusters_to_add);
-	else /* if we've already extended once, then we've already reserved. */
-		credits_needed = ocfs_blocks_for_bits(osb->sb, clusters_to_add);
-	if (!free_extents) {
-		/* will need to extend the file: 
-		 * metadata suballoc fe + metadata suballoc bitmap 
-		 * + actual metadata blocks. */
-		credits_needed += 1 + 1 + ocfs2_extend_meta_needed(fe);
-	}
-	multi_pass = 1;
-
-	if (credits_needed > (handle->max_buffs - handle->num_buffs)) {
-		LOG_TRACE_ARGS("Not enough credits for this extend: need %u, "
-			       "have %u\n", credits_needed, 
-			       (handle->max_buffs - handle->num_buffs));
-		status = -EAGAIN;
-		if (reason)
-			*reason = RESTART_TRANS;
-		goto leave;
-	}
-
 	status = ocfs_claim_bits(osb, handle, data_ac, 1, &bit_off, &num_bits);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
@@ -1151,7 +1123,9 @@
 		LOG_TRACE_ARGS("need to alloc once more, clusters = %u, "
 			       "wanted = %u\n", fe->i_clusters, 
 			       clusters_to_add);
-		goto again;
+		status = -EAGAIN;
+		if (reason)
+			*reason = RESTART_TRANS;
 	}
 
 leave:
@@ -1280,7 +1254,7 @@
 	}
 
 do_start_trans:
-	credits = ocfs_calc_extend_credits(osb->sb, clusters_to_add);
+	credits = ocfs_calc_extend_credits(osb->sb, fe, clusters_to_add);
 	handle = ocfs_start_trans(osb, handle, credits);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS(status = -ENOMEM);
@@ -1341,6 +1315,7 @@
 			LOG_TRACE_ARGS("restarting transaction.\n");
 			/* TODO: This can be more intelligent. */
 			credits = ocfs_calc_extend_credits(osb->sb, 
+							   fe,
 							   clusters_to_add);
 			status = ocfs_extend_trans(handle, credits);
 			if (status < 0) {

Modified: trunk/src/ocfs_journal.h
===================================================================
--- trunk/src/ocfs_journal.h	2004-10-12 02:01:09 UTC (rev 1563)
+++ trunk/src/ocfs_journal.h	2004-10-12 21:28:34 UTC (rev 1564)
@@ -371,62 +371,53 @@
  *  that I'm not worried about the 'fuzz' taking up potential credits.
  */
 #define OCFS_JOURNAL_FUZZ_CREDITS (5)
-#define OCFS_SINGLE_FILE_EXTEND_CREDITS (10)
 
-/* locknode + new fe + dirnode head + new dirnode for parent directory
- * + extending (diralloc, filealloc, dirallocbitmap, fileallocbitmap)
- * + a second dirnode for handling mkdir + 2 * 2 = 4 blocks for
- * setting the bits in the dir alloc bitmap and the metadata alloc
- * bitmap if dir alloc needs to be extended + some fuzz. */
-#define OCFS_MKNOD_CREDITS (1 + 1 + 	      \
-			    (OCFS_SINGLE_FILE_EXTEND_CREDITS * 4) +	      \
-			    OCFS_JOURNAL_FUZZ_CREDITS)
+/* data block for new dir/symlink, 2 for bitmap updates (bitmap fe +
+ * bitmap block for the new bit) */
+#define OCFS_DIR_LINK_ADDITIONAL_CREDITS (1 + 2)
+/* parent fe, parent block, new file entry, inode alloc fe, inode alloc
+ * group descriptor + mkdir/symlink blocks */
+#define OCFS_MKNOD_CREDITS (5 + OCFS_DIR_LINK_ADDITIONAL_CREDITS)
 
 /* local alloc metadata change + main bitmap updates */
 #define OCFS_WINDOW_MOVE_CREDITS (1 + 8 + OCFS_JOURNAL_FUZZ_CREDITS)
 
-/* single file metadata updates * 3 because we might have to extend
- * the file alloc and file alloc bitmap files + possible update to
- * local bitmap. + 2 blocks for bits to set in the metadata alloc
- * bitmap file + 8 blocks for local alloc shift(s) */
-#define OCFS_FILE_EXTEND_CREDITS (OCFS_SINGLE_FILE_EXTEND_CREDITS * 3         \
-				  + 1 + 2 + 8 + OCFS_JOURNAL_FUZZ_CREDITS)
+/* used when we don't need an allocation change for a dir extend. One
+ for the dinode, one for the new block. */
+#define OCFS_SIMPLE_DIR_EXTEND_CREDITS (2)
 
-/* Now that we journal bitmap writes, this might get a bit more
- * complicated, use this function to determine how many credits are
- * needed for an extend. Unfortunately, we're in bytes because the
- * rest of the file system is. 
- */
 static inline int ocfs_calc_extend_credits(struct super_block *sb,
-					   __u32 bits_wanted)
+					   ocfs2_dinode *fe,
+					   u32 bits_wanted)
 {
-	int bitmap_blocks, sysfile_bitmap_blocks;
+	int bitmap_blocks, sysfile_bitmap_blocks, dinode_blocks;
 	/* take advantage of the fact that we always allocate in one 
 	 * large chunk. */
 	bitmap_blocks = ocfs_blocks_for_bits(sb, bits_wanted) + 1;
 
-	/* need to account for any bitmap system file extension.
-	 * system files extend by up to 2mb, so the corresponding bitmap
-	 * file (which are all blocksize allocators today) will require
-	 * enough credits to zero the new bitmap data for that 2mb.
-	 * even on a 512byte sect size, this is only 512 bytes of bitmap
-	 * data, so it's really never more than two extra blocks.  add
-	 * some extra in case the request spans the new blocks + old ones. */
-	
-	/* NOTE: if we ever add an allocator that allocates something
-	 * other than blocksize chunks, or expect requests to be lots of 
-	 * bits at a time, this assumption doesn't hold */
-	sysfile_bitmap_blocks = 4;
-	
-	return (bitmap_blocks + sysfile_bitmap_blocks + OCFS_FILE_EXTEND_CREDITS);
+	/* we might need to shift granularity so lets assume an
+	 * absolute worst case of complete fragmentation so for each
+	 * new metadata block we have a descriptor and the actual
+	 * block and of course 1 credit for the metadata dinode
+	 * update. */
+	sysfile_bitmap_blocks = 1 + 2 * ocfs2_extend_meta_needed(fe);
+
+	/* this does not include *new* metadata blocks, which are
+	 * accounted for in sysfile_bitmap_blocks. fe +
+	 * prev. last_eb_blk + blocks along edge of tree. 
+	 * calc_symlink_credits passes because we just need 1 
+	 * credit for the dinode there. */
+	dinode_blocks = 1 + 1 + fe->id2.i_list.l_tree_depth;
+
+	return (bitmap_blocks + sysfile_bitmap_blocks + dinode_blocks);
 }
 
 static inline int ocfs_calc_symlink_credits(struct super_block *sb)
 {
-	/* get our fuzz from mknod and extend credits. */
-	int blocks = OCFS_MKNOD_CREDITS + 1;
-	
-	blocks += ocfs_calc_extend_credits(sb, 1);
+	int blocks = OCFS_MKNOD_CREDITS;
+
+	/* links can be longer than one block so we may update many
+	 * within our single allocated extent. */
 	blocks += ocfs2_clusters_to_blocks(sb, 1);
 
 	return(blocks);
@@ -470,9 +461,6 @@
 	return(credits);
 }
 
-/* fe, anything along new 'edge' of tree + fuzz*/
-#define OCFS_FILE_TRUNCATE_CREDITS (1 + 14 + OCFS_JOURNAL_FUZZ_CREDITS)
-
 /* the file entry + the locknode + possibily the parent dirnode + fuzz */
 /* ok, these credits are messed up and need to be re calculated. */
 #define OCFS_FILE_DELETE_CREDITS  (2 + 1 + 1 + 1 + OCFS_JOURNAL_FUZZ_CREDITS)
@@ -482,8 +470,4 @@
 #define OCFS_FILE_RENAME_CREDITS  (2 * (1 + 1 + 1) + OCFS_FILE_DELETE_CREDITS \
 				   + OCFS_JOURNAL_FUZZ_CREDITS)
 
-/* On very rare open operations (it's a first open and we're not in
- * the open map), we have to change the file entry. */
-#define OCFS_OPEN_CREDITS 1
-
 #endif /* _OCFSJOURNAL_H_ */

Modified: trunk/src/suballoc.c
===================================================================
--- trunk/src/suballoc.c	2004-10-12 02:01:09 UTC (rev 1563)
+++ trunk/src/suballoc.c	2004-10-12 21:28:34 UTC (rev 1564)
@@ -425,9 +425,7 @@
 		goto bail;
 	}
 	memset(*ac, 0, sizeof(ocfs2_alloc_context));
-	/* Our file data alloc path is such a mess that I really feel
-	 * comfortable just always over-reserving here. */
-	(*ac)->ac_bits_wanted = 2 * ocfs2_extend_meta_needed(fe);
+	(*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
 	(*ac)->ac_handle = handle;
 	(*ac)->ac_which = OCFS_AC_USE_META;
 



More information about the Ocfs2-commits mailing list