[Ocfs2-commits] mfasheh commits r2673 - in branches/locking-changes: . fs/ocfs2 fs/ocfs2/cluster fs/ocfs2/dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Oct 31 16:48:23 CST 2005


Author: mfasheh
Date: 2005-10-31 16:48:20 -0600 (Mon, 31 Oct 2005)
New Revision: 2673

Modified:
   branches/locking-changes/README
   branches/locking-changes/fs/ocfs2/alloc.c
   branches/locking-changes/fs/ocfs2/alloc.h
   branches/locking-changes/fs/ocfs2/cluster/heartbeat.c
   branches/locking-changes/fs/ocfs2/cluster/heartbeat.h
   branches/locking-changes/fs/ocfs2/cluster/sys.c
   branches/locking-changes/fs/ocfs2/dlm/dlmast.c
   branches/locking-changes/fs/ocfs2/dlm/dlmcommon.h
   branches/locking-changes/fs/ocfs2/dlm/dlmdomain.c
   branches/locking-changes/fs/ocfs2/dlm/dlmdomain.h
   branches/locking-changes/fs/ocfs2/dlm/dlmlock.c
   branches/locking-changes/fs/ocfs2/dlm/dlmmaster.c
   branches/locking-changes/fs/ocfs2/dlm/dlmrecovery.c
   branches/locking-changes/fs/ocfs2/dlm/dlmthread.c
   branches/locking-changes/fs/ocfs2/extent_map.c
   branches/locking-changes/fs/ocfs2/extent_map.h
   branches/locking-changes/fs/ocfs2/file.c
   branches/locking-changes/fs/ocfs2/file.h
   branches/locking-changes/fs/ocfs2/ver.c
   branches/locking-changes/fs/ocfs2/ver.h
Log:
* merge svn 2651:2672 from trunk:
        - README updates
        - DLM fixes
        - Code cleanups



Modified: branches/locking-changes/README
===================================================================
--- branches/locking-changes/README	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/README	2005-10-31 22:48:20 UTC (rev 2673)
@@ -28,8 +28,8 @@
 Caveats
 =======
 Features which OCFS2 does not support yet:
+	- sparse files
 	- extended attributes
-	- readonly mount
 	- shared writeable mmap
 	- loopback is supported, but data written will not
 	  be cluster coherent.
@@ -56,3 +56,6 @@
 data=writeback          Data ordering is not preserved, data may be
                         written into the main file system after its
                         metadata has been committed to the journal.
+intr             (*)    Allow signals to interrupt cluster operations.
+nointr                  Do not allow signals to interrupt cluster
+                        operations.

Modified: branches/locking-changes/fs/ocfs2/alloc.c
===================================================================
--- branches/locking-changes/fs/ocfs2/alloc.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/alloc.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -92,6 +92,8 @@
 				       struct buffer_head *old_last_eb,
 				       struct buffer_head **new_last_eb);
 
+static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc);
+
 static int ocfs2_extent_contig(struct inode *inode,
 			       ocfs2_extent_rec *ext,
 			       u64 blkno)
@@ -2018,7 +2020,7 @@
 	return status;
 }
 
-void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc)
+static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc)
 {
 	if (tc->tc_ext_alloc_inode) {
 		if (tc->tc_ext_alloc_locked)

Modified: branches/locking-changes/fs/ocfs2/alloc.h
===================================================================
--- branches/locking-changes/fs/ocfs2/alloc.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/alloc.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -70,8 +70,6 @@
 	struct buffer_head *tc_last_eb_bh;
 };
 
-void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc);
-
 int ocfs2_prepare_truncate(ocfs2_super *osb,
 			   struct inode *inode,
 			   struct buffer_head *fe_bh,

Modified: branches/locking-changes/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/locking-changes/fs/ocfs2/cluster/heartbeat.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/cluster/heartbeat.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -969,7 +969,8 @@
 }
 
 /* if we're already in a callback then we're already serialized by the sem */
-void o2hb_fill_node_map_from_callback(unsigned long *map, unsigned bytes)
+static void o2hb_fill_node_map_from_callback(unsigned long *map,
+					     unsigned bytes)
 {
 	BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long)));
 
@@ -1776,23 +1777,6 @@
 }
 EXPORT_SYMBOL_GPL(o2hb_check_local_node_heartbeating);
 
-/* Makes sure our local node is configured with a node number, and is
- * heartbeating. */
-int o2hb_check_local_node_heartbeating_from_callback(void)
-{
-	u8 node_num;
-
-	/* if this node was set then we have networking */
-	node_num = o2nm_this_node();
-	if (node_num == O2NM_MAX_NODES) {
-		mlog(ML_HEARTBEAT, "this node has not been configured.\n");
-		return 0;
-	}
-
-	return o2hb_check_node_heartbeating_from_callback(node_num);
-}
-EXPORT_SYMBOL_GPL(o2hb_check_local_node_heartbeating_from_callback);
-
 /*
  * this is just a hack until we get the plumbing which flips file systems
  * read only and drops the hb ref instead of killing the node dead.

Modified: branches/locking-changes/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- branches/locking-changes/fs/ocfs2/cluster/heartbeat.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/cluster/heartbeat.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -73,12 +73,10 @@
 int o2hb_unregister_callback(struct o2hb_callback_func *hc);
 void o2hb_fill_node_map(unsigned long *map,
 			unsigned bytes);
-void o2hb_fill_node_map_from_callback(unsigned long *map, unsigned bytes);
 void o2hb_init(void);
 int o2hb_check_node_heartbeating(u8 node_num);
 int o2hb_check_node_heartbeating_from_callback(u8 node_num);
 int o2hb_check_local_node_heartbeating(void);
-int o2hb_check_local_node_heartbeating_from_callback(void);
 void o2hb_stop_all_regions(void);
 
 #endif /* O2CLUSTER_HEARTBEAT_H */

