[Ocfs2-commits] mfasheh commits r2497 - in
branches/ocfs2-1.0/fs/ocfs2: . dlm
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Aug 3 20:36:11 CDT 2005
Author: mfasheh
Signed-off-by: manish
Date: 2005-08-03 20:36:09 -0500 (Wed, 03 Aug 2005)
New Revision: 2497
Modified:
branches/ocfs2-1.0/fs/ocfs2/dlm/dlmapi.h
branches/ocfs2-1.0/fs/ocfs2/dlm/dlmast.c
branches/ocfs2-1.0/fs/ocfs2/dlm/dlmconvert.c
branches/ocfs2-1.0/fs/ocfs2/dlm/dlmlock.c
branches/ocfs2-1.0/fs/ocfs2/dlm/dlmunlock.c
branches/ocfs2-1.0/fs/ocfs2/dlmglue.c
Log:
* Backport svn r2487 and r2496 from trunk into the 1.0 branch:
* better error reporting in the dlm. This should help us track dlm
issues more easily.
* the generic_bast function was clearing OCFS2_LOCK_NEEDS_REFRESH when it is
actually the generic_ast function which we want clearing that.
* after fixing the above, ocfs2_inode_bast_func can trivially call into
ocfs2_generic_bast_func so have it do so.
Signed-off-by: manish
Modified: branches/ocfs2-1.0/fs/ocfs2/dlm/dlmapi.h
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlm/dlmapi.h 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlm/dlmapi.h 2005-08-04 01:36:09 UTC (rev 2497)
@@ -84,8 +84,17 @@
/* for pretty-printing dlm_status error names */
const char *dlm_errname(enum dlm_status err);
+/* Eventually the DLM will use standard errno values, but in the
+ * meantime this lets us track dlm errors as they bubble up. When we
+ * bring its error reporting into line with the rest of the stack,
+ * these can just be replaced with calls to mlog_errno. */
+#define dlm_error(st) do { \
+ if ((st) != DLM_RECOVERING && \
+ (st) != DLM_MIGRATING && \
+ (st) != DLM_FORWARD) \
+ mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st))); \
+} while (0)
-
#define DLM_LKSB_UNUSED1 0x01
#define DLM_LKSB_PUT_LVB 0x02
#define DLM_LKSB_GET_LVB 0x04
Modified: branches/ocfs2-1.0/fs/ocfs2/dlm/dlmast.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlm/dlmast.c 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlm/dlmast.c 2005-08-04 01:36:09 UTC (rev 2497)
@@ -256,8 +256,10 @@
u64 cookie;
u32 flags;
- if (!dlm_grab(dlm))
+ if (!dlm_grab(dlm)) {
+ dlm_error(DLM_REJECTED);
return DLM_REJECTED;
+ }
mlog_bug_on_msg(!dlm_domain_fully_joined(dlm),
"Domain %s not fully joined!\n", dlm->name);
Modified: branches/ocfs2-1.0/fs/ocfs2/dlm/dlmconvert.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlm/dlmconvert.c 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlm/dlmconvert.c 2005-08-04 01:36:09 UTC (rev 2497)
@@ -94,6 +94,8 @@
res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
spin_unlock(&res->spinlock);
wake_up(&res->wq);
+ if (status != DLM_NORMAL && status != DLM_NOTQUEUED)
+ dlm_error(status);
/* either queue the ast or release it */
if (call_ast)
@@ -315,8 +317,11 @@
res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
lock->convert_pending = 0;
/* if it failed, move it back to granted queue */
- if (status != DLM_NORMAL)
+ if (status != DLM_NORMAL) {
+ if (status != DLM_NOTQUEUED)
+ dlm_error(status);
dlm_revert_pending_convert(res, lock);
+ }
bail:
spin_unlock(&res->spinlock);
@@ -380,7 +385,8 @@
} else if (ret == DLM_FORWARD) {
mlog(0, "node %u returned DLM_FORWARD from convert "
"message!\n", res->owner);
- }
+ } else if (ret != DLM_NORMAL)
+ dlm_error(ret);
} else {
mlog_errno(tmpret);
if (dlm_is_host_down(tmpret)) {
@@ -416,8 +422,10 @@
u32 flags;
int call_ast = 0, kick_thread = 0;
- if (!dlm_grab(dlm))
+ if (!dlm_grab(dlm)) {
+ dlm_error(DLM_REJECTED);
return DLM_REJECTED;
+ }
mlog_bug_on_msg(!dlm_domain_fully_joined(dlm),
"Domain %s not fully joined!\n", dlm->name);
@@ -426,6 +434,7 @@
if (cnv->namelen > DLM_LOCKID_NAME_MAX) {
status = DLM_IVBUFLEN;
+ dlm_error(status);
goto leave;
}
@@ -443,8 +452,10 @@
status = DLM_IVLOCKID;
res = dlm_lookup_lockres(dlm, cnv->name, cnv->namelen);
- if (!res)
+ if (!res) {
+ dlm_error(status);
goto leave;
+ }
spin_lock(&res->spinlock);
list_for_each(iter, &res->granted) {
@@ -457,8 +468,11 @@
lock = NULL;
}
spin_unlock(&res->spinlock);
- if (!lock)
+ if (!lock) {
+ status = DLM_IVLOCKID;
+ dlm_error(status);
goto leave;
+ }
/* found the lock */
lksb = lock->lksb;
@@ -485,9 +499,11 @@
}
spin_unlock(&res->spinlock);
-
- if (status != DLM_NORMAL)
+ if (status != DLM_NORMAL) {
+ if (status != DLM_NOTQUEUED)
+ dlm_error(status);
lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB);
+ }
leave:
if (!lock)
Modified: branches/ocfs2-1.0/fs/ocfs2/dlm/dlmlock.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlm/dlmlock.c 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlm/dlmlock.c 2005-08-04 01:36:09 UTC (rev 2497)
@@ -117,6 +117,7 @@
lock->ml.node != dlm->node_num) {
/* erf. state changed after lock was dropped. */
spin_unlock(&res->spinlock);
+ dlm_error(status);
return status;
}
__dlm_wait_on_lockres(res);
@@ -214,6 +215,7 @@
res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
lock->lock_pending = 0;
if (status != DLM_NORMAL) {
+ dlm_error(status);
dlm_revert_pending_lock(res, lock);
dlm_lock_put(lock);
}
@@ -413,15 +415,19 @@
namelen = create->namelen;
status = DLM_IVBUFLEN;
- if (namelen > DLM_LOCKID_NAME_MAX)
+ if (namelen > DLM_LOCKID_NAME_MAX) {
+ dlm_error(status);
goto leave;
+ }
status = DLM_SYSERR;
newlock = dlm_new_lock(create->requested_type,
create->node_idx,
create->cookie, NULL);
- if (!newlock)
+ if (!newlock) {
+ dlm_error(status);
goto leave;
+ }
lksb = newlock->lksb;
@@ -432,8 +438,10 @@
status = DLM_IVLOCKID;
res = dlm_lookup_lockres(dlm, name, namelen);
- if (!res)
+ if (!res) {
+ dlm_error(status);
goto leave;
+ }
spin_lock(&res->spinlock);
status = __dlm_lockres_state_to_status(res);
@@ -491,21 +499,28 @@
/* yes this function is a mess.
* TODO: clean this up. lots of common code in the
* lock and convert paths, especially in the retry blocks */
- if (!lksb)
+ if (!lksb) {
+ dlm_error(DLM_BADARGS);
return DLM_BADARGS;
+ }
status = DLM_BADPARAM;
- if (mode != LKM_EXMODE && mode != LKM_PRMODE && mode != LKM_NLMODE)
+ if (mode != LKM_EXMODE && mode != LKM_PRMODE && mode != LKM_NLMODE) {
+ dlm_error(status);
goto error;
+ }
- if (flags & ~LKM_VALID_FLAGS)
+ if (flags & ~LKM_VALID_FLAGS) {
+ dlm_error(status);
goto error;
+ }
convert = (flags & LKM_CONVERT);
recovery = (flags & LKM_RECOVERY);
if (recovery &&
(!dlm_is_recovery_lock(name, strlen(name)) || convert) ) {
+ dlm_error(status);
goto error;
}
if (convert && (flags & LKM_LOCAL)) {
@@ -570,17 +585,23 @@
/* LOCK request */
status = DLM_BADARGS;
- if (!name)
+ if (!name) {
+ dlm_error(status);
goto error;
+ }
status = DLM_IVBUFLEN;
- if (strlen(name) > DLM_LOCKID_NAME_MAX || strlen(name) < 1)
+ if (strlen(name) > DLM_LOCKID_NAME_MAX || strlen(name) < 1) {
+ dlm_error(status);
goto error;
+ }
dlm_get_next_cookie(dlm->node_num, &tmpcookie);
lock = dlm_new_lock(mode, dlm->node_num, tmpcookie, lksb);
- if (!lock)
+ if (!lock) {
+ dlm_error(status);
goto error;
+ }
if (!recovery)
dlm_wait_for_recovery(dlm);
@@ -589,6 +610,7 @@
res = dlm_get_lock_resource(dlm, name, flags);
if (!res) {
status = DLM_IVLOCKID;
+ dlm_error(status);
goto error;
}
@@ -630,6 +652,7 @@
if (status != DLM_NORMAL) {
lock->lksb->flags &= ~DLM_LKSB_GET_LVB;
+ dlm_error(status);
goto error;
}
}
Modified: branches/ocfs2-1.0/fs/ocfs2/dlm/dlmunlock.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlm/dlmunlock.c 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlm/dlmunlock.c 2005-08-04 01:36:09 UTC (rev 2497)
@@ -548,6 +548,7 @@
if (!dlm_lock_on_list(&res->granted, lock)) {
lksb->status = DLM_DENIED;
status = DLM_DENIED;
+ dlm_error(status);
*actions = 0;
} else {
/* unlock granted lock */
@@ -574,19 +575,25 @@
mlog_entry_void();
- if (!lksb)
+ if (!lksb) {
+ dlm_error(DLM_BADARGS);
return DLM_BADARGS;
+ }
- if (flags & ~(LKM_CANCEL | LKM_VALBLK | LKM_INVVALBLK))
+ if (flags & ~(LKM_CANCEL | LKM_VALBLK | LKM_INVVALBLK)) {
+ dlm_error(DLM_BADPARAM);
return DLM_BADPARAM;
+ }
if ((flags & (LKM_VALBLK | LKM_CANCEL)) == (LKM_VALBLK | LKM_CANCEL)) {
mlog(0, "VALBLK given with CANCEL: ignoring VALBLK\n");
flags &= ~LKM_VALBLK;
}
- if (!lksb->lockid || !lksb->lockid->lockres)
+ if (!lksb->lockid || !lksb->lockid->lockres) {
+ dlm_error(DLM_BADPARAM);
return DLM_BADPARAM;
+ }
lock = lksb->lockid;
BUG_ON(!lock);
@@ -653,7 +660,8 @@
if (status == DLM_NORMAL) {
mlog(0, "kicking the thread\n");
dlm_kick_thread(dlm, res);
- }
+ } else
+ dlm_error(status);
dlm_lockres_calc_usage(dlm, res);
dlm_lockres_put(res);
Modified: branches/ocfs2-1.0/fs/ocfs2/dlmglue.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlmglue.c 2005-08-04 01:12:16 UTC (rev 2496)
+++ branches/ocfs2-1.0/fs/ocfs2/dlmglue.c 2005-08-04 01:36:09 UTC (rev 2497)
@@ -622,12 +622,33 @@
return needs_downconvert;
}
+static void ocfs2_generic_bast_func(ocfs2_super *osb,
+ struct ocfs2_lock_res *lockres,
+ int level)
+{
+ int needs_downconvert;
+
+ mlog_entry_void();
+
+ BUG_ON(level <= LKM_NLMODE);
+
+ spin_lock(&lockres->l_lock);
+ needs_downconvert = ocfs2_generic_handle_bast(lockres, level);
+ if (needs_downconvert)
+ ocfs2_schedule_blocked_lock(osb, lockres);
+ spin_unlock(&lockres->l_lock);
+
+ ocfs2_kick_vote_thread(osb);
+
+ wake_up(&lockres->l_event);
+ mlog_exit_void();
+}
+
static void ocfs2_inode_bast_func(void *opaque, int level)
{
struct ocfs2_lock_res *lockres = opaque;
struct inode *inode;
ocfs2_super *osb;
- int needs_downconvert;
mlog_entry_void();
@@ -641,23 +662,13 @@
lockres->l_level,
(lockres->l_type == OCFS2_LOCK_TYPE_META) ? "Meta" : "Data");
- BUG_ON(level <= LKM_NLMODE);
+ ocfs2_generic_bast_func(osb, lockres, level);
- spin_lock(&lockres->l_lock);
-
- needs_downconvert = ocfs2_generic_handle_bast(lockres, level);
- if (needs_downconvert)
- ocfs2_schedule_blocked_lock(osb, lockres);
-
- spin_unlock(&lockres->l_lock);
-
- ocfs2_kick_vote_thread(osb);
- wake_up(&lockres->l_event);
-
mlog_exit_void();
}
-static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres)
+static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres,
+ int ignore_refresh)
{
struct dlm_lockstatus *lksb = &lockres->l_lksb;
@@ -684,6 +695,9 @@
BUG();
}
+ if (ignore_refresh)
+ lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH);
+
/* set it to something invalid so if we get called again we
* can catch it. */
lockres->l_action = OCFS2_AST_INVALID;
@@ -692,31 +706,6 @@
wake_up(&lockres->l_event);
}
-static void ocfs2_generic_bast_func(ocfs2_super *osb,
- struct ocfs2_lock_res *lockres,
- int level,
- int ignore_refresh)
-{
- int needs_downconvert;
-
- mlog_entry_void();
-
- spin_lock(&lockres->l_lock);
- needs_downconvert = ocfs2_generic_handle_bast(lockres, level);
- if (needs_downconvert)
- ocfs2_schedule_blocked_lock(osb, lockres);
-
- if (ignore_refresh)
- lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH);
-
- spin_unlock(&lockres->l_lock);
-
- ocfs2_kick_vote_thread(osb);
-
- wake_up(&lockres->l_event);
- mlog_exit_void();
-}
-
static void ocfs2_super_ast_func(void *opaque)
{
struct ocfs2_lock_res *lockres = opaque;
@@ -725,7 +714,7 @@
mlog(0, "Superblock AST fired\n");
BUG_ON(!ocfs2_is_super_lock(lockres));
- ocfs2_generic_ast_func(lockres);
+ ocfs2_generic_ast_func(lockres, 0);
mlog_exit_void();
}
@@ -741,7 +730,7 @@
BUG_ON(!ocfs2_is_super_lock(lockres));
osb = ocfs2_lock_res_super(lockres);
- ocfs2_generic_bast_func(osb, lockres, level, 0);
+ ocfs2_generic_bast_func(osb, lockres, level);
mlog_exit_void();
}
@@ -756,7 +745,7 @@
BUG_ON(!ocfs2_is_rename_lock(lockres));
- ocfs2_generic_ast_func(lockres);
+ ocfs2_generic_ast_func(lockres, 1);
mlog_exit_void();
}
@@ -774,7 +763,7 @@
BUG_ON(!ocfs2_is_rename_lock(lockres));
osb = ocfs2_lock_res_super(lockres);
- ocfs2_generic_bast_func(osb, lockres, level, 1);
+ ocfs2_generic_bast_func(osb, lockres, level);
mlog_exit_void();
}
More information about the Ocfs2-commits
mailing list