[Ocfs2-commits] khackel commits r2816 - branches/ocfs2-1.2-cert/patches

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Mon Apr 3 16:13:22 CDT 2006


Author: khackel
Signed-off-by: jlbec
Date: 2006-04-03 16:13:21 -0500 (Mon, 03 Apr 2006)
New Revision: 2816

Added:
   branches/ocfs2-1.2-cert/patches/move-dlm-work-to-thread.patch
Modified:
   branches/ocfs2-1.2-cert/patches/series
Log:
add move-dlm-work-to-thread.patch
Signed-off-by: jlbec

Added: branches/ocfs2-1.2-cert/patches/move-dlm-work-to-thread.patch
===================================================================
--- branches/ocfs2-1.2-cert/patches/move-dlm-work-to-thread.patch	2006-04-03 19:23:53 UTC (rev 2815)
+++ branches/ocfs2-1.2-cert/patches/move-dlm-work-to-thread.patch	2006-04-03 21:13:21 UTC (rev 2816)
@@ -0,0 +1,224 @@
+Index: cert2/fs/ocfs2/dlm/dlmcommon.h
+===================================================================
+--- cert2.orig/fs/ocfs2/dlm/dlmcommon.h	2006-04-03 13:05:22.485447000 -0700
++++ cert2/fs/ocfs2/dlm/dlmcommon.h	2006-04-03 13:59:43.391426000 -0700
+@@ -121,12 +121,13 @@
+ 	struct o2hb_callback_func dlm_hb_down;
+ 	struct task_struct *dlm_thread_task;
+ 	struct task_struct *dlm_reco_thread_task;
++	struct task_struct *dlm_worker_task;
+ 	wait_queue_head_t dlm_thread_wq;
+ 	wait_queue_head_t dlm_reco_thread_wq;
++	wait_queue_head_t dlm_worker_thread_wq;
+ 	wait_queue_head_t ast_wq;
+ 	wait_queue_head_t migration_wq;
+ 
+-	struct work_struct dispatched_work;
+ 	struct list_head work_list;
+ 	spinlock_t work_lock;
+ 	struct list_head dlm_domain_handlers;
+@@ -701,6 +702,10 @@
+ int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node);
+ int dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout);
+ int dlm_wait_for_node_recovery(struct dlm_ctxt *dlm, u8 node, int timeout);
++int dlm_launch_worker_thread(struct dlm_ctxt *dlm);
++void dlm_kick_worker_thread(struct dlm_ctxt *dlm);
++void dlm_complete_worker_thread(struct dlm_ctxt *dlm);
++void dlm_dispatch_work(void *data);
+ 
+ void dlm_get(struct dlm_ctxt *dlm);
+ void dlm_put(struct dlm_ctxt *dlm);
+Index: cert2/fs/ocfs2/dlm/dlmdomain.c
+===================================================================
+--- cert2.orig/fs/ocfs2/dlm/dlmdomain.c	2006-04-03 13:05:22.678447000 -0700
++++ cert2/fs/ocfs2/dlm/dlmdomain.c	2006-04-03 13:59:53.091420000 -0700
+@@ -290,6 +290,7 @@
+ 	dlm_unregister_domain_handlers(dlm);
+ 	dlm_complete_thread(dlm);
+ 	dlm_complete_recovery_thread(dlm);
++	dlm_complete_worker_thread(dlm);
+ 
+ 	/* We've left the domain. Now we can take ourselves out of the
+ 	 * list and allow the kref stuff to help us free the
+@@ -1136,6 +1137,12 @@
+ 		goto bail;
+ 	}
+ 
++	status = dlm_launch_worker_thread(dlm);
++	if (status < 0) {
++		mlog_errno(status);
++		goto bail;
++	}
++
+ 	do {
+ 		unsigned int backoff;
+ 		status = dlm_try_to_join_domain(dlm);
+@@ -1176,11 +1183,14 @@
+ 		dlm_unregister_domain_handlers(dlm);
+ 		dlm_complete_thread(dlm);
+ 		dlm_complete_recovery_thread(dlm);
++		dlm_complete_worker_thread(dlm);
+ 	}
+ 
+ 	return status;
+ }
+ 
++
++
+ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
+ 				u32 key)
+ {
+@@ -1241,8 +1251,10 @@
+ 
+ 	dlm->dlm_thread_task = NULL;
+ 	dlm->dlm_reco_thread_task = NULL;
++	dlm->dlm_worker_task = NULL;
+ 	init_waitqueue_head(&dlm->dlm_thread_wq);
+ 	init_waitqueue_head(&dlm->dlm_reco_thread_wq);
++	init_waitqueue_head(&dlm->dlm_worker_thread_wq);
+ 	init_waitqueue_head(&dlm->reco.event);
+ 	init_waitqueue_head(&dlm->ast_wq);
+ 	init_waitqueue_head(&dlm->migration_wq);
+@@ -1260,7 +1272,6 @@
+ 
+ 	spin_lock_init(&dlm->work_lock);
+ 	INIT_LIST_HEAD(&dlm->work_list);
+-	INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work, dlm);
+ 
+ 	kref_init(&dlm->dlm_refs, dlm_ctxt_release);
+ 	dlm->dlm_state = DLM_CTXT_NEW;
+Index: cert2/fs/ocfs2/dlm/dlmmaster.c
+===================================================================
+--- cert2.orig/fs/ocfs2/dlm/dlmmaster.c	2006-04-03 13:05:22.720447000 -0700
++++ cert2/fs/ocfs2/dlm/dlmmaster.c	2006-04-03 13:54:09.433523000 -0700
+@@ -2018,7 +2018,7 @@
+ 	list_add_tail(&item->list, &dlm->work_list);
+ 	spin_unlock(&dlm->work_lock);
+ 
+-	schedule_work(&dlm->dispatched_work);
++	dlm_kick_worker_thread(dlm);
+ 	return 0;
+ }
+ 
+Index: cert2/fs/ocfs2/dlm/dlmrecovery.c
+===================================================================
+--- cert2.orig/fs/ocfs2/dlm/dlmrecovery.c	2006-04-03 13:05:22.658447000 -0700
++++ cert2/fs/ocfs2/dlm/dlmrecovery.c	2006-04-03 14:00:58.817233000 -0700
+@@ -150,6 +150,65 @@
+ 	spin_unlock(&dlm->spinlock);
+ }
+ 
++/*
++ * WORKER THREAD
++ */
++static int dlm_worker_thread(void *data);
++
++void dlm_kick_worker_thread(struct dlm_ctxt *dlm)
++{
++	wake_up(&dlm->dlm_worker_thread_wq);
++}
++
++/* Launch the worker thread */
++int dlm_launch_worker_thread(struct dlm_ctxt *dlm)
++{
++	mlog(0, "starting dlm worker thread...\n");
++
++	dlm->dlm_worker_task = kthread_run(dlm_worker_thread, dlm,
++						"dlm_work_thread");
++	if (IS_ERR(dlm->dlm_worker_task)) {
++		mlog_errno(PTR_ERR(dlm->dlm_worker_task));
++		dlm->dlm_worker_task = NULL;
++		return -EINVAL;
++	}
++
++	return 0;
++}
++
++void dlm_complete_worker_thread(struct dlm_ctxt *dlm)
++{
++	if (dlm->dlm_worker_task) {
++		mlog(0, "waiting for dlm worker thread to exit\n");
++		kthread_stop(dlm->dlm_worker_task);
++		dlm->dlm_worker_task = NULL;
++	}
++}
++
++#define DLM_WORKER_TIMEOUT_MS (5 * 1000)
++static int dlm_worker_thread(void *data)
++{
++	struct dlm_ctxt *dlm = data;
++	unsigned long timeout = msecs_to_jiffies(DLM_WORKER_TIMEOUT_MS);
++
++	mlog(0, "dlm worker thread running for %s...\n", dlm->name);
++
++	while (!kthread_should_stop()) {
++		if (dlm_joined(dlm)) {
++			mlog(0, "%s: starting dlm_dispatch_work\n", dlm->name);
++			dlm_dispatch_work(dlm);
++			mlog(0, "%s: done with dlm_dispatch_work\n", dlm->name);
++		}
++
++		wait_event_interruptible_timeout(dlm->dlm_worker_thread_wq,
++						 kthread_should_stop(),
++						 timeout);
++	}
++
++	mlog(0, "quitting DLM worker thread\n");
++	return 0;
++}
++
+ /* Worker function used during recovery. */
+ void dlm_dispatch_work(void *data)
+ {
+@@ -158,15 +217,22 @@
+ 	struct list_head *iter, *iter2;
+ 	struct dlm_work_item *item;
+ 	dlm_workfunc_t *workfunc;
++	int tot=0, i=0;
+ 
+ 	spin_lock(&dlm->work_lock);
+ 	list_splice_init(&dlm->work_list, &tmp_list);
+ 	spin_unlock(&dlm->work_lock);
+ 
+ 	list_for_each_safe(iter, iter2, &tmp_list) {
++		tot++;
++	}
++	mlog(0, "%s: work thread has %d work items\n", dlm->name, tot);
++
++	list_for_each_safe(iter, iter2, &tmp_list) {
+ 		item = list_entry(iter, struct dlm_work_item, list);
+ 		workfunc = item->func;
+ 		list_del_init(&item->list);
++		i++;
+ 
+ 		/* already have ref on dlm to avoid having
+ 		 * it disappear.  just double-check. */
+@@ -174,7 +240,10 @@
+ 
+ 		/* this is allowed to sleep and
+ 		 * call network stuff */
++		mlog(0, "%s: calling workfunc (%p) %d/%d\n", dlm->name,
++		     workfunc, i, tot);
+ 		workfunc(item, item->data);
++		mlog(0, "%s: done with workfunc %d/%d\n", dlm->name, i, tot);
+ 
+ 		dlm_put(dlm);
+ 		kfree(item);
+@@ -875,7 +944,7 @@
+ 	spin_lock(&dlm->work_lock);
+ 	list_add_tail(&item->list, &dlm->work_list);
+ 	spin_unlock(&dlm->work_lock);
+-	schedule_work(&dlm->dispatched_work);
++	dlm_kick_worker_thread(dlm);
+ 
+ 	dlm_put(dlm);
+ 	return 0;
+@@ -1430,7 +1499,7 @@
+ 	spin_lock(&dlm->work_lock);
+ 	list_add_tail(&item->list, &dlm->work_list);
+ 	spin_unlock(&dlm->work_lock);
+-	schedule_work(&dlm->dispatched_work);
++	dlm_kick_worker_thread(dlm);
+ 
+ leave:
+ 	dlm_put(dlm);

Modified: branches/ocfs2-1.2-cert/patches/series
===================================================================
--- branches/ocfs2-1.2-cert/patches/series	2006-04-03 19:23:53 UTC (rev 2815)
+++ branches/ocfs2-1.2-cert/patches/series	2006-04-03 21:13:21 UTC (rev 2816)
@@ -29,3 +29,4 @@
 lame-timeout-dbg.patch
 dlm-replace_gfp_kernel_with_nofs 
 hb-replace_gfp_kernel_with_nofs
+move-dlm-work-to-thread.patch




More information about the Ocfs2-commits mailing list