Modified: branches/locking-changes/fs/ocfs2/cluster/sys.c
===================================================================
--- branches/locking-changes/fs/ocfs2/cluster/sys.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/cluster/sys.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -31,6 +31,7 @@
 
 #include "ocfs2_nodemanager.h"
 #include "masklog.h"
+#include "sys.h"
 
 struct o2cb_attribute {
 	struct attribute	attr;
@@ -66,7 +67,7 @@
 	.store	= o2cb_store,
 };
 
-struct kobj_type o2cb_subsys_type = {
+static struct kobj_type o2cb_subsys_type = {
 	.default_attrs	= o2cb_attrs,
 	.sysfs_ops	= &o2cb_sysfs_ops,
 };

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmast.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmast.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmast.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -91,7 +91,7 @@
 	return 0;
 }
 
-void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
+static void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
 {
 	mlog_entry_void();
 
@@ -136,7 +136,7 @@
 }
 
 
-void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
+static void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
 {
 	mlog_entry_void();
 

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmcommon.h
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmcommon.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmcommon.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -634,7 +634,6 @@
 void dlm_lock_get(struct dlm_lock *lock);
 void dlm_lock_put(struct dlm_lock *lock);
 
-void dlm_lock_detach_lockres(struct dlm_lock *lock);
 void dlm_lock_attach_lockres(struct dlm_lock *lock,
 			     struct dlm_lock_resource *res);
 
@@ -653,17 +652,12 @@
 void dlm_commit_pending_unlock(struct dlm_lock_resource *res,
 			       struct dlm_lock *lock);
 
-void dlm_shuffle_lists(struct dlm_ctxt *dlm,
-		       struct dlm_lock_resource *res);
 int dlm_launch_thread(struct dlm_ctxt *dlm);
 void dlm_complete_thread(struct dlm_ctxt *dlm);
-void dlm_flush_asts(struct dlm_ctxt *dlm);
-int dlm_flush_lockres_asts(struct dlm_ctxt *dlm, struct dlm_lock_resource *res);
 int dlm_launch_recovery_thread(struct dlm_ctxt *dlm);
 void dlm_complete_recovery_thread(struct dlm_ctxt *dlm);
 void dlm_wait_for_recovery(struct dlm_ctxt *dlm);
 
-void dlm_get(struct dlm_ctxt *dlm);
 void dlm_put(struct dlm_ctxt *dlm);
 struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm);
 int dlm_domain_fully_joined(struct dlm_ctxt *dlm);
@@ -697,9 +691,7 @@
 					  const char *name,
 					  unsigned int namelen);
 
-void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
 void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
-void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
 void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
 void dlm_do_local_ast(struct dlm_ctxt *dlm,
 		      struct dlm_lock_resource *res,
@@ -739,17 +731,13 @@
 
 u8 dlm_nm_this_node(struct dlm_ctxt *dlm);
 void dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res);
-void __dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res);
 void __dlm_dirty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res);
 
 
 int dlm_nm_init(struct dlm_ctxt *dlm);
 int dlm_heartbeat_init(struct dlm_ctxt *dlm);
-void __dlm_hb_node_down(struct dlm_ctxt *dlm, int idx);
 void dlm_hb_node_down_cb(struct o2nm_node *node, int idx, void *data);
 void dlm_hb_node_up_cb(struct o2nm_node *node, int idx, void *data);
-int dlm_hb_node_dead(struct dlm_ctxt *dlm, int node);
-int __dlm_hb_node_dead(struct dlm_ctxt *dlm, int node);
 
 int dlm_lockres_is_dirty(struct dlm_ctxt *dlm, struct dlm_lock_resource *res);
 int dlm_migrate_lockres(struct dlm_ctxt *dlm,
@@ -777,7 +765,6 @@
 			       int ignore_higher,
 			       u8 request_from,
 			       u32 flags);
-void dlm_assert_master_worker(struct dlm_work_item *item, void *data);
 
 
 int dlm_send_one_lockres(struct dlm_ctxt *dlm,
@@ -788,11 +775,6 @@
 void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
 				       struct dlm_lock_resource *res);
 
-void dlm_init_lockres(struct dlm_ctxt *dlm,
-		      struct dlm_lock_resource *res,
-		      const char *name,
-		      unsigned int namelen);
-
 /* will exit holding res->spinlock, but may drop in function */
 void __dlm_wait_on_lockres_flags(struct dlm_lock_resource *res, int flags);
 void __dlm_wait_on_lockres_flags_set(struct dlm_lock_resource *res, int flags);
