Skip to content

Commit 0f869f7

Browse files
committed
Merge: dlm: fix recovery of middle conversions
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5792 JIRA: https://issues.redhat.com/browse/RHEL-67852 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm.git Conflicts: ms_stub rename to ms_local and some conversions to __le16 Signed-off-by: Alexander Aring <aahringo@redhat.com> Approved-by: David Teigland <teigland@redhat.com> Approved-by: Chris von Recklinghausen <crecklin@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 2746332 + 14ace0c commit 0f869f7

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

fs/dlm/lock.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,17 +5084,20 @@ static void recover_convert_waiter(struct dlm_ls *ls, struct dlm_lkb *lkb,
50845084
struct dlm_message *ms_stub)
50855085
{
50865086
if (middle_conversion(lkb)) {
5087+
log_rinfo(ls, "%s %x middle convert in progress", __func__,
5088+
lkb->lkb_id);
5089+
5090+
/* We sent this lock to the new master. The new master will
5091+
* tell us when it's granted. We no longer need a reply, so
5092+
* use a fake reply to put the lkb into the right state.
5093+
*/
50875094
hold_lkb(lkb);
50885095
memset(ms_stub, 0, sizeof(struct dlm_message));
50895096
ms_stub->m_flags = DLM_IFL_STUB_MS;
50905097
ms_stub->m_type = DLM_MSG_CONVERT_REPLY;
50915098
ms_stub->m_result = -EINPROGRESS;
50925099
ms_stub->m_header.h_nodeid = lkb->lkb_nodeid;
50935100
_receive_convert_reply(lkb, ms_stub);
5094-
5095-
/* Same special case as in receive_rcom_lock_args() */
5096-
lkb->lkb_grmode = DLM_LOCK_IV;
5097-
rsb_set_flag(lkb->lkb_resource, RSB_RECOVER_CONVERT);
50985101
unhold_lkb(lkb);
50995102

51005103
} else if (lkb->lkb_rqmode >= lkb->lkb_grmode) {
@@ -5618,10 +5621,11 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
56185621
The real granted mode of these converting locks cannot be determined
56195622
until all locks have been rebuilt on the rsb (recover_conversion) */
56205623

5621-
if (rl->rl_wait_type == cpu_to_le16(DLM_MSG_CONVERT) &&
5622-
middle_conversion(lkb)) {
5623-
rl->rl_status = DLM_LKSTS_CONVERT;
5624-
lkb->lkb_grmode = DLM_LOCK_IV;
5624+
if (rl->rl_status == DLM_LKSTS_CONVERT && middle_conversion(lkb)) {
5625+
/* We may need to adjust grmode depending on other granted locks. */
5626+
log_limit(ls, "%s %x middle convert gr %d rq %d remote %d %x",
5627+
__func__, lkb->lkb_id, lkb->lkb_grmode,
5628+
lkb->lkb_rqmode, lkb->lkb_nodeid, lkb->lkb_remid);
56255629
rsb_set_flag(r, RSB_RECOVER_CONVERT);
56265630
}
56275631

fs/dlm/recover.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -813,33 +813,42 @@ static void recover_lvb(struct dlm_rsb *r)
813813
}
814814

815815
/* All master rsb's flagged RECOVER_CONVERT need to be looked at. The locks
816-
converting PR->CW or CW->PR need to have their lkb_grmode set. */
816+
* converting PR->CW or CW->PR may need to have their lkb_grmode changed.
817+
*/
817818

818819
static void recover_conversion(struct dlm_rsb *r)
819820
{
820821
struct dlm_ls *ls = r->res_ls;
822+
uint32_t other_lkid = 0;
823+
int other_grmode = -1;
821824
struct dlm_lkb *lkb;
822-
int grmode = -1;
823825

824826
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
825827
if (lkb->lkb_grmode == DLM_LOCK_PR ||
826828
lkb->lkb_grmode == DLM_LOCK_CW) {
827-
grmode = lkb->lkb_grmode;
829+
other_grmode = lkb->lkb_grmode;
830+
other_lkid = lkb->lkb_id;
828831
break;
829832
}
830833
}
831834

835+
if (other_grmode == -1)
836+
return;
837+
832838
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
833-
if (lkb->lkb_grmode != DLM_LOCK_IV)
834-
continue;
835-
if (grmode == -1) {
836-
log_debug(ls, "recover_conversion %x set gr to rq %d",
837-
lkb->lkb_id, lkb->lkb_rqmode);
838-
lkb->lkb_grmode = lkb->lkb_rqmode;
839-
} else {
840-
log_debug(ls, "recover_conversion %x set gr %d",
841-
lkb->lkb_id, grmode);
842-
lkb->lkb_grmode = grmode;
839+
/* Lock recovery created incompatible granted modes, so
840+
* change the granted mode of the converting lock to
841+
* NL. The rqmode of the converting lock should be CW,
842+
* which means the converting lock should be granted at
843+
* the end of recovery.
844+
*/
845+
if (((lkb->lkb_grmode == DLM_LOCK_PR) && (other_grmode == DLM_LOCK_CW)) ||
846+
((lkb->lkb_grmode == DLM_LOCK_CW) && (other_grmode == DLM_LOCK_PR))) {
847+
log_limit(ls, "%s %x gr %d rq %d, remote %d %x, other_lkid %u, other gr %d, set gr=NL",
848+
__func__, lkb->lkb_id, lkb->lkb_grmode,
849+
lkb->lkb_rqmode, lkb->lkb_nodeid,
850+
lkb->lkb_remid, other_lkid, other_grmode);
851+
lkb->lkb_grmode = DLM_LOCK_NL;
843852
}
844853
}
845854
}

0 commit comments

Comments
 (0)