[Ocfs2-commits] mfasheh commits r2212 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue May 3 13:17:32 CDT 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-05-03 13:17:31 -0500 (Tue, 03 May 2005)
New Revision: 2212

Modified:
   trunk/fs/ocfs2/journal.c
   trunk/fs/ocfs2/journal.h
   trunk/fs/ocfs2/ocfs.h
   trunk/fs/ocfs2/super.c
Log:
* push local node recovery completion to keventd using the same mechanism as
  the recovery thread. this fixes a problem with orphan dir recovery
  happening from mount. 

* use a wait_queue instead of a schedule() loop in ocfs_wait_on_mount

* add a couple lines of tracing which may be usefull for future debugging

Signed-off-by: manish



Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c	2005-05-03 18:11:24 UTC (rev 2211)
+++ trunk/fs/ocfs2/journal.c	2005-05-03 18:17:31 UTC (rev 2212)
@@ -946,6 +946,23 @@
 	spin_unlock(&journal->j_lock);
 }
 
+/* Called by the mount code to queue recovery the last part of
+ * recovery for it's own slot. */
+void ocfs2_complete_mount_recovery(ocfs_super *osb)
+{
+	ocfs_journal *journal = osb->journal;
+
+	if (osb->dirty) {
+		ocfs2_queue_local_alloc_cleanup(journal,
+						osb->local_alloc_copy);
+		osb->local_alloc_copy = NULL;
+
+		ocfs2_queue_orphan_dir_cleanup(journal);
+
+		osb->dirty = 0;
+	}
+}
+
 static int __ocfs_recovery_thread(void *arg)
 {
 	int status, node_num, recovered;
@@ -1421,6 +1438,8 @@
 			if (!iter) 
 				continue;
 
+			mlog(0, "queue orphan %"MLFu64"\n",
+			     OCFS_I(iter)->ip_blkno);
 			OCFS_I(iter)->ip_next_orphan = inode;
 			inode = iter;
 		}
@@ -1435,6 +1454,8 @@
 	orphan_dir_inode = NULL;
 
 	while (inode) {
+		mlog(0, "iput orphan %"MLFu64"\n", OCFS_I(inode)->ip_blkno);
+
 		iter = OCFS_I(inode)->ip_next_orphan;
 		iput(inode);
 		inode = iter;
@@ -1452,9 +1473,12 @@
 
 static int ocfs_wait_on_mount(ocfs_super *osb)
 {
-retry:
-	if (atomic_read(&osb->vol_state) == VOLUME_MOUNTED)
-		return 0;
+	/* This check is good because ocfs2 will wait on our recovery
+	 * thread before changing it to something other than MOUNTED
+	 * or DISABLED. */
+	wait_event(osb->osb_mount_event,
+		   atomic_read(&osb->vol_state) == VOLUME_MOUNTED ||
+		   atomic_read(&osb->vol_state) == VOLUME_DISABLED);
 
 	/* If there's an error on mount, then we may never get to the
 	 * MOUNTED flag, but this is set right before
@@ -1464,11 +1488,7 @@
 		return -EBUSY;
 	}
 
-	mlog(0, "vol_state = %d, waiting!\n", atomic_read(&osb->vol_state));
-
-	/* one day my prince will bring me a wait queue. */
-	schedule();
-	goto retry;
+	return 0;
 }
 
 static int ocfs_commit_thread(void *arg)

Modified: trunk/fs/ocfs2/journal.h
===================================================================
--- trunk/fs/ocfs2/journal.h	2005-05-03 18:11:24 UTC (rev 2211)
+++ trunk/fs/ocfs2/journal.h	2005-05-03 18:17:31 UTC (rev 2212)
@@ -204,6 +204,7 @@
 int    ocfs_journal_load(ocfs_journal *journal);
 void   ocfs_recovery_thread(struct _ocfs_super *osb, int node_num);
 int    ocfs2_mark_dead_nodes(ocfs_super *osb);
+void   ocfs2_complete_mount_recovery(ocfs_super *osb);
 
 static inline void ocfs_start_checkpoint(struct _ocfs_super *osb)
 {

Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h	2005-05-03 18:11:24 UTC (rev 2211)
+++ trunk/fs/ocfs2/ocfs.h	2005-05-03 18:17:31 UTC (rev 2212)
@@ -371,6 +371,8 @@
 	struct list_head		osb_okp_teardown_list;
 	struct list_head		osb_okp_pending_list;
 	wait_queue_head_t		osb_okp_pending_wq;
+
+	wait_queue_head_t		osb_mount_event;
 };
 
 #define NAMEI_RA_CHUNKS  2

Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-03 18:11:24 UTC (rev 2211)
+++ trunk/fs/ocfs2/super.c	2005-05-03 18:17:31 UTC (rev 2212)
@@ -92,7 +92,6 @@
 static int ocfs_init_local_system_inodes(ocfs_super *osb);
 static int ocfs_release_system_inodes(ocfs_super *osb);
 static int ocfs2_fill_local_node_info(ocfs_super *osb);
-static int ocfs2_complete_mount_recovery(ocfs_super *osb);
 static int ocfs_check_volume(ocfs_super * osb);
 static int ocfs_verify_volume(ocfs2_dinode *di, struct buffer_head *bh,
 			      u32 sectsize);
@@ -339,26 +338,22 @@
 
 	sb->s_root = root;
 
+	ocfs2_complete_mount_recovery(osb);
+
 	printk("ocfs2: Mounting device (%u,%u) on (node %d, slot %d)\n",
 	       MAJOR(sb->s_dev), MINOR(sb->s_dev), osb->node_num,
 	       osb->slot_num);
 
 	atomic_set(&osb->vol_state, VOLUME_MOUNTED);
+	wake_up(&osb->osb_mount_event);
 
-	if (osb->dirty) {
-		/* This must happen *after* setting the volume to
-		 * MOUNTED as we may sleep on any recovery threads. */
-		status = ocfs2_complete_mount_recovery(osb);
-		if (status < 0)
-			mlog_exit(status);
-	}
-
 	mlog_exit(status);
 	return status;		
 
 read_super_error:
 	if (osb) {
 		atomic_set(&osb->vol_state, VOLUME_DISABLED);
+		wake_up(&osb->osb_mount_event);
 		ocfs_dismount_volume (sb);
 	}
 
@@ -1043,6 +1038,8 @@
 	osb->have_local_alloc = 0;
 	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 */
@@ -1215,35 +1212,6 @@
 	return status;
 }				/* ocfs_verify_volume */
 
-/* This part of local node recovery needs to happen after we've
- * discovered all other nodes that need recovery and we've recovered
- * them. */
-static int ocfs2_complete_mount_recovery(ocfs_super *osb)
-{
-	int status = 0;
-	ocfs2_dinode *local_alloc = osb->local_alloc_copy;
-
-	osb->local_alloc_copy = NULL;
-
-	if (osb->dirty) {
-		status = ocfs_complete_local_alloc_recovery(osb, local_alloc);
-		if (status < 0) {
-			mlog_errno(status);
-			goto finally;
-		}
-
-		status = ocfs_recover_orphans(osb);
-		if (status < 0)
-			mlog_errno(status);
-	}
-	osb->dirty = 0;
-
-finally:
-	if (local_alloc)
-		kfree(local_alloc);
-	return status;
-}
-
 /*
  * ocfs_check_volume()
  *



More information about the Ocfs2-commits mailing list