@@ -809,24 +791,11 @@
 int dlm_init_mle_cache(void);
 void dlm_destroy_mle_cache(void);
 void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up);
-int dlm_do_assert_master(struct dlm_ctxt *dlm,
-			 const char *lockname,
-			 unsigned int namelen,
-			 void *nodemap,
-			 u32 flags);
-int dlm_do_migrate_request(struct dlm_ctxt *dlm,
-			   struct dlm_lock_resource *res,
-			   u8 master,
-			   u8 new_master,
-			   struct dlm_node_iter *iter);
 void dlm_clean_master_list(struct dlm_ctxt *dlm,
 			   u8 dead_node);
 int dlm_lock_basts_flushed(struct dlm_ctxt *dlm, struct dlm_lock *lock);
 
 
-int dlm_dump_all_mles(const char __user *data, unsigned int len);
-
-
 static inline const char * dlm_lock_mode_name(int mode)
 {
 	switch (mode) {

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmdomain.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmdomain.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmdomain.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -163,7 +163,7 @@
 }
 
 /* For null terminated domain strings ONLY */
-struct dlm_ctxt * __dlm_lookup_domain(const char *domain)
+static struct dlm_ctxt * __dlm_lookup_domain(const char *domain)
 {
 	assert_spin_locked(&dlm_domain_lock);
 
@@ -266,13 +266,6 @@
 	return target;
 }
 
-void dlm_get(struct dlm_ctxt *dlm)
-{
-	spin_lock(&dlm_domain_lock);
-	__dlm_get(dlm);
-	spin_unlock(&dlm_domain_lock);
-}
-
 int dlm_domain_fully_joined(struct dlm_ctxt *dlm)
 {
 	int ret;

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmdomain.h
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmdomain.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmdomain.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -28,7 +28,6 @@
 extern spinlock_t dlm_domain_lock;
 extern struct list_head dlm_domains;
 
-struct dlm_ctxt * __dlm_lookup_domain(const char *domain);
 int dlm_joined(struct dlm_ctxt *dlm);
 int dlm_shutting_down(struct dlm_ctxt *dlm);
 void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm,

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmlock.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmlock.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmlock.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -62,6 +62,7 @@
 static void dlm_init_lock(struct dlm_lock *newlock, int type,
 			  u8 node, u64 cookie);
 static void dlm_lock_release(struct kref *kref);
+static void dlm_lock_detach_lockres(struct dlm_lock *lock);
 
 /* Tell us whether we can grant a new lock request.
  * locking:
@@ -312,7 +313,7 @@
 }
 
 /* drop ref on lockres, if there is still one associated with lock */
-void dlm_lock_detach_lockres(struct dlm_lock *lock)
+static void dlm_lock_detach_lockres(struct dlm_lock *lock)
 {
 	struct dlm_lock_resource *res;
 

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmmaster.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmmaster.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -88,16 +88,19 @@
 	} u;
 };
 
-void dlm_print_one_mle(struct dlm_master_list_entry *mle);
+static void dlm_mle_node_down(struct dlm_ctxt *dlm,
+			      struct dlm_master_list_entry *mle,
+			      struct o2nm_node *node,
+			      int idx);
+static void dlm_mle_node_up(struct dlm_ctxt *dlm,
+			    struct dlm_master_list_entry *mle,
+			    struct o2nm_node *node,
+			    int idx);
 
-void dlm_mle_node_down(struct dlm_ctxt *dlm,
-		       struct dlm_master_list_entry *mle,
-		       struct o2nm_node *node,
-		       int idx);
-void dlm_mle_node_up(struct dlm_ctxt *dlm,
-		     struct dlm_master_list_entry *mle,
-		     struct o2nm_node *node,
-		     int idx);
+static void dlm_assert_master_worker(struct dlm_work_item *item, void *data);
+static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname,
+				unsigned int namelen, void *nodemap,
+				u32 flags);
 
 static inline int dlm_mle_equal(struct dlm_ctxt *dlm,
 				struct dlm_master_list_entry *mle,
@@ -123,6 +126,9 @@
 	return 1;
 }
 
+#if 0
+/* Code here is included but defined out as it aids debugging */
+
 void dlm_print_one_mle(struct dlm_master_list_entry *mle)
 {
 	int i = 0, refs;
@@ -152,9 +158,6 @@
 		  namelen, namelen, name);
 }
 
-			      
-static void dlm_dump_mles(struct dlm_ctxt *dlm);
-
 static void dlm_dump_mles(struct dlm_ctxt *dlm)
 {
 	struct dlm_master_list_entry *mle;
@@ -189,7 +192,9 @@
 }
 EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
 
+#endif  /*  0  */
 
+
 static kmem_cache_t *dlm_mle_cache = NULL;
 
 
@@ -419,8 +424,9 @@
 	}
 }
 
-void dlm_mle_node_down(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle,
-		       struct o2nm_node *node, int idx)
+static void dlm_mle_node_down(struct dlm_ctxt *dlm,
+			      struct dlm_master_list_entry *mle,
+			      struct o2nm_node *node, int idx)
 {
 	spin_lock(&mle->spinlock);
 
@@ -432,8 +438,9 @@
 	spin_unlock(&mle->spinlock);
 }
 
