[Ocfs2-commits] mfasheh commits r1653 - branches/dlm-glue/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Nov 16 15:25:06 CST 2004


Author: mfasheh
Date: 2004-11-16 15:25:05 -0600 (Tue, 16 Nov 2004)
New Revision: 1653

Modified:
   branches/dlm-glue/src/dlmglue.c
   branches/dlm-glue/src/dlmglue.h
   branches/dlm-glue/src/inode.c
   branches/dlm-glue/src/ocfs.h
Log:
* squish ocfs2_lock_res and ocfs2_lock into one structure
  finally. This simplifies things a fair amount and makes adding new
  lock types much easier.



Modified: branches/dlm-glue/src/dlmglue.c
===================================================================
--- branches/dlm-glue/src/dlmglue.c	2004-11-16 19:27:06 UTC (rev 1652)
+++ branches/dlm-glue/src/dlmglue.c	2004-11-16 21:25:05 UTC (rev 1653)
@@ -121,31 +121,28 @@
 };
 static int ocfs2_lock_create(ocfs_super *osb,
 			     ocfs2_lock_res *lockres,
-			     ocfs2_lock *lock,
 			     int level,
 			     int flags);
-static inline int ocfs2_may_continue_on_blocked_lock(ocfs2_lock *lock,
+static inline int ocfs2_may_continue_on_blocked_lock(ocfs2_lock_res *lockres,
 						     int wanted);
 static int ocfs2_cluster_lock(ocfs_super *osb,
 			      ocfs2_lock_res *lockres,
-			      ocfs2_lock *lock, 
 			      int level);
 static void ocfs2_unlock_ast_func(void *opaque, dlm_status status);
 static void ocfs2_inc_inode_seq(ocfs_super *osb,
 				struct inode *inode);
 static void ocfs2_schedule_blocked_inode(struct inode *inode);
 static inline void ocfs2_recover_from_dlm_error(ocfs2_lock_res *lockres,
-						ocfs2_lock *lock,
 						int convert);
 static void ocfs2_vote_on_unlock(ocfs_super *osb,
-				 ocfs2_lock *lock);
+				 ocfs2_lock_res *lockres);
 /* Called after we refresh our inode, only has any effect if we have
  * an EX lock. This populates the LVB with the initial values for our
  * change set. */
 static void ocfs2_reset_meta_lvb_values(struct inode *inode);
 static void __ocfs2_stuff_meta_lvb(struct inode *inode);
 static void ocfs2_refresh_inode_from_lvb(struct inode *inode);
-static void __ocfs2_lvb_on_downconvert(ocfs2_lock *lock,
+static void __ocfs2_lvb_on_downconvert(ocfs2_lock_res *lockres,
 				       int new_level);
 static int ocfs2_meta_lock_update(struct inode *inode,
 				  struct buffer_head **bh);
@@ -154,20 +151,17 @@
 static void ocfs2_process_vote(ocfs_super *osb,
 			       ocfs2_vote_msg *msg);
 static int __ocfs2_drop_lock(ocfs_super *osb,
-			     ocfs2_lock_res *lockres,
-			     ocfs2_lock *lock);
+			     ocfs2_lock_res *lockres);
 static inline int ocfs2_highest_compat_lock_level(int level);
 static int __ocfs2_downconvert_lock(ocfs_super *osb,
 				    ocfs2_lock_res *lockres,
-				    ocfs2_lock *lock,
 				    int new_level,
 				    int lvb);
 static int __ocfs2_cancel_convert(ocfs_super *osb,
-				  ocfs2_lock_res *lockres,
-				  ocfs2_lock *lock);
+				  ocfs2_lock_res *lockres);
 static void ocfs2_process_blocked_inode(struct inode *inode);
 static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode,
-						  ocfs2_lock *lock,
+						  ocfs2_lock_res *lockres,
 						  int new_level);
 static int ocfs2_process_blocked_meta(struct inode *inode,
 				      int *requeue);
@@ -177,45 +171,45 @@
 				 struct inode *inode,
 				 enum ocfs2_vote_request type);
 
