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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Jun 22 18:27:58 CDT 2004


Author: mfasheh
Date: 2004-06-22 17:27:57 -0500 (Tue, 22 Jun 2004)
New Revision: 1184

Modified:
   trunk/src/journal.c
   trunk/src/lockres.c
   trunk/src/ocfs.h
   trunk/src/super.c
   trunk/src/vote.c
Log:
* removed unused vol_state enums

* turn osb->vol_state into an atomic_t

* recovery thread now knows how to wait on a mount thread (or detect a
  mount error and exit gracefully)



Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c	2004-06-22 22:18:20 UTC (rev 1183)
+++ trunk/src/journal.c	2004-06-22 22:27:57 UTC (rev 1184)
@@ -65,6 +65,7 @@
 static int ocfs_recover_vol(struct _ocfs_super *osb, int node_num);
 static int __ocfs_recovery_thread(void *arg);
 static int ocfs_commit_cache (ocfs_super * osb, int data_flush);
+static int ocfs_wait_on_mount(ocfs_super *osb);
 
 /* 
  * JBD in 2.4 kernels has a bug in that it doesn't do any locking of
@@ -1473,8 +1474,9 @@
 	/* Free bits from the bitmaps only after the node has been
 	 * removed from the recovery map. */
 	if (bits_to_free) {
-		if (!status)
+		if (!status && !ocfs_wait_on_mount(osb))
 			ocfs_process_bitmap_free_head(osb, bits_to_free);
+
 		ocfs_free_bitmap_free_head(bits_to_free);
 	}
 
@@ -1484,6 +1486,29 @@
 	return(status);
 }
 
+static int ocfs_wait_on_mount(ocfs_super *osb)
+{
+
+retry:
+	if (atomic_read(&osb->vol_state) == VOLUME_MOUNTED)
+		return 0;
+
+	/* If there's an error on mount, then we may never get to the
+	 * MOUNTED flag, but this is set right before
+	 * dismount_volume() so we can trust it. */
+	if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) {
+		LOG_TRACE_STR("mount error, exiting!");
+		return -EFAIL;
+	}
+
+	LOG_TRACE_ARGS("vol_state = %d, waiting!\n", 
+		       atomic_read(&osb->vol_state));
+
+	/* one day my prince will bring me a wait queue. */
+	schedule();
+	goto retry;
+}
+
 /*
  * ocfs_reset_publish()
  *

Modified: trunk/src/lockres.c
===================================================================
--- trunk/src/lockres.c	2004-06-22 22:18:20 UTC (rev 1183)
+++ trunk/src/lockres.c	2004-06-22 22:27:57 UTC (rev 1184)
@@ -118,10 +118,8 @@
 
 finally:
 	if (status < 0) {
-		if (status != -ETIMEDOUT) {
-			LOG_ERROR_STR ("Disabling Volume");
-			osb->vol_state = VOLUME_DISABLED;
-		}
+		if (status != -ETIMEDOUT)
+			LOG_ERROR_STATUS (status);
 	}
 
 	if (tmpbh)

Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h	2004-06-22 22:18:20 UTC (rev 1183)
+++ trunk/src/ocfs.h	2004-06-22 22:27:57 UTC (rev 1184)
@@ -494,14 +494,10 @@
 
 typedef enum _ocfs_vol_state
 {
-	VOLUME_DISABLED,
-	VOLUME_INIT,
-	VOLUME_ENABLED,
-	VOLUME_LOCKED,
-	VOLUME_IN_RECOVERY,
+	VOLUME_INIT = 0,
 	VOLUME_MOUNTED,
-	VOLUME_BEING_DISMOUNTED,
-	VOLUME_DISMOUNTED
+	VOLUME_DISMOUNTED,
+	VOLUME_DISABLED
 }
 ocfs_vol_state;
 
@@ -611,7 +607,7 @@
 	int needs_flush;
 
 	ocfs_alloc_bm cluster_bitmap;
-	ocfs_vol_state vol_state;
+	atomic_t vol_state;
 	struct semaphore recovery_lock;
 	spinlock_t recovery_map_lock;
 	ocfs_node_map recovery_map;

Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c	2004-06-22 22:18:20 UTC (rev 1183)
+++ trunk/src/super.c	2004-06-22 22:27:57 UTC (rev 1184)
@@ -366,12 +366,15 @@
 		MAJOR(sb->s_dev), MINOR(sb->s_dev),
 		osb->node_cfg_info[osb->node_num]->node_name, osb->node_num);
 
+	atomic_set(&osb->vol_state, VOLUME_MOUNTED);
 	LOG_EXIT_STATUS(status);
 	return status;		
 
 read_super_error:
-	if (osb)
+	if (osb) {
+		atomic_set(&osb->vol_state, VOLUME_DISABLED);
 		ocfs_dismount_volume (sb);
+	}
 
 	if (inode)
 		iput (inode);
@@ -1024,7 +1027,6 @@
 	up (&(osb->publish_lock));
 
 	ocfs_node_map_set_bit(&osb->publ_map, osb->node_num);
-	osb->vol_state = VOLUME_ENABLED;
 	up (&(osb->osb_res));
 
 	/* Read the publish sector for this node and cleanup dirent being */