-void dlm_mle_node_up(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle,
-		     struct o2nm_node *node, int idx)
+static void dlm_mle_node_up(struct dlm_ctxt *dlm,
+			    struct dlm_master_list_entry *mle,
+			    struct o2nm_node *node, int idx)
 {
 	spin_lock(&mle->spinlock);
 
@@ -576,8 +583,9 @@
 	kref_put(&res->refs, dlm_lockres_release);
 }
 
-void dlm_init_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
-		      const char *name, unsigned int namelen)
+static void dlm_init_lockres(struct dlm_ctxt *dlm,
+			     struct dlm_lock_resource *res,
+			     const char *name, unsigned int namelen)
 {
 	char *qname;
 
@@ -658,7 +666,8 @@
 					  int flags)
 {
 	struct dlm_lock_resource *tmpres=NULL, *res=NULL;
-	struct dlm_master_list_entry *mle = NULL, *tmpmle = NULL;
+	struct dlm_master_list_entry *mle = NULL;
+	struct dlm_master_list_entry *alloc_mle = NULL;
 	int blocked = 0;
 	int ret, nodenum;
 	struct dlm_node_iter iter;
@@ -676,26 +685,23 @@
 	if (tmpres) {
 		spin_unlock(&dlm->spinlock);
 		mlog(0, "found in hash!\n");
-		if (mle)
-			kmem_cache_free(dlm_mle_cache, mle);
 		if (res)
 			dlm_lockres_put(res);
-		return tmpres;
+		res = tmpres;
+		goto leave;
 	}
 
 	if (!res) {
 		spin_unlock(&dlm->spinlock);
 		mlog(0, "allocating a new resource\n");
 		/* nothing found and we need to allocate one. */
-		mle = (struct dlm_master_list_entry *)kmem_cache_alloc(dlm_mle_cache,
-								GFP_KERNEL);
-		if (!mle)
-			return NULL;
+		alloc_mle = (struct dlm_master_list_entry *)
+			kmem_cache_alloc(dlm_mle_cache, GFP_KERNEL);
+		if (!alloc_mle)
+			goto leave;
 		res = dlm_new_lockres(dlm, lockid, namelen);
-		if (!res) {
-			kmem_cache_free(dlm_mle_cache, mle);
-			return NULL;
-		}
+		if (!res)
+			goto leave;
 		goto lookup;
 	}
 
@@ -710,8 +716,6 @@
 		spin_unlock(&res->spinlock);
 		spin_unlock(&dlm->spinlock);
 		/* lockres still marked IN_PROGRESS */
-		/* need to free the unused mle */
-		kmem_cache_free(dlm_mle_cache, mle);
 		goto wake_waiters;
 	}
 
@@ -719,12 +723,12 @@
 	spin_lock(&dlm->master_lock);
 
 	/* if we found a block, wait for lock to be mastered by another node */
-	blocked = dlm_find_mle(dlm, &tmpmle, (char *)lockid, namelen);
+	blocked = dlm_find_mle(dlm, &mle, (char *)lockid, namelen);
 	if (blocked) {
-		if (tmpmle->type == DLM_MLE_MASTER) {
+		if (mle->type == DLM_MLE_MASTER) {
 			mlog(ML_ERROR, "master entry for nonexistent lock!\n");
 			BUG();
-		} else if (tmpmle->type == DLM_MLE_MIGRATION) {
+		} else if (mle->type == DLM_MLE_MIGRATION) {
 			/* migration is in progress! */
 			/* the good news is that we now know the
 			 * "current" master (mle->master). */
@@ -734,22 +738,22 @@
 
 			/* set the lockres owner and hash it */
 			spin_lock(&res->spinlock);
-			dlm_set_lockres_owner(dlm, res, tmpmle->master);
+			dlm_set_lockres_owner(dlm, res, mle->master);
 			__dlm_insert_lockres(dlm, res);
 			spin_unlock(&res->spinlock);
 			spin_unlock(&dlm->spinlock);
 
 			/* master is known, detach */
-			dlm_mle_detach_hb_events(dlm, tmpmle);
-			dlm_put_mle(tmpmle);
-
-			/* need to free the unused mle */
-			kmem_cache_free(dlm_mle_cache, mle);
+			dlm_mle_detach_hb_events(dlm, mle);
+			dlm_put_mle(mle);
+			mle = NULL;
 			goto wake_waiters;
 		}
-	}
-	if (!blocked) {
+	} else {
 		/* go ahead and try to master lock on this node */
+		mle = alloc_mle;
+		/* make sure this does not get freed below */
+		alloc_mle = NULL;
 		dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0);
 		list_add(&mle->list, &dlm->master_list);
 	}
@@ -761,15 +765,17 @@
 
 	/* finally add the lockres to its hash bucket */
 	__dlm_insert_lockres(dlm, res);
+	/* get an extra ref on the mle in case this is a BLOCK
+	 * if so, the creator of the BLOCK may try to put the last
+	 * ref at this time in the assert master handler, so we
+	 * need an extra one to keep from a bad ptr deref. */
+	dlm_get_mle(mle);
 	spin_unlock(&dlm->master_lock);
 	spin_unlock(&dlm->spinlock);
 
