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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Sep 30 19:54:13 CDT 2004


Author: mfasheh
Date: 2004-09-30 19:54:11 -0500 (Thu, 30 Sep 2004)
New Revision: 1528

Modified:
   branches/dlm-changes/src/journal.c
Log:
* ocfs_journal_dirty was accounting for buffers during roll-forward
  transactions. This is bad as we don't want to keep them around, and
  therefore it was thinking it was running out of credits.

* a JBD error in ocfs_journal_dirty wasn't being handled correctly.

* reorg ocfs_extend_trans a bit



Modified: branches/dlm-changes/src/journal.c
===================================================================
--- branches/dlm-changes/src/journal.c	2004-09-30 23:11:30 UTC (rev 1527)
+++ branches/dlm-changes/src/journal.c	2004-10-01 00:54:11 UTC (rev 1528)
@@ -790,8 +790,10 @@
 	return;
 } /* ocfs_abort_trans */
 
-/* will either extend the current handle by nblocks, or commit it and
- * start a new one with nblocks credits. 
+/* 
+ * 'nblocks' is what you want to add to the current
+ * transaction. extend_trans will either extend the current handle by
+ * nblocks, or commit it and start a new one with nblocks credits.
  *
  * WARNING: This will not release any semaphores or disk locks taken
  * during the transaction, so make sure they were taken *before*
@@ -813,7 +815,7 @@
 
 	LOG_ENTRY();
 
-	printk("Trying to extend by %d blocks\n", nblocks);
+	printk("Trying to extend transaction by %d blocks\n", nblocks);
 
 	status = journal_extend(handle->k_handle, nblocks);
 	if (status < 0) {
@@ -822,6 +824,7 @@
 	}
 
 	if (status > 0) {
+		printk("journal_extend failed, trying journal_restart\n");
 		status = journal_restart(handle->k_handle, nblocks);
 		if (status < 0) {
 #warning we need to handle this better
@@ -830,10 +833,10 @@
 			goto bail;
 		}
 
-		new_num_buffs = 0;
+		restarted = 1;
 		new_num_co = 0;
+		new_num_buffs = 0;
 		new_max_buffs = nblocks;
-		restarted = 1;
 	} else {
 		new_num_co = handle->num_co;
 		new_num_buffs = handle->num_buffs;
@@ -856,10 +859,12 @@
 	memset(new_co_buffs, 0, sizeof(ocfs_journal_copyout) * new_max_buffs);
 
 	if (!restarted) {
-		memcpy(new_buffs, handle->buffs, 
-		       sizeof(*new_buffs) * handle->num_buffs);
-		memcpy(new_co_buffs, handle->co_buffs, 
-		       sizeof(*new_co_buffs) * handle->num_co);
+		if (handle->num_buffs)
+			memcpy(new_buffs, handle->buffs, 
+			       sizeof(*new_buffs) * handle->num_buffs);
+		if (handle->num_co)
+			memcpy(new_co_buffs, handle->co_buffs, 
+			       sizeof(*new_co_buffs) * handle->num_co);
 	}
 
 	if (restarted) {
@@ -882,9 +887,9 @@
 		kfree(handle->co_buffs);
 	}
 
-	handle->max_buffs = new_max_buffs;
 	handle->buffs = new_buffs;
 	handle->num_buffs = new_num_buffs;
+	handle->max_buffs = new_max_buffs;
 	handle->co_buffs = new_co_buffs;
 	handle->num_co = new_num_co;
 	status = 0;
@@ -1020,7 +1025,7 @@
  */
 int ocfs_journal_dirty(ocfs_journal_handle *handle, struct buffer_head *bh) 
 {
-	int status = -1;
+	int status = -EINVAL;
 	int i = 0;
 
 	OCFS_ASSERT((handle->flags & OCFS_HANDLE_STARTED));
@@ -1028,16 +1033,8 @@
 	LOG_ENTRY_ARGS("(bh->b_blocknr=%llu)\n",
 			(unsigned long long)bh->b_blocknr);
 
-	if (handle->num_buffs >= handle->max_buffs) {
-		LOG_ERROR_ARGS("Cannot add buffer to full transaction! "
-			       "num_buffs=%d, max_buffs=%d, block=%llu\n",
-			       handle->num_buffs, handle->max_buffs,
-			       (unsigned long long)bh->b_blocknr);
-		goto done;
-	}
-
 	if (handle->flags & OCFS_HANDLE_ALWAYS_COMMITS)
-		goto inc_buffs_count;
+		goto call_jbd;
 
 	/* First, make sure we aren't already in the list. If we've
 	 * already been added, then that's OK as JBD knows how to
@@ -1052,13 +1049,14 @@
 		}
 	}
 
+	OCFS_ASSERT(handle->num_buffs < handle->max_buffs);
+
 	i = handle->num_buffs;
 	/* Increase the ref count on this buffer. We
 	 * do this because we still want to keep them
 	 * around in case of abort */
 	get_bh(bh);
 	handle->buffs[i] = bh;
-inc_buffs_count:
 	handle->num_buffs++;
 
 call_jbd:
@@ -1067,13 +1065,6 @@
 		LOG_ERROR_ARGS("Could not dirty metadata buffer. "
 			       "(bh->b_blocknr=%llu)\n",
 			       (unsigned long long)bh->b_blocknr);
-		if (!(handle->flags & OCFS_HANDLE_ALWAYS_COMMITS)) {
-			LOG_TRACE_ARGS("Setting handle->buffs[%d] = NULL\n", 
-				       i);
-			brelse(bh);
-			handle->buffs[i] = NULL;
-		}
-		handle->num_buffs--;
 		goto done;
 	}
 



More information about the Ocfs2-commits mailing list