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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jun 21 16:09:39 CDT 2004


Author: mfasheh
Date: 2004-06-21 15:09:37 -0500 (Mon, 21 Jun 2004)
New Revision: 1160

Modified:
   trunk/src/alloc.c
   trunk/src/alloc.h
   trunk/src/journal.c
   trunk/src/super.c
Log:
* fix a bug in the recovery code with processing bitmaps.
* clean up the local alloc shutdown / recovery paths a bit



Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-06-21 19:28:10 UTC (rev 1159)
+++ trunk/src/alloc.c	2004-06-21 20:09:37 UTC (rev 1160)
@@ -3792,8 +3792,8 @@
 				printk("ocfs2: disabling local alloc "
 				       "bitmap for this mount.\n");
 
-				ocfs_shutdown_local_alloc(osb, NULL, 0, 
-							  0);
+#warning this call will hang
+				ocfs_shutdown_local_alloc(osb, 0);
 
 				/* the bh might not have been dirtied to
 				 * the journal yet. */
@@ -4063,30 +4063,21 @@
  * local_alloc_bh is optional. If not passed, we will simply use the
  * one off osb. If you do pass it however, be warned that it *will* be
  * returned brelse'd and NULL'd out.*/
-void ocfs_shutdown_local_alloc(ocfs_super *osb, 
-			       struct buffer_head **local_alloc_bh, 
-			       int sync,
-			       int in_recovery)
+void ocfs_shutdown_local_alloc(ocfs_super *osb, int sync)
 {
 	int status;
 	ocfs2_dinode *alloc = NULL;
 	ocfs_bitmap_free_head *f = NULL;
 	struct buffer_head *bh = NULL;
 
-	LOG_ENTRY_ARGS("(local_alloc_bh = 0x%p, sync = %s, "
-		       "in_recovery = %s)\n", local_alloc_bh,
-		       sync ? "true" : "false",
-		       in_recovery ? "true" : "false");
+	LOG_ENTRY_ARGS("(sync = %s)", sync ? "true" : "false");
 
-	if (!osb->have_local_alloc && (!in_recovery))
+	if (!osb->have_local_alloc)
 		return;
 
-	if (local_alloc_bh)
-		bh = *local_alloc_bh;
-	else
-		bh = osb->local_alloc_bh;
+	bh = osb->local_alloc_bh;
 
-	status = ocfs_sync_local_from_shutdown(osb, &f, bh, in_recovery);
+	status = ocfs_sync_local_from_shutdown(osb, &f, bh, 0);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 	else if (f)
@@ -4107,42 +4098,62 @@
 	}
 
 	brelse(bh);
-	/* this is special only if we're using the one off osb. */
-	if (!local_alloc_bh) {
-		osb->local_alloc_bh = NULL;
-		osb->have_local_alloc = 0;
-	} else
-		*local_alloc_bh = NULL;
 
+	osb->local_alloc_bh = NULL;
+	osb->have_local_alloc = 0;
+
 	LOG_EXIT();
 	return;
 } /* ocfs_shutdown_local_alloc */
 
 /*
  * ocfs_recover_local_alloc
+ *
+ * We want to free the bitmap bits outside of any recovery context, so
+ * it's allocated and passed back for you.
  */
-int ocfs_recover_local_alloc(ocfs_super *osb, int node_num)
+int ocfs_recover_local_alloc(ocfs_super *osb, 
+			     int node_num, 
+			     ocfs_bitmap_free_head **bits_to_free)
 {
 	int status = 0;
 	struct buffer_head *alloc_bh = NULL;
 	struct inode *inode = NULL;
+	ocfs2_dinode *alloc;
 
 	LOG_ENTRY_ARGS("(node_num = %d)\n", node_num);
 
-	inode = ocfs_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, node_num);
+	inode = ocfs_get_system_file_inode(osb, 
+					   LOCAL_ALLOC_SYSTEM_INODE, 
+					   node_num);
 	if (!inode) {
 		LOG_ERROR_STATUS(status=-EINVAL);
 		goto bail;
 	}
 
-	status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &alloc_bh, 0, inode);
+	status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &alloc_bh, 
+			      0, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
 
-	ocfs_shutdown_local_alloc(osb, &alloc_bh, 1, 1);
+	status = ocfs_sync_local_from_shutdown(osb, 
+					       bits_to_free, 
+					       alloc_bh, 
+					       1);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
 
+	alloc = (ocfs2_dinode *) alloc_bh->b_data;
+	ocfs_clear_local_alloc(alloc);
+
+	status = ocfs_write_bh(osb, alloc_bh, 0, inode);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
+
 bail:
 	if (alloc_bh)
 		brelse(alloc_bh);

Modified: trunk/src/alloc.h
===================================================================
--- trunk/src/alloc.h	2004-06-21 19:28:10 UTC (rev 1159)
+++ trunk/src/alloc.h	2004-06-21 20:09:37 UTC (rev 1160)
@@ -70,10 +70,9 @@
 				int locked);
 int ocfs_process_bitmap_free_head(ocfs_super *osb,
 				  ocfs_bitmap_free_head *f);
-int ocfs_recover_local_alloc(ocfs_super *osb, int node_num);
-void ocfs_shutdown_local_alloc(ocfs_super *osb, 
-			       struct buffer_head **local_alloc_bh, 
- 			       int sync,
- 			       int in_recovery);
+int ocfs_recover_local_alloc(ocfs_super *osb, 
+			     int node_num, 
+			     ocfs_bitmap_free_head **bits_to_free);
+void ocfs_shutdown_local_alloc(ocfs_super *osb, int sync);
 
 #endif /* OCFS2_ALLOC_H */

Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c	2004-06-21 19:28:10 UTC (rev 1159)
+++ trunk/src/journal.c	2004-06-21 20:09:37 UTC (rev 1160)
@@ -1280,8 +1280,6 @@
 	return;
 }
 
-/* TODO: We need to manually scan the config sectors at startup and
- * call this function on any that aren't clean... */
 static int ocfs_recover_vol(ocfs_super *osb, int node_num) 
 {
 	int status = -1;
@@ -1293,6 +1291,7 @@
 	ocfs_journal * journal = NULL;
 	int recovery_lock = 0, got_lock = 0;
 	__u64 alloc_size;
+	ocfs_bitmap_free_head *bits_to_free = NULL;
 
 	LOG_ENTRY_ARGS("(node_num=%d, osb->node_num = %d)\n", node_num,
 		       osb->node_num);
@@ -1420,7 +1419,7 @@
 	journal_destroy(k_journal);
 
 	/* recover his local alloc file, AFTER recovering his journal... */
-	status = ocfs_recover_local_alloc(osb, node_num);
+	status = ocfs_recover_local_alloc(osb, node_num, &bits_to_free);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto done;
@@ -1455,6 +1454,14 @@
 	if (bh)
 		brelse(bh);
 
+	/* Free bits from the bitmaps only after the node has been
+	 * removed from the recovery map. */
+	if (bits_to_free) {
+		if (!status)
+			ocfs_process_bitmap_free_head(osb, bits_to_free);
+		ocfs_free_bitmap_free_head(bits_to_free);
+	}
+
 	atomic_dec(&osb->num_recovery_threads);
 
 	LOG_EXIT_STATUS(status);

Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c	2004-06-21 19:28:10 UTC (rev 1159)
+++ trunk/src/super.c	2004-06-21 20:09:37 UTC (rev 1160)
@@ -1145,7 +1145,7 @@
 #endif
 
 	/* Shutdown the journal and sync up and clear the local alloc. */
-	ocfs_shutdown_local_alloc(osb, NULL, 1, 0);
+	ocfs_shutdown_local_alloc(osb, 1);
 	ocfs_journal_shutdown(osb);
 
 	/* unset the mounted flag -- we're done with the journal and
@@ -1846,6 +1846,9 @@
 	int node_num = osb->node_num;
 	struct buffer_head * publish_bh = NULL;
 	int mounted;
+	ocfs_bitmap_free_head *bits_to_free = NULL; /* only used if we
+						     * recover
+						     * ourselves. */
 
 	LOG_ENTRY ();
 
@@ -1889,7 +1892,9 @@
 
 	if (mounted) {
 		/* recover my local alloc if we didn't unmount cleanly. */
-		status = ocfs_recover_local_alloc(osb, node_num);
+		status = ocfs_recover_local_alloc(osb, 
+						  node_num, 
+						  &bits_to_free);
 		if (status < 0) {
 			LOG_ERROR_STATUS(status);
 			goto finally;
@@ -1908,9 +1913,15 @@
 		LOG_ERROR_STATUS(status);
 
 finally:
-	if (publish_bh) {
+	if (publish_bh)
 		brelse(publish_bh);
+
+	if (bits_to_free) {
+		if (!status)
+			ocfs_process_bitmap_free_head(osb, bits_to_free);
+		ocfs_free_bitmap_free_head(bits_to_free);
 	}
+
 	LOG_EXIT_STATUS (status);
 	return status;
 }				/* ocfs_check_volume */



More information about the Ocfs2-commits mailing list