dlm: rearrange async condition return
authorAlexander Aring <aahringo@redhat.com>
Mon, 4 Apr 2022 20:06:33 +0000 (16:06 -0400)
committerDavid Teigland <teigland@redhat.com>
Wed, 6 Apr 2022 19:02:05 +0000 (14:02 -0500)
This patch moves the return of FILE_LOCK_DEFERRED a little bit earlier
than checking afterwards again if the request was an asynchronous request.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/plock.c

index 4e60dd657cb6d30b161350eeae64045e034f6d45..757d9013788aac539d6cd1fb2933d5cceb607d20 100644 (file)
@@ -149,26 +149,25 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
                op_data->file   = file;
 
                op->data = op_data;
+
+               send_op(op);
+               rv = FILE_LOCK_DEFERRED;
+               goto out;
        } else {
                op->info.owner  = (__u64)(long) fl->fl_owner;
        }
 
        send_op(op);
 
-       if (!op->data) {
-               rv = wait_event_interruptible(recv_wq, (op->done != 0));
-               if (rv == -ERESTARTSYS) {
-                       log_debug(ls, "dlm_posix_lock: wait killed %llx",
-                                 (unsigned long long)number);
-                       spin_lock(&ops_lock);
-                       list_del(&op->list);
-                       spin_unlock(&ops_lock);
-                       dlm_release_plock_op(op);
-                       do_unlock_close(ls, number, file, fl);
-                       goto out;
-               }
-       } else {
-               rv = FILE_LOCK_DEFERRED;
+       rv = wait_event_interruptible(recv_wq, (op->done != 0));
+       if (rv == -ERESTARTSYS) {
+               log_debug(ls, "%s: wait killed %llx", __func__,
+                         (unsigned long long)number);
+               spin_lock(&ops_lock);
+               list_del(&op->list);
+               spin_unlock(&ops_lock);
+               dlm_release_plock_op(op);
+               do_unlock_close(ls, number, file, fl);
                goto out;
        }