]> err.no Git - linux-2.6/blobdiff - fs/ocfs2/dlmglue.c
Merge branches 'x86/numa-fixes', 'x86/apic', 'x86/apm', 'x86/bitops', 'x86/build...
[linux-2.6] / fs / ocfs2 / dlmglue.c
index 295c47f7aba2829d3289e8e8d0f5135b24e54998..394d25a131a54d406b4fd9422639cde7c1d7c320 100644 (file)
@@ -880,13 +880,20 @@ static void ocfs2_locking_ast(void *opaque)
        struct ocfs2_lock_res *lockres = opaque;
        struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
        unsigned long flags;
+       int status;
 
        spin_lock_irqsave(&lockres->l_lock, flags);
 
-       if (ocfs2_dlm_lock_status(&lockres->l_lksb)) {
+       status = ocfs2_dlm_lock_status(&lockres->l_lksb);
+
+       if (status == -EAGAIN) {
+               lockres_clear_flags(lockres, OCFS2_LOCK_BUSY);
+               goto out;
+       }
+
+       if (status) {
                mlog(ML_ERROR, "lockres %s: lksb status value of %d!\n",
-                    lockres->l_name,
-                    ocfs2_dlm_lock_status(&lockres->l_lksb));
+                    lockres->l_name, status);
                spin_unlock_irqrestore(&lockres->l_lock, flags);
                return;
        }
@@ -909,7 +916,7 @@ static void ocfs2_locking_ast(void *opaque)
                     lockres->l_unlock_action);
                BUG();
        }
-
+out:
        /* set it to something invalid so if we get called again we
         * can catch it. */
        lockres->l_action = OCFS2_AST_INVALID;
@@ -1113,6 +1120,7 @@ static int ocfs2_cluster_lock(struct ocfs2_super *osb,
        int ret = 0; /* gcc doesn't realize wait = 1 guarantees ret is set */
        unsigned long flags;
        unsigned int gen;
+       int noqueue_attempted = 0;
 
        mlog_entry_void();
 
@@ -1157,6 +1165,13 @@ again:
        }
 
        if (level > lockres->l_level) {
+               if (noqueue_attempted > 0) {
+                       ret = -EAGAIN;
+                       goto unlock;
+               }
+               if (lkm_flags & DLM_LKF_NOQUEUE)
+                       noqueue_attempted = 1;
+
                if (lockres->l_action != OCFS2_AST_INVALID)
                        mlog(ML_ERROR, "lockres %s has action %u pending\n",
                             lockres->l_name, lockres->l_action);
@@ -1621,6 +1636,10 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
                 * to just bubble sucess back up to the user.
                 */
                ret = ocfs2_flock_handle_signal(lockres, level);
+       } else if (!ret && (level > lockres->l_level)) {
+               /* Trylock failed asynchronously */
+               BUG_ON(!trylock);
+               ret = -EAGAIN;
        }
 
 out:
@@ -2608,7 +2627,8 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
        }
 
        /* for now, uuid == domain */
-       status = ocfs2_cluster_connect(osb->uuid_str,
+       status = ocfs2_cluster_connect(osb->osb_cluster_stack,
+                                      osb->uuid_str,
                                       strlen(osb->uuid_str),
                                       ocfs2_do_node_down, osb,
                                       &conn);
@@ -2622,7 +2642,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
                mlog_errno(status);
                mlog(ML_ERROR,
                     "could not find this host's node number\n");
-               ocfs2_cluster_disconnect(conn);
+               ocfs2_cluster_disconnect(conn, 0);
                goto bail;
        }
 
@@ -2644,7 +2664,8 @@ bail:
        return status;
 }
 
-void ocfs2_dlm_shutdown(struct ocfs2_super *osb)
+void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
+                       int hangup_pending)
 {
        mlog_entry_void();
 
@@ -2664,7 +2685,7 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb)
        ocfs2_lock_res_free(&osb->osb_super_lockres);
        ocfs2_lock_res_free(&osb->osb_rename_lockres);
 
-       ocfs2_cluster_disconnect(osb->cconn);
+       ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
        osb->cconn = NULL;
 
        ocfs2_dlm_shutdown_debug(osb);
@@ -2784,8 +2805,7 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
        if (ret) {
                ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres);
                mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags);
-               /* XXX Need to abstract this */
-               dlm_print_one_lock(lockres->l_lksb.lksb_o2dlm.lockid);
+               ocfs2_dlm_dump_lksb(&lockres->l_lksb);
                BUG();
        }
        mlog(0, "lock %s, successfull return from ocfs2_dlm_unlock\n",
@@ -3348,16 +3368,11 @@ static struct ocfs2_locking_protocol lproto = {
        .lp_unlock_ast          = ocfs2_unlock_ast,
 };
 
-/* This interface isn't the final one, hence the less-than-perfect names */
-void dlmglue_init_stack(void)
+void ocfs2_set_locking_protocol(void)
 {
-       o2cb_get_stack(&lproto);
+       ocfs2_stack_glue_set_locking_protocol(&lproto);
 }
 
-void dlmglue_exit_stack(void)
-{
-       o2cb_put_stack();
-}
 
 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
                                       struct ocfs2_lock_res *lockres)