-	if (blocked) {
-		/* must wait for lock to be mastered elsewhere */
-		kmem_cache_free(dlm_mle_cache, mle);
-		mle = tmpmle;
+	/* must wait for lock to be mastered elsewhere */
+	if (blocked)
 		goto wait;
-	}
 
 redo_request:
 	ret = -EINVAL;
@@ -810,6 +816,8 @@
 	/* master is known, detach if not already detached */
 	dlm_mle_detach_hb_events(dlm, mle);
 	dlm_put_mle(mle);
+	/* put the extra ref */
+	dlm_put_mle(mle);
 
 wake_waiters:
 	spin_lock(&res->spinlock);
@@ -817,6 +825,11 @@
 	spin_unlock(&res->spinlock);
 	wake_up(&res->wq);
 
+leave:
+	/* need to free the unused mle */
+	if (alloc_mle)
+		kmem_cache_free(dlm_mle_cache, alloc_mle);
+
 	return res;
 }
 
@@ -1225,6 +1238,7 @@
 	char *name;
 	unsigned int namelen;
 	int found, ret;
+	int set_maybe;
 
 	if (!dlm_grab(dlm))
 		return DLM_MASTER_RESP_NO;
@@ -1310,6 +1324,7 @@
 			mlog(ML_ERROR, "no mle found for this lock!\n");
 			BUG();
 		}
+		set_maybe = 1;
 		spin_lock(&tmpmle->spinlock);
 		if (tmpmle->type == DLM_MLE_BLOCK) {
 			// mlog(0, "this node is waiting for "
@@ -1328,12 +1343,19 @@
 				/* the real master can respond on its own */
 				response = DLM_MASTER_RESP_NO;
 			}
+		} else if (tmpmle->master != DLM_LOCK_RES_OWNER_UNKNOWN) {
+			set_maybe = 0;
+			if (tmpmle->master == dlm->node_num)
+				response = DLM_MASTER_RESP_YES;
+			else
+				response = DLM_MASTER_RESP_NO;
 		} else {
 			// mlog(0, "this node is attempting to "
 			// "master lockres\n");
 			response = DLM_MASTER_RESP_MAYBE;
 		}
-		set_bit(request->node_idx, tmpmle->maybe_map);
+		if (set_maybe)
+			set_bit(request->node_idx, tmpmle->maybe_map);
 		spin_unlock(&tmpmle->spinlock);
 
 		spin_unlock(&dlm->master_lock);
@@ -1382,6 +1404,7 @@
 		response = DLM_MASTER_RESP_NO;
 	} else {
 		// mlog(0, "mle was found\n");
+		set_maybe = 1;
 		spin_lock(&tmpmle->spinlock);
 		if (tmpmle->type == DLM_MLE_BLOCK)
 			response = DLM_MASTER_RESP_NO;
@@ -1395,9 +1418,15 @@
 			}
 			/* real master can respond on its own */
 			response = DLM_MASTER_RESP_NO;
-		} else
-			response = DLM_MASTER_RESP_MAYBE;
-		set_bit(request->node_idx, tmpmle->maybe_map);
+		} else {
+			if (tmpmle->master == dlm->node_num) {
+				response = DLM_MASTER_RESP_YES;
+				set_maybe = 0;
+			} else
+				response = DLM_MASTER_RESP_MAYBE;
+		}
+		if (set_maybe)
+			set_bit(request->node_idx, tmpmle->maybe_map);
 		spin_unlock(&tmpmle->spinlock);
 	}
 	spin_unlock(&dlm->master_lock);
@@ -1422,9 +1451,9 @@
  * can periodically run all locks owned by this node
  * and re-assert across the cluster...
  */
