[Ocfs2-commits] mfasheh commits r2464 - trunk/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Jul 8 16:46:52 CDT 2005
Author: mfasheh
Signed-off-by: zab
Date: 2005-07-08 16:46:51 -0500 (Fri, 08 Jul 2005)
New Revision: 2464
Modified:
trunk/fs/ocfs2/dlmglue.c
Log:
* handle getting DLM_CANCELGRANT in the unlockast function properly.
Signed-off-by: zab
Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c 2005-07-08 21:46:36 UTC (rev 2463)
+++ trunk/fs/ocfs2/dlmglue.c 2005-07-08 21:46:51 UTC (rev 2464)
@@ -1816,11 +1816,26 @@
mlog(0, "UNLOCK AST called on lock %s, action = %d\n", lockres->l_name,
lockres->l_unlock_action);
- if (status != DLM_NORMAL)
- mlog(ML_ERROR, "Dlm returns status %d for lock %s\n",
- status, lockres->l_name);
+ spin_lock(&lockres->l_lock);
+ /* We tried to cancel a convert request, but it was already
+ * granted. All we want to do here is clear our unlock
+ * state. The wake_up call done at the bottom is redundant
+ * (__ocfs2_cancel_convert doesn't sleep on this) but doesn't
+ * hurt anything anyway */
+ if (status == DLM_CANCELGRANT &&
+ lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
+ mlog(0, "Ok, got cancelgrant for %s\n", lockres->l_name);
+ goto complete_unlock;
+ }
- spin_lock(&lockres->l_lock);
+ if (status != DLM_NORMAL) {
+ mlog(ML_ERROR, "Dlm passes status %d for lock %s, "
+ "unlock_action %d\n", status, lockres->l_name,
+ lockres->l_unlock_action);
+ spin_unlock(&lockres->l_lock);
+ return;
+ }
+
switch(lockres->l_unlock_action) {
case OCFS2_UNLOCK_CANCEL_CONVERT:
lockres->l_action = OCFS2_AST_INVALID;
@@ -1831,6 +1846,7 @@
default:
BUG();
}
+complete_unlock:
lockres->l_unlock_action = OCFS2_UNLOCK_INVALID;
lockres_clear_flags(lockres, OCFS2_LOCK_BUSY);
spin_unlock(&lockres->l_lock);
@@ -1840,7 +1856,6 @@
mlog_exit_void();
}
-
/* BEWARE: called with lockres lock, and always drops it. Caller
* should not be calling us with a busy lock... */
static int __ocfs2_drop_lock(ocfs2_super *osb,
@@ -2090,6 +2105,23 @@
return ret;
}
+static int ocfs2_cancel_convert(ocfs2_super *osb,
+ struct ocfs2_lock_res *lockres)
+{
+ assert_spin_locked(&lockres->l_lock);
+
+ 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 allow the caller to
+ * requeue this lock. */
+ spin_unlock(&lockres->l_lock);
+ return 0;
+ }
+
+ /* this will drop the spinlock for us. */
+ return __ocfs2_cancel_convert(osb, lockres);
+}
+
static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode,
struct ocfs2_lock_res *lockres,
int new_level)
@@ -2121,12 +2153,11 @@
int new_level;
int set_lvb = 0;
int ret = 0;
- struct ocfs2_lock_res *lockres;
+ struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres;
+ ocfs2_super *osb = OCFS2_SB(inode->i_sb);
mlog_entry_void();
- lockres = &OCFS2_I(inode)->ip_meta_lockres;
-
spin_lock(&lockres->l_lock);
BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED));
@@ -2139,17 +2170,9 @@
if (lockres->l_flags & OCFS2_LOCK_BUSY) {
*requeue = 1;
- 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->l_lock);
- ret = 0;
- goto leave;
- }
-
- ret = __ocfs2_cancel_convert(OCFS2_SB(inode->i_sb),
- lockres);
+ ret = ocfs2_cancel_convert(osb, lockres);
+ if (ret < 0)
+ mlog_errno(ret);
goto leave;
}
@@ -2178,13 +2201,12 @@
"l_level=%d, l_blocking=%d, new_level=%d\n",
lockres->l_level, lockres->l_blocking,
new_level);
- ret = __ocfs2_downconvert_lock(OCFS2_SB(inode->i_sb),
- lockres, new_level,
+ ret = __ocfs2_downconvert_lock(osb, lockres, new_level,
set_lvb);
goto leave;
}
if (!ocfs2_inode_fully_checkpointed(inode))
- ocfs2_start_checkpoint(OCFS2_SB(inode->i_sb));
+ ocfs2_start_checkpoint(osb);
*requeue = 1;
spin_unlock(&lockres->l_lock);
@@ -2212,16 +2234,9 @@
recheck:
if (lockres->l_flags & OCFS2_LOCK_BUSY) {
*requeue = 1;
- 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->l_lock);
- ret = 0;
- goto leave;
- }
-
- ret = __ocfs2_cancel_convert(osb, lockres);
+ ret = ocfs2_cancel_convert(osb, lockres);
+ if (ret < 0)
+ mlog_errno(ret);
goto leave;
}
More information about the Ocfs2-commits
mailing list