Commit ea5b3a18 authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: Update dlmfs for new dlmlock() API

We just need to add a namelen field to the user_lock_res structure, and
update a few debug prints. Instead of updating all debug prints, I took the
opportunity to remove a few that are likely unnecessary these days.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 3384f3df
...@@ -102,10 +102,10 @@ static inline void user_recover_from_dlm_error(struct user_lock_res *lockres) ...@@ -102,10 +102,10 @@ static inline void user_recover_from_dlm_error(struct user_lock_res *lockres)
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
} }
#define user_log_dlm_error(_func, _stat, _lockres) do { \ #define user_log_dlm_error(_func, _stat, _lockres) do { \
mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \ mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \
"resource %s: %s\n", dlm_errname(_stat), _func, \ "resource %.*s: %s\n", dlm_errname(_stat), _func, \
_lockres->l_name, dlm_errmsg(_stat)); \ _lockres->l_namelen, _lockres->l_name, dlm_errmsg(_stat)); \
} while (0) } while (0)
/* WARNING: This function lives in a world where the only three lock /* WARNING: This function lives in a world where the only three lock
...@@ -127,21 +127,22 @@ static void user_ast(void *opaque) ...@@ -127,21 +127,22 @@ static void user_ast(void *opaque)
struct user_lock_res *lockres = opaque; struct user_lock_res *lockres = opaque;
struct dlm_lockstatus *lksb; struct dlm_lockstatus *lksb;
mlog(0, "AST fired for lockres %s\n", lockres->l_name); mlog(0, "AST fired for lockres %.*s\n", lockres->l_namelen,
lockres->l_name);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
lksb = &(lockres->l_lksb); lksb = &(lockres->l_lksb);
if (lksb->status != DLM_NORMAL) { if (lksb->status != DLM_NORMAL) {
mlog(ML_ERROR, "lksb status value of %u on lockres %s\n", mlog(ML_ERROR, "lksb status value of %u on lockres %.*s\n",
lksb->status, lockres->l_name); lksb->status, lockres->l_namelen, lockres->l_name);
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
return; return;
} }
mlog_bug_on_msg(lockres->l_requested == LKM_IVMODE, mlog_bug_on_msg(lockres->l_requested == LKM_IVMODE,
"Lockres %s, requested ivmode. flags 0x%x\n", "Lockres %.*s, requested ivmode. flags 0x%x\n",
lockres->l_name, lockres->l_flags); lockres->l_namelen, lockres->l_name, lockres->l_flags);
/* we're downconverting. */ /* we're downconverting. */
if (lockres->l_requested < lockres->l_level) { if (lockres->l_requested < lockres->l_level) {
...@@ -213,8 +214,8 @@ static void user_bast(void *opaque, int level) ...@@ -213,8 +214,8 @@ static void user_bast(void *opaque, int level)
{ {
struct user_lock_res *lockres = opaque; struct user_lock_res *lockres = opaque;
mlog(0, "Blocking AST fired for lockres %s. Blocking level %d\n", mlog(0, "Blocking AST fired for lockres %.*s. Blocking level %d\n",
lockres->l_name, level); lockres->l_namelen, lockres->l_name, level);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
lockres->l_flags |= USER_LOCK_BLOCKED; lockres->l_flags |= USER_LOCK_BLOCKED;
...@@ -231,7 +232,8 @@ static void user_unlock_ast(void *opaque, enum dlm_status status) ...@@ -231,7 +232,8 @@ static void user_unlock_ast(void *opaque, enum dlm_status status)
{ {
struct user_lock_res *lockres = opaque; struct user_lock_res *lockres = opaque;
mlog(0, "UNLOCK AST called on lock %s\n", lockres->l_name); mlog(0, "UNLOCK AST called on lock %.*s\n", lockres->l_namelen,
lockres->l_name);
if (status != DLM_NORMAL && status != DLM_CANCELGRANT) if (status != DLM_NORMAL && status != DLM_CANCELGRANT)
mlog(ML_ERROR, "Dlm returns status %d\n", status); mlog(ML_ERROR, "Dlm returns status %d\n", status);
...@@ -244,8 +246,6 @@ static void user_unlock_ast(void *opaque, enum dlm_status status) ...@@ -244,8 +246,6 @@ static void user_unlock_ast(void *opaque, enum dlm_status status)
&& !(lockres->l_flags & USER_LOCK_IN_CANCEL)) { && !(lockres->l_flags & USER_LOCK_IN_CANCEL)) {
lockres->l_level = LKM_IVMODE; lockres->l_level = LKM_IVMODE;
} else if (status == DLM_CANCELGRANT) { } else if (status == DLM_CANCELGRANT) {
mlog(0, "Lock %s, cancel fails, flags 0x%x\n",
lockres->l_name, lockres->l_flags);
/* We tried to cancel a convert request, but it was /* We tried to cancel a convert request, but it was
* already granted. Don't clear the busy flag - the * already granted. Don't clear the busy flag - the
* ast should've done this already. */ * ast should've done this already. */
...@@ -255,8 +255,6 @@ static void user_unlock_ast(void *opaque, enum dlm_status status) ...@@ -255,8 +255,6 @@ static void user_unlock_ast(void *opaque, enum dlm_status status)
} else { } else {
BUG_ON(!(lockres->l_flags & USER_LOCK_IN_CANCEL)); BUG_ON(!(lockres->l_flags & USER_LOCK_IN_CANCEL));
/* Cancel succeeded, we want to re-queue */ /* Cancel succeeded, we want to re-queue */
mlog(0, "Lock %s, cancel succeeds, flags 0x%x\n",
lockres->l_name, lockres->l_flags);
lockres->l_requested = LKM_IVMODE; /* cancel an lockres->l_requested = LKM_IVMODE; /* cancel an
* upconvert * upconvert
* request. */ * request. */
...@@ -287,13 +285,14 @@ static void user_dlm_unblock_lock(void *opaque) ...@@ -287,13 +285,14 @@ static void user_dlm_unblock_lock(void *opaque)
struct user_lock_res *lockres = (struct user_lock_res *) opaque; struct user_lock_res *lockres = (struct user_lock_res *) opaque;
struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
mlog(0, "processing lockres %s\n", lockres->l_name); mlog(0, "processing lockres %.*s\n", lockres->l_namelen,
lockres->l_name);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
mlog_bug_on_msg(!(lockres->l_flags & USER_LOCK_QUEUED), mlog_bug_on_msg(!(lockres->l_flags & USER_LOCK_QUEUED),
"Lockres %s, flags 0x%x\n", "Lockres %.*s, flags 0x%x\n",
lockres->l_name, lockres->l_flags); lockres->l_namelen, lockres->l_name, lockres->l_flags);
/* notice that we don't clear USER_LOCK_BLOCKED here. If it's /* notice that we don't clear USER_LOCK_BLOCKED here. If it's
* set, we want user_ast clear it. */ * set, we want user_ast clear it. */
...@@ -305,22 +304,16 @@ static void user_dlm_unblock_lock(void *opaque) ...@@ -305,22 +304,16 @@ static void user_dlm_unblock_lock(void *opaque)
* flag, and finally we might get another bast which re-queues * flag, and finally we might get another bast which re-queues
* us before our ast for the downconvert is called. */ * us before our ast for the downconvert is called. */
if (!(lockres->l_flags & USER_LOCK_BLOCKED)) { if (!(lockres->l_flags & USER_LOCK_BLOCKED)) {
mlog(0, "Lockres %s, flags 0x%x: queued but not blocking\n",
lockres->l_name, lockres->l_flags);
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
goto drop_ref; goto drop_ref;
} }
if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) { if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
mlog(0, "lock is in teardown so we do nothing\n");
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
goto drop_ref; goto drop_ref;
} }
if (lockres->l_flags & USER_LOCK_BUSY) { if (lockres->l_flags & USER_LOCK_BUSY) {
mlog(0, "Cancel lock %s, flags 0x%x\n",
lockres->l_name, lockres->l_flags);
if (lockres->l_flags & USER_LOCK_IN_CANCEL) { if (lockres->l_flags & USER_LOCK_IN_CANCEL) {
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
goto drop_ref; goto drop_ref;
...@@ -372,6 +365,7 @@ static void user_dlm_unblock_lock(void *opaque) ...@@ -372,6 +365,7 @@ static void user_dlm_unblock_lock(void *opaque)
&lockres->l_lksb, &lockres->l_lksb,
LKM_CONVERT|LKM_VALBLK, LKM_CONVERT|LKM_VALBLK,
lockres->l_name, lockres->l_name,
lockres->l_namelen,
user_ast, user_ast,
lockres, lockres,
user_bast); user_bast);
...@@ -420,16 +414,16 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres, ...@@ -420,16 +414,16 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres,
if (level != LKM_EXMODE && if (level != LKM_EXMODE &&
level != LKM_PRMODE) { level != LKM_PRMODE) {
mlog(ML_ERROR, "lockres %s: invalid request!\n", mlog(ML_ERROR, "lockres %.*s: invalid request!\n",
lockres->l_name); lockres->l_namelen, lockres->l_name);
status = -EINVAL; status = -EINVAL;
goto bail; goto bail;
} }
mlog(0, "lockres %s: asking for %s lock, passed flags = 0x%x\n", mlog(0, "lockres %.*s: asking for %s lock, passed flags = 0x%x\n",
lockres->l_name, lockres->l_namelen, lockres->l_name,
(level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE", (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE",
lkm_flags); lkm_flags);
again: again:
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -474,15 +468,13 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres, ...@@ -474,15 +468,13 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres,
BUG_ON(level == LKM_IVMODE); BUG_ON(level == LKM_IVMODE);
BUG_ON(level == LKM_NLMODE); BUG_ON(level == LKM_NLMODE);
mlog(0, "lock %s, get lock from %d to level = %d\n",
lockres->l_name, lockres->l_level, level);
/* call dlm_lock to upgrade lock now */ /* call dlm_lock to upgrade lock now */
status = dlmlock(dlm, status = dlmlock(dlm,
level, level,
&lockres->l_lksb, &lockres->l_lksb,
local_flags, local_flags,
lockres->l_name, lockres->l_name,
lockres->l_namelen,
user_ast, user_ast,
lockres, lockres,
user_bast); user_bast);
...@@ -498,9 +490,6 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres, ...@@ -498,9 +490,6 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres,
goto bail; goto bail;
} }
mlog(0, "lock %s, successfull return from dlmlock\n",
lockres->l_name);
user_wait_on_busy_lock(lockres); user_wait_on_busy_lock(lockres);
goto again; goto again;
} }
...@@ -508,9 +497,6 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres, ...@@ -508,9 +497,6 @@ int user_dlm_cluster_lock(struct user_lock_res *lockres,
user_dlm_inc_holders(lockres, level); user_dlm_inc_holders(lockres, level);
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
mlog(0, "lockres %s: Got %s lock!\n", lockres->l_name,
(level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE");
status = 0; status = 0;
bail: bail:
return status; return status;
...@@ -538,13 +524,11 @@ void user_dlm_cluster_unlock(struct user_lock_res *lockres, ...@@ -538,13 +524,11 @@ void user_dlm_cluster_unlock(struct user_lock_res *lockres,
{ {
if (level != LKM_EXMODE && if (level != LKM_EXMODE &&
level != LKM_PRMODE) { level != LKM_PRMODE) {
mlog(ML_ERROR, "lockres %s: invalid request!\n", lockres->l_name); mlog(ML_ERROR, "lockres %.*s: invalid request!\n",
lockres->l_namelen, lockres->l_name);
return; return;
} }
mlog(0, "lockres %s: dropping %s lock\n", lockres->l_name,
(level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE");
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
user_dlm_dec_holders(lockres, level); user_dlm_dec_holders(lockres, level);
__user_dlm_cond_queue_lockres(lockres); __user_dlm_cond_queue_lockres(lockres);
...@@ -602,6 +586,7 @@ void user_dlm_lock_res_init(struct user_lock_res *lockres, ...@@ -602,6 +586,7 @@ void user_dlm_lock_res_init(struct user_lock_res *lockres,
memcpy(lockres->l_name, memcpy(lockres->l_name,
dentry->d_name.name, dentry->d_name.name,
dentry->d_name.len); dentry->d_name.len);
lockres->l_namelen = dentry->d_name.len;
} }
int user_dlm_destroy_lock(struct user_lock_res *lockres) int user_dlm_destroy_lock(struct user_lock_res *lockres)
...@@ -609,11 +594,10 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres) ...@@ -609,11 +594,10 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
int status = -EBUSY; int status = -EBUSY;
struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
mlog(0, "asked to destroy %s\n", lockres->l_name); mlog(0, "asked to destroy %.*s\n", lockres->l_namelen, lockres->l_name);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) { if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
mlog(0, "Lock is already torn down\n");
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
return 0; return 0;
} }
...@@ -623,8 +607,6 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres) ...@@ -623,8 +607,6 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
while (lockres->l_flags & USER_LOCK_BUSY) { while (lockres->l_flags & USER_LOCK_BUSY) {
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
mlog(0, "lock %s is busy\n", lockres->l_name);
user_wait_on_busy_lock(lockres); user_wait_on_busy_lock(lockres);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
...@@ -632,14 +614,12 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres) ...@@ -632,14 +614,12 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
if (lockres->l_ro_holders || lockres->l_ex_holders) { if (lockres->l_ro_holders || lockres->l_ex_holders) {
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
mlog(0, "lock %s has holders\n", lockres->l_name);
goto bail; goto bail;
} }
status = 0; status = 0;
if (!(lockres->l_flags & USER_LOCK_ATTACHED)) { if (!(lockres->l_flags & USER_LOCK_ATTACHED)) {
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
mlog(0, "lock %s is not attached\n", lockres->l_name);
goto bail; goto bail;
} }
...@@ -647,7 +627,6 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres) ...@@ -647,7 +627,6 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
lockres->l_flags |= USER_LOCK_BUSY; lockres->l_flags |= USER_LOCK_BUSY;
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
mlog(0, "unlocking lockres %s\n", lockres->l_name);
status = dlmunlock(dlm, status = dlmunlock(dlm,
&lockres->l_lksb, &lockres->l_lksb,
LKM_VALBLK, LKM_VALBLK,
......
...@@ -53,6 +53,7 @@ struct user_lock_res { ...@@ -53,6 +53,7 @@ struct user_lock_res {
#define USER_DLM_LOCK_ID_MAX_LEN 32 #define USER_DLM_LOCK_ID_MAX_LEN 32
char l_name[USER_DLM_LOCK_ID_MAX_LEN]; char l_name[USER_DLM_LOCK_ID_MAX_LEN];
int l_namelen;
int l_level; int l_level;
unsigned int l_ro_holders; unsigned int l_ro_holders;
unsigned int l_ex_holders; unsigned int l_ex_holders;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment