[Ocfs2-commits] manish commits r2254 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon May 16 20:19:00 CDT 2005


Author: manish
Signed-off-by: mfasheh
Date: 2005-05-16 20:18:58 -0500 (Mon, 16 May 2005)
New Revision: 2254

Modified:
   trunk/fs/ocfs2/super.c
Log:
Initialize a bunch of static osb members before we return any failures from
ocfs_initialize_osb, so thing the shutdown paths expect to be initialized
work.

Bail gracefully when max_nodes is 0.

Signed-off-by: mfasheh


Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-17 01:16:21 UTC (rev 2253)
+++ trunk/fs/ocfs2/super.c	2005-05-17 01:18:58 UTC (rev 2254)
@@ -927,6 +927,51 @@
 	mlog_entry_void ();
 
 	INIT_LIST_HEAD(&osb->osb_net_handlers);
+	init_waitqueue_head(&osb->recovery_event);
+	spin_lock_init(&osb->vote_task_lock);
+	init_waitqueue_head(&osb->vote_event);
+	osb->vote_work_sequence = 0;
+	osb->vote_wake_sequence = 0;
+	INIT_LIST_HEAD(&osb->blocked_lock_list);
+	osb->blocked_lock_count = 0;
+	INIT_LIST_HEAD(&osb->vote_list);
+	spin_lock_init(&osb->s_next_gen_lock);
+
+	spin_lock_init(&osb->osb_okp_teardown_lock);
+	INIT_LIST_HEAD(&osb->osb_okp_teardown_list);
+	INIT_LIST_HEAD(&osb->osb_okp_pending_list);
+	init_waitqueue_head(&osb->osb_okp_pending_wq);
+	/* we sync with this work queue (and sb ref) on unmount */
+	INIT_WORK(&osb->osb_okp_teardown_work, okp_teardown_from_list, osb);
+
+	atomic_set(&osb->alloc_stats.moves, 0);
+	atomic_set(&osb->alloc_stats.local_data, 0);
+	atomic_set(&osb->alloc_stats.bitmap_data, 0);
+	atomic_set(&osb->alloc_stats.bg_allocs, 0);
+	atomic_set(&osb->alloc_stats.bg_extends, 0);
+
+	ocfs2_init_node_maps(osb);
+
+	snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
+		 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
+
+	init_MUTEX (&(osb->recovery_lock));
+
+	osb->disable_recovery = 0;
+	osb->recovery_thread_task = NULL;
+
+	init_waitqueue_head (&osb->checkpoint_event);
+	atomic_set (&osb->needs_checkpoint, 0);
+	atomic_set (&osb->clean_buffer_seq, 1);
+	spin_lock_init (&osb->clean_buffer_lock);
+
+	osb->node_num = OCFS_INVALID_NODE_NUM;
+	osb->slot_num = OCFS_INVALID_NODE_NUM;
+
+	osb->local_alloc_state = OCFS2_LA_UNUSED;
+	osb->local_alloc_bh = NULL;
+
+	init_waitqueue_head(&osb->osb_mount_event);
 	
 	osb->vol_label = kmalloc(64, GFP_KERNEL);
 	if (!osb->vol_label) {
@@ -941,10 +986,10 @@
 		goto bail;
 	}
 
-	/* this needs to be done before most other initializations */
 	di = (ocfs2_dinode *) bh->b_data;
+
 	osb->max_nodes = le16_to_cpu(di->id2.i_super.s_max_nodes);
-	if (osb->max_nodes > OCFS2_MAX_NODES) {
+	if (osb->max_nodes > OCFS2_MAX_NODES || osb->max_nodes == 0) {
 		mlog(ML_ERROR, "Invalid number of nodes (%u)\n",
 		     osb->max_nodes);
 		status = -EINVAL;
@@ -981,30 +1026,8 @@
 		goto bail;
 	}
 
-	init_waitqueue_head(&osb->recovery_event);
-	spin_lock_init(&osb->vote_task_lock);
-	init_waitqueue_head(&osb->vote_event);
-	osb->vote_work_sequence = 0;
-	osb->vote_wake_sequence = 0;
-	INIT_LIST_HEAD(&osb->blocked_lock_list);
-	osb->blocked_lock_count = 0;
-	INIT_LIST_HEAD(&osb->vote_list);
-	spin_lock_init(&osb->s_next_gen_lock);
 	get_random_bytes(&osb->s_next_generation, sizeof(u32));
 
-	spin_lock_init(&osb->osb_okp_teardown_lock);
-	INIT_LIST_HEAD(&osb->osb_okp_teardown_list);
-	INIT_LIST_HEAD(&osb->osb_okp_pending_list);
-	init_waitqueue_head(&osb->osb_okp_pending_wq);
-	/* we sync with this work queue (and sb ref) on unmount */
-	INIT_WORK(&osb->osb_okp_teardown_work, okp_teardown_from_list, osb);
-
-	atomic_set(&osb->alloc_stats.moves, 0);
-	atomic_set(&osb->alloc_stats.local_data, 0);
-	atomic_set(&osb->alloc_stats.bitmap_data, 0);
-	atomic_set(&osb->alloc_stats.bg_allocs, 0);
-	atomic_set(&osb->alloc_stats.bg_extends, 0);
-
 	/* FIXME
 	 * This should be done in ocfs_journal_init(), but unknown
 	 * ordering issues will cause the filesystem to crash.
@@ -1033,31 +1056,6 @@
 	INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery, osb);
 	journal->j_state = OCFS_JOURNAL_FREE;
 
-	ocfs2_init_node_maps(osb);
-
-	snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
-		 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
-
-	init_MUTEX (&(osb->recovery_lock));
-
-	osb->disable_recovery = 0;
-	osb->recovery_thread_task = NULL;
-
-	init_waitqueue_head (&osb->checkpoint_event);
-	atomic_set (&osb->needs_checkpoint, 0);
-	atomic_set (&osb->clean_buffer_seq, 1);
-	spin_lock_init (&osb->clean_buffer_lock);
-
-	osb->node_num = OCFS_INVALID_NODE_NUM;
-	osb->slot_num = OCFS_INVALID_NODE_NUM;
-
-	osb->local_alloc_state = OCFS2_LA_UNUSED;
-	osb->local_alloc_bh = NULL;
-
-	init_waitqueue_head(&osb->osb_mount_event);
-
-	di = (ocfs2_dinode *) bh->b_data;
-
 	/* get some pseudo constants for clustersize bits */
 	osb->s_clustersize_bits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
 	osb->s_clustersize = 1 << osb->s_clustersize_bits;



More information about the Ocfs2-commits mailing list