@@ -1061,9 +1063,6 @@
 	}
 	up (&(osb->osb_res));
 
-
-	osb->vol_state = VOLUME_MOUNTED;
-
 leave:
 	if (bh != NULL)
 		brelse(bh);
@@ -1098,7 +1097,7 @@
 	}
 
 	/* disable any new recovery threads and wait for any currently
-	 * running ones to exit. */
+	 * running ones to exit. Do this before setting the vol_state. */
 	down(&osb->recovery_lock);
 	osb->disable_recovery = 1;
 	up(&osb->recovery_lock);
@@ -1139,7 +1138,6 @@
 
 	/* Dismount */
 	OCFS_SET_FLAG (osb->osb_flags, OCFS_OSB_FLAGS_BEING_DISMOUNTED);
-	osb->vol_state = VOLUME_BEING_DISMOUNTED;
 
 	/* Wait for this volume's NM thread to exit */
 	if (osb->dlm_task) {
@@ -1175,7 +1173,7 @@
 //    list_del(&osb->osb_next);  /* this has been moved into ocfs_delete_osb */
 	up (&(OcfsGlobalCtxt.global_res));
 
-	osb->vol_state = VOLUME_DISMOUNTED;
+	atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
 	if (AcquiredOSB) {
 		up (&(osb->osb_res));
 		AcquiredOSB = 0;
@@ -1527,6 +1525,8 @@
 	}
 	printk("root_blkno=%llu, system_dir_blkno=%llu\n", osb->root_blkno, osb->system_dir_blkno);
 
+	atomic_set (&osb->vol_state, VOLUME_INIT);
+
 	/* load root, system_dir, and all global system inodes */
 	status = ocfs_init_global_system_inodes(osb);
 	if (status < 0) {

Modified: trunk/src/vote.c
===================================================================
--- trunk/src/vote.c	2004-06-22 22:18:20 UTC (rev 1183)
+++ trunk/src/vote.c	2004-06-22 22:27:57 UTC (rev 1184)
@@ -1187,7 +1187,6 @@
 void ocfs_recovery_map_set(ocfs_super *osb, int num)
 {
 	spin_lock(&osb->recovery_map_lock);
-	osb->vol_state = VOLUME_IN_RECOVERY;
 	ocfs_node_map_set_bit(&osb->recovery_map, num);
 	spin_unlock(&osb->recovery_map_lock);
 }
@@ -1196,8 +1195,6 @@
 {
 	spin_lock(&osb->recovery_map_lock);
 	ocfs_node_map_clear_bit(&osb->recovery_map, num);
-	if (ocfs_node_map_is_empty(&osb->recovery_map))
-		osb->vol_state = VOLUME_ENABLED;
 	spin_unlock(&osb->recovery_map_lock);
 }
 



More information about the Ocfs2-commits mailing list