fs: dlm: handle -EBUSY first in lock arg validation
authorAlexander Aring <aahringo@redhat.com>
Mon, 15 Aug 2022 19:43:15 +0000 (15:43 -0400)
committerDavid Teigland <teigland@redhat.com>
Tue, 23 Aug 2022 19:39:51 +0000 (14:39 -0500)
During lock arg validation, first check for -EBUSY cases, then for
-EINVAL cases. The -EINVAL checks look at lkb state variables
which are not stable when an lkb is busy and would cause an
-EBUSY result, e.g. lkb->lkb_grmode.

Cc: stable@vger.kernel.org
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/lock.c

index dac7eb75dba95c17a26ee13153dd076e7f6e1a50..c23413da40f5a59295ef6b1e4a3ab059a05a5b7a 100644 (file)
@@ -2864,17 +2864,9 @@ static int set_unlock_args(uint32_t flags, void *astarg, struct dlm_args *args)
 static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
                              struct dlm_args *args)
 {
-       int rv = -EINVAL;
+       int rv = -EBUSY;
 
        if (args->flags & DLM_LKF_CONVERT) {
-               if (lkb->lkb_flags & DLM_IFL_MSTCPY)
-                       goto out;
-
-               if (args->flags & DLM_LKF_QUECVT &&
-                   !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1])
-                       goto out;
-
-               rv = -EBUSY;
                if (lkb->lkb_status != DLM_LKSTS_GRANTED)
                        goto out;
 
@@ -2884,6 +2876,14 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 
                if (is_overlap(lkb))
                        goto out;
+
+               rv = -EINVAL;
+               if (lkb->lkb_flags & DLM_IFL_MSTCPY)
+                       goto out;
+
+               if (args->flags & DLM_LKF_QUECVT &&
+                   !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1])
+                       goto out;
        }
 
        lkb->lkb_exflags = args->flags;