[Ocfs2-commits] rev 760 - in trunk/src: . inc

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Mar 5 14:25:07 CST 2004


Author: mfasheh
Date: 2004-03-05 14:25:06 -0600 (Fri, 05 Mar 2004)
New Revision: 760

Modified:
   trunk/src/inc/ocfs.h
   trunk/src/journal.c
   trunk/src/osb.c
   trunk/src/super.c
Log:
* fix a bug where umounting while a recovery thread is up will crash
  the system. We now block out new recovery threads and wait on existing
  ones in the mount path.



Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-03-05 20:22:58 UTC (rev 759)
+++ trunk/src/inc/ocfs.h	2004-03-05 20:25:06 UTC (rev 760)
@@ -2003,6 +2003,8 @@
 	struct semaphore recovery_lock;
 	spinlock_t recovery_map_lock;
 	__u32 recovery_map;
+	bool disable_recovery;
+	atomic_t num_recovery_threads;
 	ocfs_sem dir_alloc_lock;
 	ocfs_sem file_alloc_lock;
 	ocfs_sem vol_alloc_lock;

Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c	2004-03-05 20:22:58 UTC (rev 759)
+++ trunk/src/journal.c	2004-03-05 20:25:06 UTC (rev 760)
@@ -1422,6 +1422,10 @@
 	arg->osb = osb;
 	arg->node_num = node_num;
 
+	/* atomic_inc this here and let recover_vol dec it when
+	 * done. We do it this way to avoid races with umount. */
+	atomic_inc(&osb->num_recovery_threads);
+
 	LOG_TRACE_STR("starting recovery thread...");
 
 	kernel_thread(__ocfs_recovery_thread, (void *) arg,
@@ -1466,6 +1470,10 @@
 	 * comes in from this node for recovery */
 	down(&(osb->recovery_lock));
 	recovery_lock = true;
+	if (osb->disable_recovery) {
+		LOG_TRACE_STR("Shutting down so skipping reovery.");
+		goto done;
+	}
 
 	/* get the cleanup file fe and lock */
 	cleanup_file_id = (__u32) (JOURNAL_FILE_BASE_ID + node_num);
@@ -1644,6 +1652,8 @@
 	if (lock_res)
 		ocfs_put_lockres (lock_res);
 
+	atomic_dec(&osb->num_recovery_threads);
+
 	LOG_EXIT_STATUS(status);
 	return(status);
 }

Modified: trunk/src/osb.c
===================================================================
--- trunk/src/osb.c	2004-03-05 20:22:58 UTC (rev 759)
+++ trunk/src/osb.c	2004-03-05 20:25:06 UTC (rev 760)
@@ -84,6 +84,7 @@
 	osb->recovery_map = 0;
 
 	osb->needs_flush = false;
+	osb->disable_recovery = false;
 	osb->log_disk_off = 0;
 	osb->log_meta_disk_off = 0;
 	osb->trans_in_progress = false;
@@ -91,6 +92,8 @@
 	init_MUTEX (&(osb->publish_lock));
 	atomic_set (&osb->node_req_vote, 0);
 
+	atomic_set (&osb->num_recovery_threads, 0);
+
 	init_waitqueue_head (&osb->nm_init_event);
 	atomic_set (&osb->nm_init, 0);
 

Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c	2004-03-05 20:22:58 UTC (rev 759)
+++ trunk/src/super.c	2004-03-05 20:25:06 UTC (rev 760)
@@ -1105,6 +1105,16 @@
 	}
 	rootoin = osb->oin_root_dir;
 
+	/* disable any new recovery threads and wait for any currently
+	 * running ones to exit. */
+	down(&osb->recovery_lock);
+	osb->disable_recovery = true;
+	up(&osb->recovery_lock);
+	while (atomic_read(&osb->num_recovery_threads)) {
+		LOG_TRACE_STR("Waiting on a recovery thread to complete.");
+		schedule();
+	}
+
 	ocfs_down_sem (&(osb->osb_res), true);
 	AcquiredOSB = true;
 



More information about the Ocfs2-commits mailing list