dlm: replace usage of found with dedicated list iterator variable
[ Upstream commit dc1acd5c94699389a9ed023e94dd860c846ea1f6 ] To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com> Stable-dep-of: 57e2c2f2d94c ("fs: dlm: fix mismatch of plock results from userspace") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
7b44c1f383
commit
e850cd32df
@@ -732,10 +732,9 @@ void dlm_recovered_lock(struct dlm_rsb *r)
|
||||
|
||||
static void recover_lvb(struct dlm_rsb *r)
|
||||
{
|
||||
struct dlm_lkb *lkb, *high_lkb = NULL;
|
||||
struct dlm_lkb *big_lkb = NULL, *iter, *high_lkb = NULL;
|
||||
uint32_t high_seq = 0;
|
||||
int lock_lvb_exists = 0;
|
||||
int big_lock_exists = 0;
|
||||
int lvblen = r->res_ls->ls_lvblen;
|
||||
|
||||
if (!rsb_flag(r, RSB_NEW_MASTER2) &&
|
||||
@@ -751,37 +750,37 @@ static void recover_lvb(struct dlm_rsb *r)
|
||||
/* we are the new master, so figure out if VALNOTVALID should
|
||||
be set, and set the rsb lvb from the best lkb available. */
|
||||
|
||||
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
|
||||
if (!(lkb->lkb_exflags & DLM_LKF_VALBLK))
|
||||
list_for_each_entry(iter, &r->res_grantqueue, lkb_statequeue) {
|
||||
if (!(iter->lkb_exflags & DLM_LKF_VALBLK))
|
||||
continue;
|
||||
|
||||
lock_lvb_exists = 1;
|
||||
|
||||
if (lkb->lkb_grmode > DLM_LOCK_CR) {
|
||||
big_lock_exists = 1;
|
||||
if (iter->lkb_grmode > DLM_LOCK_CR) {
|
||||
big_lkb = iter;
|
||||
goto setflag;
|
||||
}
|
||||
|
||||
if (((int)lkb->lkb_lvbseq - (int)high_seq) >= 0) {
|
||||
high_lkb = lkb;
|
||||
high_seq = lkb->lkb_lvbseq;
|
||||
if (((int)iter->lkb_lvbseq - (int)high_seq) >= 0) {
|
||||
high_lkb = iter;
|
||||
high_seq = iter->lkb_lvbseq;
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
|
||||
if (!(lkb->lkb_exflags & DLM_LKF_VALBLK))
|
||||
list_for_each_entry(iter, &r->res_convertqueue, lkb_statequeue) {
|
||||
if (!(iter->lkb_exflags & DLM_LKF_VALBLK))
|
||||
continue;
|
||||
|
||||
lock_lvb_exists = 1;
|
||||
|
||||
if (lkb->lkb_grmode > DLM_LOCK_CR) {
|
||||
big_lock_exists = 1;
|
||||
if (iter->lkb_grmode > DLM_LOCK_CR) {
|
||||
big_lkb = iter;
|
||||
goto setflag;
|
||||
}
|
||||
|
||||
if (((int)lkb->lkb_lvbseq - (int)high_seq) >= 0) {
|
||||
high_lkb = lkb;
|
||||
high_seq = lkb->lkb_lvbseq;
|
||||
if (((int)iter->lkb_lvbseq - (int)high_seq) >= 0) {
|
||||
high_lkb = iter;
|
||||
high_seq = iter->lkb_lvbseq;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,7 +789,7 @@ static void recover_lvb(struct dlm_rsb *r)
|
||||
goto out;
|
||||
|
||||
/* lvb is invalidated if only NL/CR locks remain */
|
||||
if (!big_lock_exists)
|
||||
if (!big_lkb)
|
||||
rsb_set_flag(r, RSB_VALNOTVALID);
|
||||
|
||||
if (!r->res_lvbptr) {
|
||||
@@ -799,9 +798,9 @@ static void recover_lvb(struct dlm_rsb *r)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (big_lock_exists) {
|
||||
r->res_lvbseq = lkb->lkb_lvbseq;
|
||||
memcpy(r->res_lvbptr, lkb->lkb_lvbptr, lvblen);
|
||||
if (big_lkb) {
|
||||
r->res_lvbseq = big_lkb->lkb_lvbseq;
|
||||
memcpy(r->res_lvbptr, big_lkb->lkb_lvbptr, lvblen);
|
||||
} else if (high_lkb) {
|
||||
r->res_lvbseq = high_lkb->lkb_lvbseq;
|
||||
memcpy(r->res_lvbptr, high_lkb->lkb_lvbptr, lvblen);
|
||||
|
Reference in New Issue
Block a user