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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Oct 14 15:37:45 CDT 2004


Author: mfasheh
Date: 2004-10-14 15:37:43 -0500 (Thu, 14 Oct 2004)
New Revision: 1577

Modified:
   trunk/src/file.c
   trunk/src/inode.c
   trunk/src/namei.c
   trunk/src/ocfs_journal.h
Log:
* tighten up our journal credits calculations.



Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-10-14 18:33:55 UTC (rev 1576)
+++ trunk/src/file.c	2004-10-14 20:37:43 UTC (rev 1577)
@@ -441,7 +441,7 @@
 			     inode);
 
 	/* Start a transaction - need a minimal amount of block credits (1) */
-	handle = ocfs_start_trans(osb, handle, 1);
+	handle = ocfs_start_trans(osb, handle, OCFS_INODE_UPDATE_CREDITS);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS(status);
 		goto leave;
@@ -860,7 +860,7 @@
 	/* TODO: This needs to actually orphen the inode in this
 	 * transaction. */
 
-	handle = ocfs_start_trans(osb, handle, 1);
+	handle = ocfs_start_trans(osb, handle, OCFS_INODE_UPDATE_CREDITS);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto bail;
@@ -939,7 +939,8 @@
 			       "truncate\n", fe->i_clusters);
 		/* No allocation change is required, so lets fast path
 		 * this truncate. */	
-		handle = ocfs_start_trans(osb, handle, 1);
+		handle = ocfs_start_trans(osb, handle, 
+					  OCFS_INODE_UPDATE_CREDITS);
 		if (handle == NULL) {
 			LOG_ERROR_STATUS (status = -ENOMEM);
 			goto bail;

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-10-14 18:33:55 UTC (rev 1576)
+++ trunk/src/inode.c	2004-10-14 20:37:43 UTC (rev 1577)
@@ -547,7 +547,7 @@
 	if (!fe->i_clusters)
 		goto bail;
 
-	handle = ocfs_start_trans(osb, handle, 1);
+	handle = ocfs_start_trans(osb, handle, OCFS_INODE_UPDATE_CREDITS);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto bail;
@@ -721,7 +721,7 @@
 	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
 			     inode_alloc_inode);
 
-	handle = ocfs_start_trans(osb, handle, OCFS_FILE_DELETE_CREDITS);
+	handle = ocfs_start_trans(osb, handle, OCFS_DELETE_INODE_CREDITS);
 	if (handle == NULL) {
 		status = -ENOMEM;
 		LOG_ERROR_STATUS(status);

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-10-14 18:33:55 UTC (rev 1576)
+++ trunk/src/namei.c	2004-10-14 20:37:43 UTC (rev 1577)
@@ -691,8 +691,7 @@
 		goto bail;
 	}
 
-	/* mknod credits is a bit heavy, but we can tune this later. */
-	handle = ocfs_start_trans(osb, handle, OCFS_MKNOD_CREDITS);
+	handle = ocfs_start_trans(osb, handle, OCFS_LINK_CREDITS);
 	if (handle == NULL) {
 		err = -ENOMEM;
 		goto bail;
@@ -840,7 +839,7 @@
 		}
 	}
 
-	handle = ocfs_start_trans(osb, handle, OCFS_FILE_DELETE_CREDITS);
+	handle = ocfs_start_trans(osb, handle, OCFS_UNLINK_CREDITS);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto leave;
@@ -1236,7 +1235,7 @@
 		}
 	}
 