-static inline int ocfs2_lvb_is_trustable(ocfs2_lock *lock)
+static inline int ocfs2_lvb_is_trustable(ocfs2_lock_res *lockres)
 {
-	ocfs2_lvb *lvb = (ocfs2_lvb *) lock->l_lksb.lvb;
+	ocfs2_lvb *lvb = (ocfs2_lvb *) lockres->l_lksb.lvb;
 	int ret = 0;
 
-	spin_lock(&lock->l_lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
 	if (lvb->lvb_seq &&
-	    lock->l_local_seq == lvb->lvb_seq)
+	    lockres->l_local_seq == lvb->lvb_seq)
 		ret = 1;
-	spin_unlock(&lock->l_lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 
 	return ret;
 }
 
-static inline void ocfs2_set_local_seq_from_lvb(ocfs2_lock *lock)
+static inline void ocfs2_set_local_seq_from_lvb(ocfs2_lock_res *lockres)
 {
-	ocfs2_lvb *lvb = (ocfs2_lvb *) lock->l_lksb.lvb;
+	ocfs2_lvb *lvb = (ocfs2_lvb *) lockres->l_lksb.lvb;
 
-	spin_lock(&lock->l_lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
 	if (lvb->lvb_seq)
-		lock->l_local_seq = lvb->lvb_seq;
-	spin_unlock(&lock->l_lockres->lr_lock);
+		lockres->l_local_seq = lvb->lvb_seq;
+	spin_unlock(&lockres->l_lock);
 }
 
 /* fill in new values as we add them to the lvb. */
 static inline void ocfs2_meta_lvb_get_values(ocfs2_lock_res *lockres,
 					     unsigned int *trunc_clusters)
 {
-	ocfs2_lock *lock = &lockres->lr_meta;
 	ocfs2_meta_lvb *lvb;
+	OCFS_ASSERT(lockres->l_type == OCFS_TYPE_DATA);
 
-	spin_lock(&lockres->lr_lock);
-	OCFS_ASSERT(lock->l_level > LKM_NLMODE);
+	spin_lock(&lockres->l_lock);
+	OCFS_ASSERT(lockres->l_level > LKM_NLMODE);
 
-	lvb = (ocfs2_meta_lvb *) lock->l_lksb.lvb;
+	lvb = (ocfs2_meta_lvb *) lockres->l_lksb.lvb;
 	if (trunc_clusters)
 		*trunc_clusters = lvb->lvb_trunc_clusters;
 
-	spin_unlock(&lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 }
 
 static int ocfs2_build_lock_name(enum ocfs2_lock_type type,
@@ -252,8 +246,9 @@
 	return (len);
 }
 
-int ocfs2_lock_res_init(struct inode *inode,
-			ocfs2_lock_res *res)
+int ocfs2_lock_res_init(ocfs2_lock_res *res,
+			enum ocfs2_lock_type type,
+			struct inode *inode)
 {
 	int status;
 
@@ -261,35 +256,21 @@
 
 	memset(res, 0, sizeof(ocfs2_lock_res));
 
-	spin_lock_init(&res->lr_lock);
+	spin_lock_init(&res->l_lock);
 	init_waitqueue_head(&res->l_event);
-	res->lr_inode = inode;
+	res->l_inode = inode;
+	res->l_type = type;
+	res->l_level = LKM_IVMODE;
 
-	/* build the data and metadata locks. */
-	status = ocfs2_build_lock_name(OCFS_TYPE_META, 
+	status = ocfs2_build_lock_name(type,
 				       OCFS_I(inode)->ip_blkno,
 				       inode->i_generation,
-				       &res->lr_meta.l_name);
+				       &res->l_name);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
-	status = ocfs2_build_lock_name(OCFS_TYPE_DATA,
-				       OCFS_I(inode)->ip_blkno,
-				       inode->i_generation,
-				       &res->lr_data.l_name);
-	if (status < 0) {
-		kfree(res->lr_meta.l_name);
-		res->lr_meta.l_name = NULL;
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-	res->lr_meta.l_type = OCFS_TYPE_META;
-	res->lr_meta.l_level = LKM_IVMODE;
-	res->lr_meta.l_lockres = res;
-	res->lr_data.l_type = OCFS_TYPE_DATA;
-	res->lr_data.l_level = LKM_IVMODE;
-	res->lr_data.l_lockres = res;
+
 bail:
 	LOG_EXIT_STATUS(status);
 	return status;
@@ -297,70 +278,67 @@
 
 void ocfs2_lock_res_free(ocfs2_lock_res *res)
 {
-	if (res->lr_data.l_name)
-		kfree(res->lr_data.l_name);
-	if (res->lr_meta.l_name)
-		kfree(res->lr_meta.l_name);
+	if (res->l_name)
+		kfree(res->l_name);
 }
 
-static inline void ocfs2_inc_holders(ocfs2_lock *lock,
+static inline void ocfs2_inc_holders(ocfs2_lock_res *lockres,
 				     int level)
 {
-	OCFS_ASSERT(lock);
+	OCFS_ASSERT(lockres);
 
 	switch(level) {
 	case LKM_EXMODE:
-		lock->l_ex_holders++;
+		lockres->l_ex_holders++;
 		break;
 	case LKM_PRMODE:
-		lock->l_ro_holders++;
+		lockres->l_ro_holders++;
 		break;
 	default:
 		BUG();
 	}
 }
 
-static inline void ocfs2_dec_holders(ocfs2_lock *lock,
+static inline void ocfs2_dec_holders(ocfs2_lock_res *lockres,
 				     int level)
 {
-	OCFS_ASSERT(lock);
+	OCFS_ASSERT(lockres);
 
 	switch(level) {
 	case LKM_EXMODE:
-		OCFS_ASSERT(lock->l_ex_holders);
-		lock->l_ex_holders--;
+		OCFS_ASSERT(lockres->l_ex_holders);
+		lockres->l_ex_holders--;
 		break;
 	case LKM_PRMODE:
-		OCFS_ASSERT(lock->l_ro_holders);
-		lock->l_ro_holders--;
+		OCFS_ASSERT(lockres->l_ro_holders);
+		lockres->l_ro_holders--;
 		break;
 	default:
 		BUG();
 	}
 }
 
-static inline void ocfs2_handle_downconvert_action(struct inode *inode,
-						   ocfs2_lock *lock)
+static inline void ocfs2_handle_downconvert_action(ocfs2_lock_res *lockres)
 {
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BUSY);
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_ATTACHED);
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BLOCKED);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BUSY);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_ATTACHED);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BLOCKED);
 
-	lock->l_level = lock->l_requested;
-	lock->l_blocking = LKM_NLMODE;
-	lock->l_flags &= ~OCFS2_LOCK_BLOCKED;
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
-	wake_up_all(&lock->l_lockres->l_event);
+	lockres->l_level = lockres->l_requested;
+	lockres->l_blocking = LKM_NLMODE;
+	lockres->l_flags &= ~OCFS2_LOCK_BLOCKED;
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
+	wake_up_all(&lockres->l_event);
 }
 
 static inline void ocfs2_handle_data_convert_action(struct inode *inode,
-						    ocfs2_lock *lock)
+						    ocfs2_lock_res *lockres)
 {
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BUSY);
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_ATTACHED);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BUSY);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_ATTACHED);
 
-	lock->l_level = lock->l_requested;
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
+	lockres->l_level = lockres->l_requested;
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
 }
 
 static void ocfs2_inc_inode_seq(ocfs_super *osb,
@@ -388,163 +366,157 @@
 }
 
 static inline void ocfs2_handle_meta_convert_action(struct inode *inode,
-						    ocfs2_lock *lock)
+						    ocfs2_lock_res *lockres)
 {
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BUSY);
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_ATTACHED);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BUSY);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_ATTACHED);
 
 	/* Convert from RO to EX doesn't really need anything as our
 	 * information is already up to data. Convert from NL to
 	 * *anything* however should mark the inode as needing an
 	 * update. */
-	if (lock->l_level == LKM_NLMODE) {
+	if (lockres->l_level == LKM_NLMODE) {
 		ocfs2_inc_inode_seq(osb, inode);
-		lock->l_flags |= OCFS2_LOCK_NEEDS_REFRESH;
+		lockres->l_flags |= OCFS2_LOCK_NEEDS_REFRESH;
 	}
 
-	lock->l_level = lock->l_requested;
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
+	lockres->l_level = lockres->l_requested;
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
 }
 
 static inline void ocfs2_handle_attach_action(struct inode *inode,
-					      ocfs2_lock *lock)
+					      ocfs2_lock_res *lockres)
 {
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BUSY);
-	OCFS_ASSERT(!(lock->l_flags & OCFS2_LOCK_ATTACHED));
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BUSY);
+	OCFS_ASSERT(!(lockres->l_flags & OCFS2_LOCK_ATTACHED));
 
 	/* skip the cache thunk for nlmode requests and local (new
 	 * inode) locks. */