-int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname,
-			 unsigned int namelen, void *nodemap,
-			 u32 flags)
+static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname,
+				unsigned int namelen, void *nodemap,
+				u32 flags)
 {
 	struct dlm_assert_master assert;
 	int to, tmpret;
@@ -1483,7 +1512,7 @@
 	struct dlm_ctxt *dlm = data;
 	struct dlm_master_list_entry *mle = NULL;
 	struct dlm_assert_master *assert = (struct dlm_assert_master *)msg->buf;
-	struct dlm_lock_resource *res;
+	struct dlm_lock_resource *res = NULL;
 	char *name;
 	unsigned int namelen;
 	u32 flags;
@@ -1508,25 +1537,32 @@
 	/* find the MLE */
 	spin_lock(&dlm->master_lock);
 	if (!dlm_find_mle(dlm, &mle, name, namelen)) {
+		/* not an error, could be master just re-asserting */
 		mlog(0, "just got an assert_master from %u, but no "
 		     "MLE for it! (%.*s)\n", assert->node_idx,
 		     namelen, name);
 	} else {
 		int bit = find_next_bit (mle->maybe_map, O2NM_MAX_NODES, 0);
 		if (bit >= O2NM_MAX_NODES) {
+			/* not necessarily an error, though less likely.
+			 * could be master just re-asserting. */
 			mlog(ML_ERROR, "no bits set in the maybe_map, but %u "
 			     "is asserting! (%.*s)\n", assert->node_idx,
 			     namelen, name);
-			BUG();
 		} else if (bit != assert->node_idx) {
 			if (flags & DLM_ASSERT_MASTER_MLE_CLEANUP) {
 				mlog(0, "master %u was found, %u should "
 				     "back off\n", assert->node_idx, bit);
 			} else {
-				mlog(ML_ERROR, "expected %u to be the master, "
-				     "but %u is asserting! (%.*s)\n", bit,
-				     assert->node_idx, namelen, name);
-				BUG();
+				/* with the fix for bug 569, a higher node
+				 * number winning the mastery will respond
+				 * YES to mastery requests, but this node
+				 * had no way of knowing.  let it pass. */
+				mlog(ML_ERROR, "%u is the lowest node, "
+				     "%u is asserting. (%.*s)  %u must "
+				     "have begun after %u won.\n", bit,
+				     assert->node_idx, namelen, name, bit,
+				     assert->node_idx);
 			}
 		}
 	}
@@ -1537,7 +1573,11 @@
 	res = __dlm_lookup_lockres(dlm, name, namelen);
 	if (res) {
 		spin_lock(&res->spinlock);
-		BUG_ON(res->state & DLM_LOCK_RES_RECOVERING);
+		if (res->state & DLM_LOCK_RES_RECOVERING)  {
+			mlog(ML_ERROR, "%u asserting but %.*s is "
+			     "RECOVERING!\n", assert->node_idx, namelen, name);
+			goto kill;
+		}
 		if (!mle) {
 			if (res->owner != assert->node_idx) {
 				mlog(ML_ERROR, "assert_master from "
@@ -1590,7 +1630,10 @@
 	// mlog(0, "woo!  got an assert_master from node %u!\n",
 	// 	     assert->node_idx);
 	if (mle) {
+		int block;
+		
 		spin_lock(&mle->spinlock);
+		block = !!(mle->type == DLM_MLE_BLOCK);
 		mle->master = assert->node_idx;
 		atomic_set(&mle->woken, 1);
 		wake_up(&mle->wq);
@@ -1610,14 +1653,19 @@
 		/* master is known, detach if not already detached */
 		dlm_mle_detach_hb_events(dlm, mle);
 		dlm_put_mle(mle);
-		/* the assert master message now balances the extra
-		 * ref given by the master request message.
-		 * if this is the last put, it will be removed
-		 * from the list. */
-		dlm_put_mle(mle);
+		
+		if (block) {
+			/* the assert master message now balances the extra
+		 	 * ref given by the master request message.
+		 	 * if this is the last put, it will be removed
+		 	 * from the list. */
+			dlm_put_mle(mle);
+		}
 	}
 
 done:
+	if (res)
+		dlm_lockres_put(res);
 	dlm_put(dlm);
 	return 0;
 
@@ -1625,6 +1673,7 @@
 	/* kill the caller! */
 	spin_unlock(&res->spinlock);
 	spin_unlock(&dlm->spinlock);
+	dlm_lockres_put(res);
 	mlog(ML_ERROR, "Bad message received from another node.  Dumping state "
 	     "and killing the other node now!  This node is OK and can continue.\n");
 	dlm_dump_lock_resources(dlm);
@@ -1659,7 +1708,7 @@
 	return 0;
 }
 
-void dlm_assert_master_worker(struct dlm_work_item *item, void *data)
+static void dlm_assert_master_worker(struct dlm_work_item *item, void *data)
 {
 	struct dlm_ctxt *dlm = data;
 	int ret = 0;
@@ -1887,10 +1936,14 @@
 
 	/* get an extra reference on the mle.
 	 * otherwise the assert_master from the new
-	 * master will destroy this. */
+	 * master will destroy this.
+	 * also, make sure that all callers of dlm_get_mle
+	 * take both dlm->spinlock and dlm->master_lock */
+	spin_lock(&dlm->spinlock);
 	spin_lock(&dlm->master_lock);
 	dlm_get_mle(mle);
 	spin_unlock(&dlm->master_lock);
+	spin_unlock(&dlm->spinlock);
 
 	/* notify new node and send all lock state */
 	/* call send_one_lockres with migration flag.
@@ -2167,8 +2220,10 @@
 
 /* this is called by the new master once all lockres
  * data has been received */
-int dlm_do_migrate_request(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
-			   u8 master, u8 new_master, struct dlm_node_iter *iter)
+static int dlm_do_migrate_request(struct dlm_ctxt *dlm,
+				  struct dlm_lock_resource *res,
+				  u8 master, u8 new_master,
+				  struct dlm_node_iter *iter)
 {
 	struct dlm_migrate_request migrate;
 	int ret, status = 0;

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmrecovery.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmrecovery.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmrecovery.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -57,15 +57,15 @@
 static int dlm_recovery_thread(void *data);
 void dlm_complete_recovery_thread(struct dlm_ctxt *dlm);
 int dlm_launch_recovery_thread(struct dlm_ctxt *dlm);
-void dlm_kick_recovery_thread(struct dlm_ctxt *dlm);
-int dlm_do_recovery(struct dlm_ctxt *dlm);
+static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm);
+static int dlm_do_recovery(struct dlm_ctxt *dlm);
 
-int dlm_pick_recovery_master(struct dlm_ctxt *dlm);
+static int dlm_pick_recovery_master(struct dlm_ctxt *dlm);
 static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node);
-int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node);
-int dlm_request_all_locks(struct dlm_ctxt *dlm,
-			  u8 request_from, u8 dead_node);
-void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node);
+static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node);
+static int dlm_request_all_locks(struct dlm_ctxt *dlm,
+				 u8 request_from, u8 dead_node);
+static void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node);
 
 static inline int dlm_num_locks_in_lockres(struct dlm_lock_resource *res);
 static void dlm_init_migratable_lockres(struct dlm_migratable_lockres *mres,
@@ -164,7 +164,7 @@
  * RECOVERY THREAD
  */
 
-void dlm_kick_recovery_thread(struct dlm_ctxt *dlm)
+static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm)
 {
 	/* wake the recovery thread
 	 * this will wake the reco thread in one of three places
@@ -294,7 +294,7 @@
 	wake_up(&dlm->reco.event);
 }
 
-int dlm_do_recovery(struct dlm_ctxt *dlm)
+static int dlm_do_recovery(struct dlm_ctxt *dlm)
 {
 	int status = 0;
 
@@ -538,7 +538,7 @@
 	return status;
 }
 
-int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
+static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
 {
 	int num=0;
 	struct dlm_reco_node_data *ndata;
@@ -572,7 +572,7 @@
 	return 0;
 }
 
-void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
+static void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node)
 {
 	struct list_head *iter, *iter2;
 	struct dlm_reco_node_data *ndata;
@@ -589,7 +589,8 @@
 	}
 }
 
-int dlm_request_all_locks(struct dlm_ctxt *dlm, u8 request_from, u8 dead_node)
+static int dlm_request_all_locks(struct dlm_ctxt *dlm, u8 request_from,
+				 u8 dead_node)
 {
 	struct dlm_lock_request lr;
 	enum dlm_status ret;
@@ -1094,6 +1095,17 @@
 		spin_lock(&dlm->spinlock);
 		__dlm_insert_lockres(dlm, res);
 		spin_unlock(&dlm->spinlock);
+
+		/* now that the new lockres is inserted,
+		 * make it usable by other processes */
+		spin_lock(&res->spinlock);
+		res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
+		spin_unlock(&res->spinlock);
+
+		/* add an extra ref for just-allocated lockres 
+		 * otherwise the lockres will be purged immediately */
+		dlm_lockres_get(res);
+
 	}
 
 	/* at this point we have allocated everything we need,
@@ -1773,7 +1785,7 @@
 
 }
 
-void __dlm_hb_node_down(struct dlm_ctxt *dlm, int idx)
+static void __dlm_hb_node_down(struct dlm_ctxt *dlm, int idx)
 {
 	assert_spin_locked(&dlm->spinlock);
 
@@ -1854,22 +1866,6 @@
 	dlm_put(dlm);
 }
 
-int __dlm_hb_node_dead(struct dlm_ctxt *dlm, int node)
-{
-	if (test_bit(node, dlm->recovery_map))
-		return 1;
-	return 0;
-}
-
-int dlm_hb_node_dead(struct dlm_ctxt *dlm, int node)
-{
-	int ret;
-	spin_lock(&dlm->spinlock);
-	ret = __dlm_hb_node_dead(dlm, node);
-	spin_unlock(&dlm->spinlock);
-	return ret;
-}
-
 static void dlm_reco_ast(void *astdata)
 {
 	struct dlm_ctxt *dlm = astdata;
@@ -1888,7 +1884,7 @@
 }
 
 
-int dlm_pick_recovery_master(struct dlm_ctxt *dlm)
+static int dlm_pick_recovery_master(struct dlm_ctxt *dlm)
 {
 	enum dlm_status ret;
 	struct dlm_lockstatus lksb;

Modified: branches/locking-changes/fs/ocfs2/dlm/dlmthread.c
===================================================================
--- branches/locking-changes/fs/ocfs2/dlm/dlmthread.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/dlm/dlmthread.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -57,6 +57,8 @@
 
 static int dlm_thread(void *data);
 
+static void dlm_flush_asts(struct dlm_ctxt *dlm);
+
 #define dlm_lock_is_remote(dlm, lock)     ((lock)->ml.node != (dlm)->node_num)
 
 /* will exit holding res->spinlock, but may drop in function */
