Skip to content

Commit

Permalink
fs: dlm: handle -EBUSY first in lock arg validation
Browse files Browse the repository at this point in the history
commit 44637ca upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alexander Aring authored and gregkh committed Oct 21, 2022
1 parent 4b47e75 commit 335a725
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 335a725

Please sign in to comment.