-	if (lock->l_requested > LKM_NLMODE &&
-	    !(lock->l_flags & OCFS2_LOCK_LOCAL)) {
+	if (lockres->l_requested > LKM_NLMODE &&
+	    !(lockres->l_flags & OCFS2_LOCK_LOCAL)) {
 		ocfs2_inc_inode_seq(osb, inode);
-		lock->l_flags |= OCFS2_LOCK_NEEDS_REFRESH;
+		lockres->l_flags |= OCFS2_LOCK_NEEDS_REFRESH;
 	}
 
-	lock->l_level = lock->l_requested;
-	lock->l_flags |= OCFS2_LOCK_ATTACHED;
+	lockres->l_level = lockres->l_requested;
+	lockres->l_flags |= OCFS2_LOCK_ATTACHED;
 	/* should this part be in ocfs2_ast_func? */
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
 }
 
 /* can we get a lock type in this proto to? */
 static void ocfs2_ast_func(void *opaque)
 {
-	ocfs2_lock *lock = opaque;
-	ocfs2_lock_res *lockres = lock->l_lockres;
-	struct inode *inode = lockres->lr_inode;
+	ocfs2_lock_res *lockres = opaque;
+	struct inode *inode = lockres->l_inode;
 	dlm_lockstatus *lksb;
 
 #ifdef OCFS2_VERBOSE_LOCKING_TRACE
 	printk("AST fired for inode %llu\n", OCFS_I(inode)->ip_blkno);
 #endif
-	OCFS_ASSERT(lock == &lockres->lr_meta || 
-		    lock == &lockres->lr_data);
-	OCFS_ASSERT(lock->l_type == OCFS_TYPE_META ||
-		    lock->l_type == OCFS_TYPE_DATA);
+	OCFS_ASSERT(lockres->l_type == OCFS_TYPE_META ||
+		    lockres->l_type == OCFS_TYPE_DATA);
 
-	spin_lock(&lockres->lr_lock);
-	lksb = &(lock->l_lksb);
+	spin_lock(&lockres->l_lock);
+	lksb = &(lockres->l_lksb);
 	if (lksb->status != DLM_NORMAL) {
 		printk("ocfs2_meta_ast_func: lksb status value of %u on "
 		       "inode %llu\n", lksb->status, OCFS_I(inode)->ip_blkno);
-		spin_unlock(&lockres->lr_lock);
+		spin_unlock(&lockres->l_lock);
 		return;
 	}
 
-	switch(lock->l_action) {
+	switch(lockres->l_action) {
 	case OCFS2_AST_ATTACH:
-		ocfs2_handle_attach_action(inode, lock);
+		ocfs2_handle_attach_action(inode, lockres);
 		break;
 	case OCFS2_AST_CONVERT:
-		if (lock->l_type == OCFS_TYPE_META)
-			ocfs2_handle_meta_convert_action(inode, lock);
+		if (lockres->l_type == OCFS_TYPE_META)
+			ocfs2_handle_meta_convert_action(inode, lockres);
 		else
-			ocfs2_handle_data_convert_action(inode, lock);
+			ocfs2_handle_data_convert_action(inode, lockres);
 		break;
 	case OCFS2_AST_DOWNCONVERT:
-		ocfs2_handle_downconvert_action(inode, lock);
+		ocfs2_handle_downconvert_action(lockres);
 		break;
 	default:
 		BUG();
 	}
 	/* set it to something invalid so if we get called again we
 	 * can catch it. */
-	lock->l_action = OCFS2_AST_INVALID;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_action = OCFS2_AST_INVALID;
+	spin_unlock(&lockres->l_lock);
 	wake_up_all(&lockres->l_event);
 }
 
 static void ocfs2_bast_func(void *opaque, int level)
 {
-	ocfs2_lock *lock = opaque;
-	ocfs2_lock_res *lockres = lock->l_lockres;
-	struct inode *inode = lockres->lr_inode;
+	ocfs2_lock_res *lockres = opaque;
+	struct inode *inode = lockres->l_inode;
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 
 #ifdef OCFS2_VERBOSE_LOCKING_TRACE
 	printk("BAST fired for inode %llu\n", OCFS_I(inode)->ip_blkno);
 #endif
-	spin_lock(&lockres->lr_lock);
-	lock->l_flags |= OCFS2_LOCK_BLOCKED;
-	if (level > lock->l_blocking)
-		lock->l_blocking = level;
-	spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	lockres->l_flags |= OCFS2_LOCK_BLOCKED;
+	if (level > lockres->l_blocking)
+		lockres->l_blocking = level;
+	spin_unlock(&lockres->l_lock);
 	ocfs2_schedule_blocked_inode(inode);
 	ocfs2_kick_vote_thread(osb);
 }
 
 static inline void ocfs2_recover_from_dlm_error(ocfs2_lock_res *lockres,
-						ocfs2_lock *lock,
 						int convert)
 {
-	spin_lock(&lockres->lr_lock);
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
+	spin_lock(&lockres->l_lock);
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
 	if (convert)
-		lock->l_action = OCFS2_AST_INVALID;
+		lockres->l_action = OCFS2_AST_INVALID;
 	else
-		lock->l_unlock_action = OCFS2_UNLOCK_INVALID;
-	spin_unlock(&lockres->lr_lock);
+		lockres->l_unlock_action = OCFS2_UNLOCK_INVALID;
+	spin_unlock(&lockres->l_lock);
 }
 
 static int ocfs2_lock_create(ocfs_super *osb,
 			     ocfs2_lock_res *lockres,
-			     ocfs2_lock *lock,
 			     int level,
 			     int flags)
 {
 	int ret = 0;
-	enum ocfs2_lock_type type = lock->l_type;
+	enum ocfs2_lock_type type = lockres->l_type;
 	dlm_status status;
 
 	LOG_ENTRY();
 
-	spin_lock(&lockres->lr_lock);
-	if (lock->l_flags & OCFS2_LOCK_ATTACHED) {
-		spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	if (lockres->l_flags & OCFS2_LOCK_ATTACHED) {
+		spin_unlock(&lockres->l_lock);
 		goto bail;
 	}
 
-	lock->l_action = OCFS2_AST_ATTACH;
-	lock->l_requested = level;
-	lock->l_flags |= OCFS2_LOCK_BUSY;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_action = OCFS2_AST_ATTACH;
+	lockres->l_requested = level;
+	lockres->l_flags |= OCFS2_LOCK_BUSY;
+	spin_unlock(&lockres->l_lock);
 
 	status = dlmlock(osb->dlm,
 			 level,
-			 &lock->l_lksb,
+			 &lockres->l_lksb,
 			 flags,
-			 lock->l_name,
+			 lockres->l_name,
 			 ocfs2_lock_type_asts[type],
-			 lock,
+			 lockres,
 			 ocfs2_lock_type_basts[type]);
 	if (status != DLM_NORMAL) {
 		LOG_ERROR_ARGS("Dlm returns %d\n", status);
 		ret = -ENOENT;
-		ocfs2_recover_from_dlm_error(lockres, lock, 1);
+		ocfs2_recover_from_dlm_error(lockres, 1);
 	}
 
 bail:
@@ -553,63 +525,55 @@
 }
 
 static inline int ocfs2_check_wait_flag(ocfs2_lock_res *lockres,
-					ocfs2_lock *lock,
 					int flag)
 {
 	int ret;
-	spin_lock(&lockres->lr_lock);
-	ret = lock->l_flags & flag;
-	spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	ret = lockres->l_flags & flag;
+	spin_unlock(&lockres->l_lock);
 	return ret;
 }
 
-static inline void ocfs2_wait_on_busy_lock(ocfs2_lock_res *lockres,
-					   ocfs2_lock *lock)
+static inline void ocfs2_wait_on_busy_lock(ocfs2_lock_res *lockres)
 
 {
 	wait_event_interruptible(lockres->l_event,
 				 !ocfs2_check_wait_flag(lockres,
-							lock,
 							OCFS2_LOCK_BUSY));
 }
 
-static inline void ocfs2_wait_on_blocked_lock(ocfs2_lock_res *lockres,
-					      ocfs2_lock *lock)
+static inline void ocfs2_wait_on_blocked_lock(ocfs2_lock_res *lockres)
 
 {
 	wait_event_interruptible(lockres->l_event,
 				 !ocfs2_check_wait_flag(lockres,
-							lock,
 							OCFS2_LOCK_BLOCKED));
 }
 
-static inline void ocfs2_wait_on_refreshing_lock(ocfs2_lock_res *lockres,
-						 ocfs2_lock *lock)
+static inline void ocfs2_wait_on_refreshing_lock(ocfs2_lock_res *lockres)
 
 {
 	wait_event_interruptible(lockres->l_event,
 				 !ocfs2_check_wait_flag(lockres,
-							lock,
 							OCFS2_LOCK_REFRESHING));}
 
 /* predict what lock level we'll be dropping down to on behalf
  * of another node, and return true if the currently wanted
  * level will be compatible with it. */
-static inline int ocfs2_may_continue_on_blocked_lock(ocfs2_lock *lock,
+static inline int ocfs2_may_continue_on_blocked_lock(ocfs2_lock_res *lockres,
 						     int wanted)
 {
-	OCFS_ASSERT(lock->l_flags & OCFS2_LOCK_BLOCKED);
+	OCFS_ASSERT(lockres->l_flags & OCFS2_LOCK_BLOCKED);
 
-	return wanted <= ocfs2_highest_compat_lock_level(lock->l_blocking);
+	return wanted <= ocfs2_highest_compat_lock_level(lockres->l_blocking);
 }
 
 static int ocfs2_cluster_lock(ocfs_super *osb,
 			      ocfs2_lock_res *lockres,
-			      ocfs2_lock *lock, 
 			      int level)
 {
 	int ret;
-	enum ocfs2_lock_type type = lock->l_type;
+	enum ocfs2_lock_type type = lockres->l_type;
 	dlm_status status;
 
 	LOG_ENTRY();
@@ -620,24 +584,24 @@
 		goto bail;
 	}
 
-	spin_lock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
 
 	/* We only compare against the currently granted level
 	 * here. If the lock is blocked waiting on a downconvert,
 	 * we'll get caught below. */
-	if (lock->l_flags & OCFS2_LOCK_BUSY &&
-	    level > lock->l_level) {
+	if (lockres->l_flags & OCFS2_LOCK_BUSY &&
+	    level > lockres->l_level) {
 		/* is someone sitting in dlm_lock? If so, wait on
 		 * them. */
-		spin_unlock(&lockres->lr_lock);
-		ocfs2_wait_on_busy_lock(lockres, lock);
+		spin_unlock(&lockres->l_lock);
+		ocfs2_wait_on_busy_lock(lockres);
 		goto again;
 	}
 
-	if (!(lock->l_flags & OCFS2_LOCK_ATTACHED)) {
+	if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) {
 		/* lock has not been created yet. */
-		spin_unlock(&lockres->lr_lock);
-		ret = ocfs2_lock_create(osb, lockres, lock, LKM_NLMODE, 0);
+		spin_unlock(&lockres->l_lock);
+		ret = ocfs2_lock_create(osb, lockres, LKM_NLMODE, 0);
 		if (ret < 0) {
 			LOG_ERROR_STATUS(ret);
 			goto bail;
@@ -645,45 +609,45 @@
 		goto again;
 	}
 
-	if (lock->l_flags & OCFS2_LOCK_BLOCKED &&
-	    !ocfs2_may_continue_on_blocked_lock) {
+	if (lockres->l_flags & OCFS2_LOCK_BLOCKED &&
+	    !ocfs2_may_continue_on_blocked_lock(lockres, level)) {
 		/* is the lock is currently blocked on behalf of
 		 * another node */
-		spin_unlock(&lockres->lr_lock);
-		ocfs2_wait_on_blocked_lock(lockres, lock);
+		spin_unlock(&lockres->l_lock);
+		ocfs2_wait_on_blocked_lock(lockres);
 		goto again;
 	}
 
-	if (level > lock->l_level) {
-		lock->l_action = OCFS2_AST_CONVERT;
-		lock->l_requested = level;
-		lock->l_flags |= OCFS2_LOCK_BUSY;
-		spin_unlock(&lockres->lr_lock);
+	if (level > lockres->l_level) {
+		lockres->l_action = OCFS2_AST_CONVERT;
+		lockres->l_requested = level;
+		lockres->l_flags |= OCFS2_LOCK_BUSY;
+		spin_unlock(&lockres->l_lock);
 
 		/* call dlm_lock to upgrade lock now */
 		status = dlmlock(osb->dlm,
 				 level,
-				 &lock->l_lksb,
+				 &lockres->l_lksb,
 				 LKM_CONVERT|LKM_VALBLK,
-				 lock->l_name,
+				 lockres->l_name,
 				 ocfs2_lock_type_asts[type],
-				 lock,
+				 lockres,
 				 ocfs2_lock_type_basts[type]);
 		if (status != DLM_NORMAL) {
 			LOG_ERROR_ARGS("Dlm returns %d\n", status);
 			ret = -ENOENT;
-			ocfs2_recover_from_dlm_error(lockres, lock, 1);
+			ocfs2_recover_from_dlm_error(lockres, 1);
 			goto bail;
 		}
 
-		ocfs2_wait_on_busy_lock(lockres, lock);
+		ocfs2_wait_on_busy_lock(lockres);
 		goto again;
 	}
 
 	/* Ok, if we get here then we're good to go. */
-	ocfs2_inc_holders(lock, level);
+	ocfs2_inc_holders(lockres, level);
 
-	spin_unlock(&lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 
 	ret = 0;
 bail:
@@ -702,7 +666,6 @@
 	int status;
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 	ocfs2_lock_res *lockres;
-	ocfs2_lock *lock;
 
 	OCFS_ASSERT(inode);
 	OCFS_ASSERT(ocfs_inode_is_new(inode));
@@ -718,24 +681,22 @@
 	 * valid when we release the EX. */
 
 	lockres = &OCFS_I(inode)->ip_meta_lockres;
-	lock = &lockres->lr_meta;
-	OCFS_ASSERT(!(lock->l_flags & OCFS2_LOCK_ATTACHED));
-	lock->l_flags |= OCFS2_LOCK_LOCAL;
+	OCFS_ASSERT(!(lockres->l_flags & OCFS2_LOCK_ATTACHED));
+	lockres->l_flags |= OCFS2_LOCK_LOCAL;
 
-	status = ocfs2_lock_create(osb, lockres, lock, LKM_EXMODE, LKM_LOCAL);
-	lock->l_flags &= ~OCFS2_LOCK_LOCAL;
+	status = ocfs2_lock_create(osb, lockres, LKM_EXMODE, LKM_LOCAL);
+	lockres->l_flags &= ~OCFS2_LOCK_LOCAL;
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
 
 	lockres = &OCFS_I(inode)->ip_data_lockres;
-	lock = &lockres->lr_data;
-	OCFS_ASSERT(!(lock->l_flags & OCFS2_LOCK_ATTACHED));
-	lock->l_flags |= OCFS2_LOCK_LOCAL;
+	OCFS_ASSERT(!(lockres->l_flags & OCFS2_LOCK_ATTACHED));
+	lockres->l_flags |= OCFS2_LOCK_LOCAL;
 
-	status = ocfs2_lock_create(osb, lockres, lock, LKM_EXMODE, LKM_LOCAL);
-	lock->l_flags &= ~OCFS2_LOCK_LOCAL;
+	status = ocfs2_lock_create(osb, lockres, LKM_EXMODE, LKM_LOCAL);
+	lockres->l_flags &= ~OCFS2_LOCK_LOCAL;
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
@@ -752,18 +713,16 @@
 {
 	int status, level;
 	ocfs2_lock_res *lockres;
-	ocfs2_lock *lock;
 
 	OCFS_ASSERT(inode);
 
 	LOG_ENTRY();
 
 	lockres = &OCFS_I(inode)->ip_data_lockres;
-	lock = &lockres->lr_data;
 
 	level = write ? LKM_EXMODE : LKM_PRMODE;
 
-	status = ocfs2_cluster_lock(OCFS2_SB(inode->i_sb), lockres, lock, level);
+	status = ocfs2_cluster_lock(OCFS2_SB(inode->i_sb), lockres, level);
 	if (status < 0 && status != -EINTR)
 		LOG_ERROR_STATUS(status);
 
@@ -772,21 +731,21 @@
 }
 
 static void ocfs2_vote_on_unlock(ocfs_super *osb,
-				 ocfs2_lock *lock)
+				 ocfs2_lock_res *lockres)
 {
 	int kick = 0;
 
 	/* If we know that another node is waiting on our lock, kick
 	 * the vote thread * pre-emptively when we reach a release
 	 * condition. */
-	if (lock->l_flags & OCFS2_LOCK_BLOCKED) {
-		switch(lock->l_blocking) {
+	if (lockres->l_flags & OCFS2_LOCK_BLOCKED) {
+		switch(lockres->l_blocking) {
 		case LKM_EXMODE:
-			if (!lock->l_ex_holders && !lock->l_ro_holders)
+			if (!lockres->l_ex_holders && !lockres->l_ro_holders)
 				kick = 1;
 			break;
 		case LKM_PRMODE:
-			if (!lock->l_ex_holders)
+			if (!lockres->l_ex_holders)
 				kick = 1;
 			break;
 		default:
@@ -803,14 +762,13 @@
 {
 	int level;
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_data_lockres;
-	ocfs2_lock *lock = &lockres->lr_data;
 
 	level = write ? LKM_EXMODE : LKM_PRMODE;
 
-	spin_lock(&lockres->lr_lock);
-	ocfs2_dec_holders(lock, level);
-	ocfs2_vote_on_unlock(OCFS2_SB(inode->i_sb), lock);
-	spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	ocfs2_dec_holders(lockres, level);
+	ocfs2_vote_on_unlock(OCFS2_SB(inode->i_sb), lockres);
+	spin_unlock(&lockres->l_lock);
 }
 
 static inline int ocfs2_wait_on_recovery(ocfs_super *osb)
@@ -832,7 +790,7 @@
 {
 	ocfs_inode_private *oip = OCFS_I(inode);
 	ocfs2_lock_res *lockres = &oip->ip_meta_lockres;
-	ocfs2_meta_lvb *lvb     = (ocfs2_meta_lvb *) lockres->lr_meta.l_lksb.lvb;
+	ocfs2_meta_lvb *lvb     = (ocfs2_meta_lvb *) lockres->l_lksb.lvb;
 
 	lvb->lvb_iclusters = oip->ip_clusters;
 	lvb->lvb_iuid      = inode->i_uid;
@@ -849,7 +807,7 @@
 {
 	ocfs_inode_private *oip = OCFS_I(inode);
 	ocfs2_lock_res *lockres = &oip->ip_meta_lockres;
-	ocfs2_meta_lvb *lvb     = (ocfs2_meta_lvb *) lockres->lr_meta.l_lksb.lvb;
+	ocfs2_meta_lvb *lvb     = (ocfs2_meta_lvb *) lockres->l_lksb.lvb;
 
 	/* We're safe here without the lockres lock... */
 	spin_lock(&oip->ip_lock);
@@ -870,36 +828,35 @@
 static void ocfs2_reset_meta_lvb_values(struct inode *inode)
 {
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_meta_lockres;
-	ocfs2_lock *lock = &lockres->lr_meta;
-	ocfs2_meta_lvb *lvb = (ocfs2_meta_lvb *) lock->l_lksb.lvb;
+	ocfs2_meta_lvb *lvb = (ocfs2_meta_lvb *) lockres->l_lksb.lvb;
 	u32 i_clusters;
 
 	spin_lock(&OCFS_I(inode)->ip_lock);
 	i_clusters = OCFS_I(inode)->ip_clusters;
 	spin_unlock(&OCFS_I(inode)->ip_lock);
 
-	spin_lock(&lockres->lr_lock);
-	if (lock->l_level == LKM_EXMODE)
+	spin_lock(&lockres->l_lock);
+	if (lockres->l_level == LKM_EXMODE)
 		lvb->lvb_trunc_clusters = i_clusters;
-	spin_unlock(&lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 }
 
-static void __ocfs2_lvb_on_downconvert(ocfs2_lock *lock,
+static void __ocfs2_lvb_on_downconvert(ocfs2_lock_res *lockres,
 				       int new_level)
 {
-	ocfs2_lvb *lvb = (ocfs2_lvb *) lock->l_lksb.lvb;
+	ocfs2_lvb *lvb = (ocfs2_lvb *) lockres->l_lksb.lvb;
 
-	if (lock->l_level == LKM_EXMODE) {
+	if (lockres->l_level == LKM_EXMODE) {
 		lvb->lvb_seq++;
 		/* Overflow? */
 		if (!lvb->lvb_seq)
 			lvb->lvb_seq = 1;
-		lock->l_local_seq = lvb->lvb_seq;
+		lockres->l_local_seq = lvb->lvb_seq;
 		if (new_level == LKM_NLMODE)
-			lock->l_local_seq++;
-	} else if (lock->l_level == LKM_PRMODE) {
+			lockres->l_local_seq++;
+	} else if (lockres->l_level == LKM_PRMODE) {
 		if (lvb->lvb_seq)
-			lock->l_local_seq++;
+			lockres->l_local_seq++;
 	}
 }
 
@@ -910,37 +867,35 @@
 	int status = 0;
 	u32 trustable_clusters = 0;
 	ocfs2_lock_res *lockres;
-	ocfs2_lock *lock;
 	ocfs2_dinode *fe;
 
 	lockres = &OCFS_I(inode)->ip_meta_lockres;
-	lock = &lockres->lr_meta;
 
 refresh_check:
-	spin_lock(&lockres->lr_lock);
-	if (!(lock->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) {
-		spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) {
+		spin_unlock(&lockres->l_lock);
 		goto bail;
 	}
 
-	if (lock->l_flags & OCFS2_LOCK_REFRESHING) {
-		spin_unlock(&lockres->lr_lock);
+	if (lockres->l_flags & OCFS2_LOCK_REFRESHING) {
+		spin_unlock(&lockres->l_lock);
 		if (signal_pending(current)) {
 			status = -EINTR;
 			goto bail;
 		}
-		ocfs2_wait_on_refreshing_lock(lockres, lock);
+		ocfs2_wait_on_refreshing_lock(lockres);
 		goto refresh_check;
 	}
 
 	/* Ok, I'll be the one to refresh this lock. */
-	lock->l_flags |= OCFS2_LOCK_REFRESHING;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_flags |= OCFS2_LOCK_REFRESHING;
+	spin_unlock(&lockres->l_lock);
 
 	/* we don't want to use the LVB for bitmap files as the
 	 * used/set bit union is not currently sent over the wire. */
 	if (!(OCFS_I(inode)->ip_flags & OCFS_INODE_BITMAP) &&
-	    ocfs2_lvb_is_trustable(lock)) {
+	    ocfs2_lvb_is_trustable(lockres)) {
 		/* yay, fastpath! */
 		ocfs2_meta_lvb_get_values(lockres, &trustable_clusters);
 		ocfs2_refresh_inode_from_lvb(inode);
@@ -974,13 +929,13 @@
 
 	ocfs2_extent_map_trunc(inode, trustable_clusters);
 
-	ocfs2_set_local_seq_from_lvb(&OCFS_I(inode)->ip_meta_lockres.lr_meta);
+	ocfs2_set_local_seq_from_lvb(lockres);
 	ocfs2_reset_meta_lvb_values(inode);
 
-	spin_lock(&lockres->lr_lock);
-	lock->l_flags &= ~OCFS2_LOCK_REFRESHING;
-	lock->l_flags &= ~OCFS2_LOCK_NEEDS_REFRESH;
-	spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	lockres->l_flags &= ~OCFS2_LOCK_REFRESHING;
+	lockres->l_flags &= ~OCFS2_LOCK_NEEDS_REFRESH;
+	spin_unlock(&lockres->l_lock);
 
 	wake_up_all(&lockres->l_event);
 bail:
@@ -994,7 +949,6 @@
 {
 	int status, level;
 	ocfs2_lock_res *lockres;
-	ocfs2_lock *lock;
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 	struct buffer_head *bh = NULL;
 
@@ -1019,10 +973,9 @@
 	}
 
 	lockres = &OCFS_I(inode)->ip_meta_lockres;
-	lock = &(OCFS_I(inode)->ip_meta_lockres.lr_meta);
 	level = ex ? LKM_EXMODE : LKM_PRMODE;
 
-	status = ocfs2_cluster_lock(osb, lockres, lock, level);
+	status = ocfs2_cluster_lock(osb, lockres, level);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS(status);
@@ -1072,14 +1025,13 @@
 {
 	int level;
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_meta_lockres;
-	ocfs2_lock *lock = &lockres->lr_meta;
 
 	level = ex ? LKM_EXMODE : LKM_PRMODE;
 
-	spin_lock(&lockres->lr_lock);
-	ocfs2_dec_holders(lock, level);
-	ocfs2_vote_on_unlock(OCFS2_SB(inode->i_sb), lock);
-	spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	ocfs2_dec_holders(lockres, level);
+	ocfs2_vote_on_unlock(OCFS2_SB(inode->i_sb), lockres);
+	spin_unlock(&lockres->l_lock);
 }
 
 int ocfs2_dlm_init(ocfs_super *osb)
@@ -1161,71 +1113,69 @@
 
 static void ocfs2_unlock_ast_func(void *opaque, dlm_status status)
 {
-	ocfs2_lock *lock = opaque;
-	ocfs2_lock_res *lockres = lock->l_lockres;
+	ocfs2_lock_res *lockres = opaque;
 
 	if (status != DLM_NORMAL)
 		LOG_ERROR_ARGS("Dlm returns status %d\n", status);
 
-	spin_lock(&lockres->lr_lock);
-	switch(lock->l_unlock_action) {
+	spin_lock(&lockres->l_lock);
+	switch(lockres->l_unlock_action) {
 	case OCFS2_UNLOCK_CANCEL_CONVERT:
-		lock->l_action = OCFS2_AST_INVALID;
+		lockres->l_action = OCFS2_AST_INVALID;
 		break;
 	case OCFS2_UNLOCK_DROP_LOCK:
-		lock->l_level = LKM_IVMODE;
+		lockres->l_level = LKM_IVMODE;
 		break;
 	default:
 		BUG();
 	}
-	lock->l_unlock_action = OCFS2_UNLOCK_INVALID;
-	lock->l_flags &= ~OCFS2_LOCK_BUSY;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_unlock_action = OCFS2_UNLOCK_INVALID;
+	lockres->l_flags &= ~OCFS2_LOCK_BUSY;
+	spin_unlock(&lockres->l_lock);
 
 	wake_up_all(&lockres->l_event);
 }
 
 /* BEWARE: called with lockres lock, and always drops it. */
 static int __ocfs2_drop_lock(ocfs_super *osb,
-			     ocfs2_lock_res *lockres,
-			     ocfs2_lock *lock)
+			     ocfs2_lock_res *lockres)
 {
 	int ret = 0;
 	dlm_status status;
 
-	if (lock->l_flags & OCFS2_LOCK_BUSY)
+	if (lockres->l_flags & OCFS2_LOCK_BUSY)
 		printk("ocfs2: destroying busy lock!\n");
-	if (lock->l_flags & OCFS2_LOCK_BLOCKED)
+	if (lockres->l_flags & OCFS2_LOCK_BLOCKED)
 		printk("ocfs2: destroying blocked lock!\n");
 
-	if (!(lock->l_flags & OCFS2_LOCK_ATTACHED)) {
-		spin_unlock(&lockres->lr_lock);
+	if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) {
+		spin_unlock(&lockres->l_lock);
 		goto bail;
 	}
 
-	lock->l_flags &= ~OCFS2_LOCK_ATTACHED;
+	lockres->l_flags &= ~OCFS2_LOCK_ATTACHED;
 
 	/* make sure we never get here while waiting for an ast to
 	 * fire. */
-	OCFS_ASSERT(lock->l_action == OCFS2_AST_INVALID);
+	OCFS_ASSERT(lockres->l_action == OCFS2_AST_INVALID);
 
 	/* is this necessary? */
-	lock->l_flags |= OCFS2_LOCK_BUSY;
-	lock->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_flags |= OCFS2_LOCK_BUSY;
+	lockres->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK;
+	spin_unlock(&lockres->l_lock);
 
 	status = dlmunlock(osb->dlm,
-			   &lock->l_lksb,
+			   &lockres->l_lksb,
 			   LKM_VALBLK,
 			   ocfs2_unlock_ast_func,
-			   lock);
+			   lockres);
 	if (status != DLM_NORMAL) {
 		LOG_ERROR_ARGS("Dlm returns %d\n", status);
 		ret = -ENOENT;
 		goto bail;
 	}
 
-	ocfs2_wait_on_busy_lock(lockres, lock);
+	ocfs2_wait_on_busy_lock(lockres);
 	if (signal_pending(current)) {
 		printk("ocfs2_drop_lock: Signal caught!\n");
 		ret = -EINTR;
@@ -1239,12 +1189,10 @@
 {
 	int status, err;
 	ocfs2_lock_res *lockres;
-	ocfs2_lock *meta_lock;
 
 	lockres = &OCFS_I(inode)->ip_data_lockres;
-	spin_lock(&lockres->lr_lock);
-	err = __ocfs2_drop_lock(OCFS2_SB(inode->i_sb), lockres, 
-				&lockres->lr_data);
+	spin_lock(&lockres->l_lock);
+	err = __ocfs2_drop_lock(OCFS2_SB(inode->i_sb), lockres);
 	if (err < 0)
 		LOG_ERROR_STATUS(err);
 
@@ -1253,16 +1201,15 @@
 	/* the metadata lock requires a bit more work as we have an
 	 * LVB to worry about. */
 	lockres = &OCFS_I(inode)->ip_meta_lockres;
-	meta_lock = &lockres->lr_meta;
-	spin_lock(&lockres->lr_lock);
-	if (meta_lock->l_flags & OCFS2_LOCK_ATTACHED) {
-		if (meta_lock->l_level == LKM_EXMODE)
+
+	spin_lock(&lockres->l_lock);
+	if (lockres->l_flags & OCFS2_LOCK_ATTACHED) {
+		if (lockres->l_level == LKM_EXMODE)
 			__ocfs2_stuff_meta_lvb(inode);
 		/* fake an NLMODE downconvert for the lvb code. */
-		__ocfs2_lvb_on_downconvert(meta_lock, LKM_NLMODE);
+		__ocfs2_lvb_on_downconvert(lockres, LKM_NLMODE);
 	}
-	err = __ocfs2_drop_lock(OCFS2_SB(inode->i_sb), lockres,
-				meta_lock);
+	err = __ocfs2_drop_lock(OCFS2_SB(inode->i_sb), lockres);
 	if (err < 0)
 		LOG_ERROR_STATUS(err);
 	if (err < 0 && !status)
@@ -1288,35 +1235,34 @@
 /* called with the spinlock held, and WILL drop it. */
 static int __ocfs2_downconvert_lock(ocfs_super *osb,
 				    ocfs2_lock_res *lockres,
-				    ocfs2_lock *lock,
 				    int new_level,
 				    int lvb)
 {
 	int status, flags = LKM_CONVERT;
-	enum ocfs2_lock_type type = lock->l_type;
-	OCFS_ASSERT(lock->l_blocking > LKM_NLMODE);
-	OCFS_ASSERT(lock->l_level > new_level);
+	enum ocfs2_lock_type type = lockres->l_type;
+	OCFS_ASSERT(lockres->l_blocking > LKM_NLMODE);
+	OCFS_ASSERT(lockres->l_level > new_level);
 
-	lock->l_action = OCFS2_AST_DOWNCONVERT;
-	lock->l_requested = new_level;
-	lock->l_flags |= OCFS2_LOCK_BUSY;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_action = OCFS2_AST_DOWNCONVERT;
+	lockres->l_requested = new_level;
+	lockres->l_flags |= OCFS2_LOCK_BUSY;
+	spin_unlock(&lockres->l_lock);
 
 	if (lvb)
 		flags |= LKM_VALBLK;
 
 	status = dlmlock(osb->dlm,
 			 new_level,
-			 &lock->l_lksb,
+			 &lockres->l_lksb,
 			 flags,
-			 lock->l_name,
+			 lockres->l_name,
 			 ocfs2_lock_type_asts[type],
-			 lock,
+			 lockres,
 			 ocfs2_lock_type_basts[type]);
 	if (status != DLM_NORMAL) {
 		LOG_ERROR_ARGS("Dlm returns %d\n", status);
 		status = -ENOENT;
-		ocfs2_recover_from_dlm_error(lockres, lock, 1);
+		ocfs2_recover_from_dlm_error(lockres, 1);
 		goto bail;
 	}
 	status = 0;
@@ -1326,24 +1272,23 @@
 
 /* called with the spinlock held, and WILL drop it. */
 static int __ocfs2_cancel_convert(ocfs_super *osb,
-				  ocfs2_lock_res *lockres,
-				  ocfs2_lock *lock)
+				  ocfs2_lock_res *lockres)
 {
 	int status;
 
 	/* were we in a convert when we got the bast fire? */
-	OCFS_ASSERT(lock->l_action == OCFS2_AST_CONVERT ||
-		    lock->l_action == OCFS2_AST_DOWNCONVERT);
+	OCFS_ASSERT(lockres->l_action == OCFS2_AST_CONVERT ||
+		    lockres->l_action == OCFS2_AST_DOWNCONVERT);
 	/* set things up for the unlockast to know to just
 	 * clear out the ast_action and unset busy, etc. */
-	lock->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT;
-	spin_unlock(&lockres->lr_lock);
+	lockres->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT;
+	spin_unlock(&lockres->l_lock);
 
 	status = dlmunlock(osb->dlm,
-			   &lock->l_lksb,
+			   &lockres->l_lksb,
 			   LKM_CANCEL,
 			   ocfs2_unlock_ast_func,
-			   lock);
+			   lockres);
 	if (status == DLM_NORMAL)
 		status = 0;
 
@@ -1351,30 +1296,30 @@
 		/* If we got this, then the ast was fired
 		 * before we could cancel. We cleanup our
 		 * state, and restart the function. */
-		spin_lock(&lockres->lr_lock);
-		lock->l_unlock_action = OCFS2_UNLOCK_INVALID;
-		spin_unlock(&lockres->lr_lock);
+		spin_lock(&lockres->l_lock);
+		lockres->l_unlock_action = OCFS2_UNLOCK_INVALID;
+		spin_unlock(&lockres->l_lock);
 	} else {
 		LOG_ERROR_ARGS("Dlm returns %d\n", status);
 		status = -ENOENT;
-		ocfs2_recover_from_dlm_error(lockres, lock, 0);
+		ocfs2_recover_from_dlm_error(lockres, 0);
 	}
 
 	return status;
 }
 
 static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode,
-						  ocfs2_lock *lock,
+						  ocfs2_lock_res *lockres,
 						  int new_level)
 {
 	int ret;
 
 	OCFS_ASSERT(new_level == LKM_NLMODE || new_level == LKM_PRMODE);
 	if (new_level == LKM_PRMODE)
-		ret = !lock->l_ex_holders && 
+		ret = !lockres->l_ex_holders && 
 			ocfs_inode_fully_checkpointed(inode);
 	else /* Must be NLMODE we're converting to. */
-		ret = !lock->l_ro_holders && !lock->l_ex_holders &&
+		ret = !lockres->l_ro_holders && !lockres->l_ex_holders &&
 			ocfs_inode_fully_checkpointed(inode);
 
 	return ret;
@@ -1386,47 +1331,46 @@
 	int new_level;
 	int set_lvb = 0;
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_meta_lockres;
-	ocfs2_lock *lock = &lockres->lr_meta;
 
-	spin_lock(&lockres->lr_lock);
-	if (!(lock->l_flags & OCFS2_LOCK_BLOCKED)) {
-		spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) {
+		spin_unlock(&lockres->l_lock);
 		return 0;
 	}
 
-	OCFS_ASSERT(lock->l_level == LKM_EXMODE || 
-		    lock->l_level == LKM_PRMODE);
+	OCFS_ASSERT(lockres->l_level == LKM_EXMODE || 
+		    lockres->l_level == LKM_PRMODE);
 
-	if (lock->l_flags & OCFS2_LOCK_BUSY) {
+	if (lockres->l_flags & OCFS2_LOCK_BUSY) {
 		*requeue++;
-		if (lock->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
+		if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
 			/* If we're already trying to cancel a lock conversion
 			 * then just drop the spinlock and requeue ourselves
 			 * to check again later. */
-			spin_unlock(&lockres->lr_lock);
+			spin_unlock(&lockres->l_lock);
 			return 0;
 		}
 
 		return __ocfs2_cancel_convert(OCFS2_SB(inode->i_sb),
-					      lockres, lock);
+					      lockres);
 	}
 
-	new_level = ocfs2_highest_compat_lock_level(lock->l_blocking);
-	if (ocfs2_can_downconvert_meta_lock(inode, lock, new_level)) {
-		if (lock->l_level == LKM_EXMODE) {
+	new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking);
+	if (ocfs2_can_downconvert_meta_lock(inode, lockres, new_level)) {
+		if (lockres->l_level == LKM_EXMODE) {
 			__ocfs2_stuff_meta_lvb(inode);
 			set_lvb = 1;
 		}
-		__ocfs2_lvb_on_downconvert(lock, new_level);
+		__ocfs2_lvb_on_downconvert(lockres, new_level);
 		return __ocfs2_downconvert_lock(OCFS2_SB(inode->i_sb),
-						lockres, lock, new_level,
+						lockres, new_level,
 						set_lvb);
 	}
 	if (!ocfs_inode_fully_checkpointed(inode))
 		ocfs_start_checkpoint(OCFS2_SB(inode->i_sb));
 
 	*requeue++;
-	spin_unlock(&lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 
 	return 0;
 }
@@ -1435,47 +1379,46 @@
 				      int *requeue)
 {
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_data_lockres;
-	ocfs2_lock *lock = &lockres->lr_meta;
 	int blocking;
 	int new_level;
 
-	spin_lock(&lockres->lr_lock);
-	if (!(lock->l_flags & OCFS2_LOCK_BLOCKED)) {
-		spin_unlock(&lockres->lr_lock);
+	spin_lock(&lockres->l_lock);
+	if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) {
+		spin_unlock(&lockres->l_lock);
 		return 0;
 	}
 
-	OCFS_ASSERT(!(lock->l_flags & OCFS2_LOCK_BUSY));
+	OCFS_ASSERT(!(lockres->l_flags & OCFS2_LOCK_BUSY));
 
 recheck:
-	if (lock->l_flags & OCFS2_LOCK_BUSY) {
+	if (lockres->l_flags & OCFS2_LOCK_BUSY) {
 		*requeue++;
-		if (lock->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
+		if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
 			/* If we're already trying to cancel a lock conversion
 			 * then just drop the spinlock and requeue ourselves
 			 * to check again later. */
-			spin_unlock(&lockres->lr_lock);
+			spin_unlock(&lockres->l_lock);
 			return 0;
 		}
 
 		return __ocfs2_cancel_convert(OCFS2_SB(inode->i_sb),
-					      lockres, lock);
+					      lockres);
 	}
 
 	/* if we're blocking an exclusive and we have *anyone* in I/O,
 	 * then requeue. */
-	if ((lock->l_blocking == LKM_EXMODE) 
-	    && (lock->l_ex_holders || lock->l_ro_holders)) {
-		spin_unlock(&lockres->lr_lock);
+	if ((lockres->l_blocking == LKM_EXMODE) 
+	    && (lockres->l_ex_holders || lockres->l_ro_holders)) {
+		spin_unlock(&lockres->l_lock);
 		*requeue++;
 		return 0;
 	}
 
 	/* If it's a PR we're blocking, then only
 	 * requeue if we've got anyone doing write (ex) I/O */
-	if (lock->l_blocking == LKM_PRMODE &&
-	    lock->l_ex_holders) {
-		spin_unlock(&lockres->lr_lock);
+	if (lockres->l_blocking == LKM_PRMODE &&
+	    lockres->l_ex_holders) {
+		spin_unlock(&lockres->l_lock);
 		*requeue++;
 		return 0;
 	}
@@ -1484,8 +1427,8 @@
 	 * I/O is currently blocked. Save off a copy of what we're
 	 * blocking as it may change while we're not holding the spin
 	 * lock. */
-	blocking = lock->l_blocking;
-	spin_unlock(&lockres->lr_lock);
+	blocking = lockres->l_blocking;
+	spin_unlock(&lockres->l_lock);
 
 	/* 3 cases: EX blocking EX
 	 *	    EX blocking RO
@@ -1494,15 +1437,15 @@
 	if (blocking == LKM_EXMODE)
 		ocfs_truncate_inode_pages(inode, 0);
 
-	spin_lock(&lockres->lr_lock);
-	if (blocking != lock->l_blocking) {
+	spin_lock(&lockres->l_lock);
+	if (blocking != lockres->l_blocking) {
 		/* If this changed underneath us, then we can't drop
 		 * it just yet. */
 		goto recheck;
 	}
 
-	new_level = ocfs2_highest_compat_lock_level(lock->l_blocking);
-	return __ocfs2_downconvert_lock(OCFS2_SB(inode->i_sb), lockres, lock, 
+	new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking);
+	return __ocfs2_downconvert_lock(OCFS2_SB(inode->i_sb), lockres,
 					new_level, 0);
 }
 

Modified: branches/dlm-glue/src/dlmglue.h
===================================================================
--- branches/dlm-glue/src/dlmglue.h	2004-11-16 19:27:06 UTC (rev 1652)
+++ branches/dlm-glue/src/dlmglue.h	2004-11-16 21:25:05 UTC (rev 1653)
@@ -80,8 +80,9 @@
 int ocfs2_dlm_init(ocfs_super *osb);
 void ocfs2_dlm_shutdown(ocfs_super *osb);
 int ocfs2_find_slot(ocfs_super *osb);
-int ocfs2_lock_res_init(struct inode *inode,
-			ocfs2_lock_res *res);
+int ocfs2_lock_res_init(ocfs2_lock_res *res,
+			enum ocfs2_lock_type type,
+			struct inode *inode);
 void ocfs2_lock_res_free(ocfs2_lock_res *res);
 int ocfs2_create_new_inode_locks(struct inode *inode);
 int ocfs2_drop_inode_locks(struct inode *inode);
@@ -111,16 +112,15 @@
 						unsigned int trunc_clusters)
 {
 	ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_meta_lockres;
-	ocfs2_lock *lock = &lockres->lr_meta;
 	ocfs2_meta_lvb *lvb;
 
-	spin_lock(&lockres->lr_lock);
-	OCFS_ASSERT(lock->l_level == LKM_EXMODE);
+	spin_lock(&lockres->l_lock);
+	OCFS_ASSERT(lockres->l_level == LKM_EXMODE);
 
-	lvb = (ocfs2_meta_lvb *) lock->l_lksb.lvb;
+	lvb = (ocfs2_meta_lvb *) lockres->l_lksb.lvb;
 	if (lvb->lvb_trunc_clusters > trunc_clusters)
 		lvb->lvb_trunc_clusters = trunc_clusters;
-	spin_unlock(&lockres->lr_lock);
+	spin_unlock(&lockres->l_lock);
 }
 
 typedef struct _ocfs2_msg_hdr

Modified: branches/dlm-glue/src/inode.c
===================================================================
--- branches/dlm-glue/src/inode.c	2004-11-16 19:27:06 UTC (rev 1652)
+++ branches/dlm-glue/src/inode.c	2004-11-16 21:25:05 UTC (rev 1653)
@@ -426,12 +426,14 @@
 		    break;
 	}
 
-	status = ocfs2_lock_res_init(inode, &OCFS_I(inode)->ip_meta_lockres);
+	status = ocfs2_lock_res_init(&OCFS_I(inode)->ip_meta_lockres,
+				     OCFS_TYPE_META, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
-	status = ocfs2_lock_res_init(inode, &OCFS_I(inode)->ip_data_lockres);
+	status = ocfs2_lock_res_init(&OCFS_I(inode)->ip_data_lockres,
+				     OCFS_TYPE_DATA, inode);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 bail:

Modified: branches/dlm-glue/src/ocfs.h
===================================================================
--- branches/dlm-glue/src/ocfs.h	2004-11-16 19:27:06 UTC (rev 1652)
+++ branches/dlm-glue/src/ocfs.h	2004-11-16 21:25:05 UTC (rev 1653)
@@ -186,32 +186,13 @@
 	OCFS2_UNLOCK_DROP_LOCK,
 };
 
-struct _ocfs2_lock_res;
-
 enum ocfs2_lock_type {
 	OCFS_TYPE_META = 0,
 	OCFS_TYPE_DATA,
 	OCFS_NUM_LOCK_TYPES
 };
 
-typedef struct _ocfs2_lock {
-	struct _ocfs2_lock_res *l_lockres;
-	enum ocfs2_lock_type    l_type;
-	int                     l_flags;
-	char                   *l_name;
-	int                     l_level;
-	unsigned int            l_ro_holders;
-	unsigned int            l_ex_holders;
-	dlm_lockstatus          l_lksb;
-	u32                     l_local_seq;
-
-	/* used from AST/BAST funcs. */
-	enum ocfs2_ast_action   l_action;
-	enum ocfs2_unlock_action l_unlock_action;
-	int                     l_requested;
-	int                     l_blocking;
-} ocfs2_lock;
-
+/* ocfs2_lock_res->l_flags flags. */
 #define OCFS2_LOCK_ATTACHED      (0x00000001) /* have we initialized
 					       * the lvb */
 #define OCFS2_LOCK_BUSY          (0x00000002) /* we are currently in
@@ -224,13 +205,24 @@
 
 typedef struct _ocfs2_lock_res {
 	/* do i need this or can't i just use container_of? */
-	struct inode     *lr_inode;
-	/* actually, should probably just use ip_lock. */
-	spinlock_t        lr_lock;
+	struct inode            *l_inode;
+	spinlock_t               l_lock;
 
-	ocfs2_lock        lr_meta;
-	ocfs2_lock        lr_data;
+	enum ocfs2_lock_type     l_type;
+	int                      l_flags;
+	char                    *l_name;
+	int                      l_level;
+	unsigned int             l_ro_holders;
+	unsigned int             l_ex_holders;
+	dlm_lockstatus           l_lksb;
+	u32                      l_local_seq;
 
+	/* used from AST/BAST funcs. */
+	enum ocfs2_ast_action    l_action;
+	enum ocfs2_unlock_action l_unlock_action;
+	int                      l_requested;
+	int                      l_blocking;
+
 	wait_queue_head_t l_event;
 } ocfs2_lock_res;
 



More information about the Ocfs2-commits mailing list