@@ -236,7 +238,8 @@
 	spin_unlock(&dlm->spinlock);
 }
 
-void dlm_shuffle_lists(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
+static void dlm_shuffle_lists(struct dlm_ctxt *dlm,
+			      struct dlm_lock_resource *res)
 {
 	struct dlm_lock *lock, *target;
 	struct list_head *iter;
@@ -412,15 +415,6 @@
 	wake_up(&dlm->dlm_thread_wq);
 }
 
-void __dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
-{
-	mlog_entry("dlm=%p, res=%p\n", dlm, res);
-	if (res)
-		__dlm_dirty_lockres(dlm, res);
-
-	wake_up(&dlm->dlm_thread_wq);
-}
-
 void __dlm_dirty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
 {
 	mlog_entry("dlm=%p, res=%p\n", dlm, res);
@@ -472,15 +466,8 @@
 	return empty;
 }
 
-int dlm_flush_lockres_asts(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
+static void dlm_flush_asts(struct dlm_ctxt *dlm)
 {
-	dlm_flush_asts(dlm);
-	/* still need to implement dlm_flush_lockres_asts */
-	return 0;
-}
-
-void dlm_flush_asts(struct dlm_ctxt *dlm)
-{
 	int ret;
 	struct dlm_lock *lock;
 	struct dlm_lock_resource *res;

Modified: branches/locking-changes/fs/ocfs2/extent_map.c
===================================================================
--- branches/locking-changes/fs/ocfs2/extent_map.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/extent_map.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -69,6 +69,8 @@
 			u32 cpos, u32 clusters,
 			struct rb_node ***ret_p,
 			struct rb_node **ret_parent);
+static int ocfs2_extent_map_insert(struct inode *inode, ocfs2_extent_rec *rec,
+				   int tree_depth);
 static int ocfs2_extent_map_insert_entry(struct ocfs2_extent_map *em,
 					 struct ocfs2_extent_map_entry *ent);
 static int ocfs2_extent_map_find_leaf(struct inode *inode,
@@ -482,8 +484,8 @@
 }
 
 
-int ocfs2_extent_map_insert(struct inode *inode, ocfs2_extent_rec *rec,
-			    int tree_depth)
+static int ocfs2_extent_map_insert(struct inode *inode, ocfs2_extent_rec *rec,
+				   int tree_depth)
 {
 	int ret;
 	struct ocfs2_em_insert_context ctxt = {0, };
@@ -633,6 +635,10 @@
 	return ret;
 }
 
+#if 0
+/* Code here is included but defined out as it completes the extent
+ * map api and may be used in the future. */
+
 /*
  * Look up the record containing this cluster offset.  This record is
  * part of the extent map.  Do not free it.  Any changes you make to
@@ -736,6 +742,8 @@
 	return -ENOENT;
 }
 
+#endif  /*  0  */
+
 int ocfs2_extent_map_get_blocks(struct inode *inode,
 				u64 v_blkno, int count,
 				u64 *p_blkno, int *ret_count)

Modified: branches/locking-changes/fs/ocfs2/extent_map.h
===================================================================
--- branches/locking-changes/fs/ocfs2/extent_map.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/extent_map.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -34,16 +34,8 @@
  * in the process of being updated.
  */
 int ocfs2_extent_map_init(struct inode *inode);
-int ocfs2_extent_map_insert(struct inode *inode, ocfs2_extent_rec *rec,
-			    int tree_depth);
 int ocfs2_extent_map_append(struct inode *inode, ocfs2_extent_rec *rec,
 			    u32 new_clusters);
-int ocfs2_extent_map_get_rec(struct inode *inode, u32 cpos,
-			     ocfs2_extent_rec **rec,
-			     int *tree_depth);
-int ocfs2_extent_map_get_clusters(struct inode *inode,
-				  u32 v_cpos, int count,
-			  	  u32 *p_cpos, int *ret_count);
 int ocfs2_extent_map_get_blocks(struct inode *inode,
 				u64 v_blkno, int count,
 				u64 *p_blkno, int *ret_count);

Modified: branches/locking-changes/fs/ocfs2/file.c
===================================================================
--- branches/locking-changes/fs/ocfs2/file.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/file.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -50,7 +50,7 @@
 
 #include "buffer_head_io.h"
 
-int ocfs2_sync_inode(struct inode *inode)
+static int ocfs2_sync_inode(struct inode *inode)
 {
 	filemap_fdatawrite(inode->i_mapping);
 	return sync_mapping_buffers(inode->i_mapping);

Modified: branches/locking-changes/fs/ocfs2/file.h
===================================================================
--- branches/locking-changes/fs/ocfs2/file.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/file.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -48,7 +48,6 @@
 int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
 int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
 		  struct kstat *stat);
-int ocfs2_sync_inode(struct inode *inode);
 
 int ocfs2_set_inode_size(ocfs2_journal_handle *handle,
 			 struct inode *inode,

Modified: branches/locking-changes/fs/ocfs2/ver.c
===================================================================
--- branches/locking-changes/fs/ocfs2/ver.c	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/ver.c	2005-10-31 22:48:20 UTC (rev 2673)
@@ -37,11 +37,6 @@
 	printk(KERN_INFO "%s\n", VERSION_STR);
 }
 
-int ocfs2_str_version(char *buf)
-{
-	return sprintf(buf, "%s\n", VERSION_STR);
-}
-
 MODULE_DESCRIPTION(VERSION_STR);
 
 #ifdef MODULE_VERSION

Modified: branches/locking-changes/fs/ocfs2/ver.h
===================================================================
--- branches/locking-changes/fs/ocfs2/ver.h	2005-10-31 20:20:26 UTC (rev 2672)
+++ branches/locking-changes/fs/ocfs2/ver.h	2005-10-31 22:48:20 UTC (rev 2673)
@@ -27,6 +27,5 @@
 #define OCFS2_VER_H
 
 void ocfs2_print_version(void);
-int ocfs2_str_version(char *buf);
 
 #endif /* OCFS2_VER_H */



More information about the Ocfs2-commits mailing list