-	handle = ocfs_start_trans(osb, handle, OCFS_FILE_RENAME_CREDITS);
+	handle = ocfs_start_trans(osb, handle, OCFS_RENAME_CREDITS);
 	if (handle == NULL) {
 		LOG_ERROR_STATUS(status = -ENOMEM);
 		goto bail;

Modified: trunk/src/ocfs_journal.h
===================================================================
--- trunk/src/ocfs_journal.h	2004-10-14 18:33:55 UTC (rev 1576)
+++ trunk/src/ocfs_journal.h	2004-10-14 20:37:43 UTC (rev 1577)
@@ -309,25 +309,50 @@
  *
  *  For convenience sake, I have a set of macros here which calculate
  *  the *maximum* number of sectors which will be changed for various
- *  metadata updates. I also have a completely arbitrary 'fuzz' value
- *  which I'll add to some of these in case of a miscalculation.
+ *  metadata updates.
  */
-#define OCFS_JOURNAL_FUZZ_CREDITS (5)
 
+/* simple file updates like chmod, etc. */
+#define OCFS_INODE_UPDATE_CREDITS 1
+
+/* get one bit out of a suballocator: dinode + group descriptor +
+ * prev. group desc. if we relink. */
+#define OCFS_SUBALLOC_ALLOC (3)
+
 /* 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)
+#define OCFS_MKNOD_CREDITS (3 + OCFS_SUBALLOC_ALLOC                           \
+			    + OCFS_DIR_LINK_ADDITIONAL_CREDITS)
 
 /* local alloc metadata change + main bitmap updates */
-#define OCFS_WINDOW_MOVE_CREDITS (1 + 8 + OCFS_JOURNAL_FUZZ_CREDITS)
+#define OCFS_WINDOW_MOVE_CREDITS (OCFS_INODE_UPDATE_CREDITS + 8 + 5)
 
 /* used when we don't need an allocation change for a dir extend. One
- for the dinode, one for the new block. */
+ * for the dinode, one for the new block. */
 #define OCFS_SIMPLE_DIR_EXTEND_CREDITS (2)
 
+/* file update (nlink, etc) + dir entry block */
+#define OCFS_LINK_CREDITS  (OCFS_INODE_UPDATE_CREDITS + 1)
+
+/* inode + dir inode (if we unlink a dir), + dir entry block + orphan
+ * dir inode link */
+#define OCFS_UNLINK_CREDITS  (2 * OCFS_INODE_UPDATE_CREDITS + 1               \
+			      + OCFS_LINK_CREDITS)
+
+/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry +
+ * inode alloc group descriptor */
+#define OCFS_DELETE_INODE_CREDITS (3 * OCFS_INODE_UPDATE_CREDITS + 1 + 1)
+
+/* dinode update, old dir dinode update, new dir dinode update, old
+ * dir dir entry, new dir dir entry, dir entry update for renaming
+ * directory + target unlink */
+#define OCFS_RENAME_CREDITS (3 * OCFS_INODE_UPDATE_CREDITS + 3                \
+			     + OCFS_UNLINK_CREDITS)
+
 static inline int ocfs_calc_extend_credits(struct super_block *sb,
 					   ocfs2_dinode *fe,
 					   u32 bits_wanted)
@@ -342,7 +367,7 @@
 	 * 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);
+	sysfile_bitmap_blocks = 1 + 3 * ocfs2_extend_meta_needed(fe);
 
 	/* this does not include *new* metadata blocks, which are
 	 * accounted for in sysfile_bitmap_blocks. fe +
@@ -372,7 +397,7 @@
 	int bitmap_blocks = ocfs_blocks_for_bits(sb, cpg) + 1;
 	/* parent inode update + new block group header + bitmap inode update 
 	   + bitmap blocks affected */
-	blocks = 1 + 1 + 1 + bitmap_blocks + OCFS_JOURNAL_FUZZ_CREDITS;
+	blocks = 1 + 1 + 1 + bitmap_blocks;
 	return(blocks);
 }
 
@@ -403,13 +428,4 @@
 	return(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)
-
-/* fe change, locknode change, dirnode head, times two plus a possible
- * delete, plus a possible dirnode addition in insert_file, and fuzz */
-#define OCFS_FILE_RENAME_CREDITS  (2 * (1 + 1 + 1) + OCFS_FILE_DELETE_CREDITS \
-				   + OCFS_JOURNAL_FUZZ_CREDITS)
-
 #endif /* _OCFSJOURNAL_H_ */



More information about the Ocfs2-commits mailing list