| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /****************************************************************************** |
|---|
| 2 | 3 | ******************************************************************************* |
|---|
| 3 | 4 | ** |
|---|
| 4 | 5 | ** Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved. |
|---|
| 5 | 6 | ** |
|---|
| 6 | | -** This copyrighted material is made available to anyone wishing to use, |
|---|
| 7 | | -** modify, copy, or redistribute it subject to the terms and conditions |
|---|
| 8 | | -** of the GNU General Public License v.2. |
|---|
| 9 | 7 | ** |
|---|
| 10 | 8 | ******************************************************************************* |
|---|
| 11 | 9 | ******************************************************************************/ |
|---|
| .. | .. |
|---|
| 1553 | 1551 | lkb->lkb_wait_type = 0; |
|---|
| 1554 | 1552 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; |
|---|
| 1555 | 1553 | lkb->lkb_wait_count--; |
|---|
| 1554 | + unhold_lkb(lkb); |
|---|
| 1556 | 1555 | goto out_del; |
|---|
| 1557 | 1556 | } |
|---|
| 1558 | 1557 | |
|---|
| .. | .. |
|---|
| 1579 | 1578 | log_error(ls, "remwait error %x reply %d wait_type %d overlap", |
|---|
| 1580 | 1579 | lkb->lkb_id, mstype, lkb->lkb_wait_type); |
|---|
| 1581 | 1580 | lkb->lkb_wait_count--; |
|---|
| 1581 | + unhold_lkb(lkb); |
|---|
| 1582 | 1582 | lkb->lkb_wait_type = 0; |
|---|
| 1583 | 1583 | } |
|---|
| 1584 | 1584 | |
|---|
| .. | .. |
|---|
| 2888 | 2888 | static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, |
|---|
| 2889 | 2889 | struct dlm_args *args) |
|---|
| 2890 | 2890 | { |
|---|
| 2891 | | - int rv = -EINVAL; |
|---|
| 2891 | + int rv = -EBUSY; |
|---|
| 2892 | 2892 | |
|---|
| 2893 | 2893 | if (args->flags & DLM_LKF_CONVERT) { |
|---|
| 2894 | | - if (lkb->lkb_flags & DLM_IFL_MSTCPY) |
|---|
| 2895 | | - goto out; |
|---|
| 2896 | | - |
|---|
| 2897 | | - if (args->flags & DLM_LKF_QUECVT && |
|---|
| 2898 | | - !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) |
|---|
| 2899 | | - goto out; |
|---|
| 2900 | | - |
|---|
| 2901 | | - rv = -EBUSY; |
|---|
| 2902 | 2894 | if (lkb->lkb_status != DLM_LKSTS_GRANTED) |
|---|
| 2903 | 2895 | goto out; |
|---|
| 2904 | 2896 | |
|---|
| .. | .. |
|---|
| 2906 | 2898 | goto out; |
|---|
| 2907 | 2899 | |
|---|
| 2908 | 2900 | if (is_overlap(lkb)) |
|---|
| 2901 | + goto out; |
|---|
| 2902 | + |
|---|
| 2903 | + rv = -EINVAL; |
|---|
| 2904 | + if (lkb->lkb_flags & DLM_IFL_MSTCPY) |
|---|
| 2905 | + goto out; |
|---|
| 2906 | + |
|---|
| 2907 | + if (args->flags & DLM_LKF_QUECVT && |
|---|
| 2908 | + !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) |
|---|
| 2909 | 2909 | goto out; |
|---|
| 2910 | 2910 | } |
|---|
| 2911 | 2911 | |
|---|
| .. | .. |
|---|
| 4067 | 4067 | rv = _create_message(ls, sizeof(struct dlm_message) + len, |
|---|
| 4068 | 4068 | dir_nodeid, DLM_MSG_REMOVE, &ms, &mh); |
|---|
| 4069 | 4069 | if (rv) |
|---|
| 4070 | | - return; |
|---|
| 4070 | + goto out; |
|---|
| 4071 | 4071 | |
|---|
| 4072 | 4072 | memcpy(ms->m_extra, name, len); |
|---|
| 4073 | 4073 | ms->m_hash = hash; |
|---|
| 4074 | 4074 | |
|---|
| 4075 | 4075 | send_message(mh, ms); |
|---|
| 4076 | 4076 | |
|---|
| 4077 | +out: |
|---|
| 4077 | 4078 | spin_lock(&ls->ls_remove_spin); |
|---|
| 4078 | 4079 | ls->ls_remove_len = 0; |
|---|
| 4079 | 4080 | memset(ls->ls_remove_name, 0, DLM_RESNAME_MAXLEN); |
|---|
| .. | .. |
|---|
| 5314 | 5315 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_UNLOCK; |
|---|
| 5315 | 5316 | lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; |
|---|
| 5316 | 5317 | lkb->lkb_wait_type = 0; |
|---|
| 5317 | | - lkb->lkb_wait_count = 0; |
|---|
| 5318 | + /* drop all wait_count references we still |
|---|
| 5319 | + * hold a reference for this iteration. |
|---|
| 5320 | + */ |
|---|
| 5321 | + while (lkb->lkb_wait_count) { |
|---|
| 5322 | + lkb->lkb_wait_count--; |
|---|
| 5323 | + unhold_lkb(lkb); |
|---|
| 5324 | + } |
|---|
| 5318 | 5325 | mutex_lock(&ls->ls_waiters_mutex); |
|---|
| 5319 | 5326 | list_del_init(&lkb->lkb_wait_reply); |
|---|
| 5320 | 5327 | mutex_unlock(&ls->ls_waiters_mutex); |
|---|
| 5321 | | - unhold_lkb(lkb); /* for waiters list */ |
|---|
| 5322 | 5328 | |
|---|
| 5323 | 5329 | if (oc || ou) { |
|---|
| 5324 | 5330 | /* do an unlock or cancel instead of resending */ |
|---|
| .. | .. |
|---|
| 5828 | 5834 | break; |
|---|
| 5829 | 5835 | case -EAGAIN: |
|---|
| 5830 | 5836 | error = 0; |
|---|
| 5831 | | - /* fall through */ |
|---|
| 5837 | + fallthrough; |
|---|
| 5832 | 5838 | default: |
|---|
| 5833 | 5839 | __put_lkb(ls, lkb); |
|---|
| 5834 | 5840 | goto out; |
|---|