From 8c11ba64ce577a993701616e335319a0afbbd49a Mon Sep 17 00:00:00 2001 From: Alexander Aring Date: Mon, 6 Mar 2023 15:48:14 -0500 Subject: fs: dlm: store lkb distributed flags into own value This patch stores lkb distributed flags value in an separate value instead of sharing internal and distributed flags in lkb->lkb_flags value. This has the advantage to not mask/write back flag values in receive_flags() functionality. The dlm debug_fs does not provide the distributed flags anymore, those can be added in future. Signed-off-by: Alexander Aring Signed-off-by: David Teigland --- fs/dlm/lock.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'fs/dlm/lock.c') diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 74dd297e0857..21c7abd7ef77 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -3675,8 +3675,7 @@ static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms) { lkb->lkb_exflags = le32_to_cpu(ms->m_exflags); lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); - lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | - (le32_to_cpu(ms->m_flags) & 0x0000FFFF); + lkb->lkb_dflags = le32_to_cpu(ms->m_flags); } static void receive_flags_reply(struct dlm_lkb *lkb, struct dlm_message *ms, @@ -3686,8 +3685,7 @@ static void receive_flags_reply(struct dlm_lkb *lkb, struct dlm_message *ms, return; lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); - lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | - (le32_to_cpu(ms->m_flags) & 0x0000FFFF); + lkb->lkb_dflags = le32_to_cpu(ms->m_flags); } static int receive_extralen(struct dlm_message *ms) @@ -3788,8 +3786,8 @@ static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms) int error = 0; /* currently mixing of user/kernel locks are not supported */ - if (ms->m_flags & cpu_to_le32(DLM_IFL_USER) && - ~lkb->lkb_flags & DLM_IFL_USER) { + if (ms->m_flags & cpu_to_le32(DLM_DFL_USER) && + ~lkb->lkb_dflags & DLM_DFL_USER) { log_error(lkb->lkb_resource->res_ls, "got user dlm message for a kernel lock"); error = -EINVAL; @@ -5347,7 +5345,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid); lkb->lkb_remid = le32_to_cpu(rl->rl_lkid); lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags); - lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF; + lkb->lkb_dflags = le32_to_cpu(rl->rl_flags); lkb->lkb_flags |= DLM_IFL_MSTCPY; lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq); lkb->lkb_rqmode = rl->rl_rqmode; @@ -5573,9 +5571,9 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, } /* After ua is attached to lkb it will be freed by dlm_free_lkb(). - When DLM_IFL_USER is set, the dlm knows that this is a userspace + When DLM_DFL_USER is set, the dlm knows that this is a userspace lock and that lkb_astparam is the dlm_user_args structure. */ - lkb->lkb_flags |= DLM_IFL_USER; + lkb->lkb_dflags |= DLM_DFL_USER; error = request_lock(ls, lkb, name, namelen, &args); switch (error) { @@ -5690,7 +5688,7 @@ int dlm_user_adopt_orphan(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, lkb = iter; list_del_init(&iter->lkb_ownqueue); - iter->lkb_flags &= ~DLM_IFL_ORPHAN; + iter->lkb_dflags &= ~DLM_DFL_ORPHAN; *lkid = iter->lkb_id; break; } @@ -5934,7 +5932,7 @@ static struct dlm_lkb *del_proc_lock(struct dlm_ls *ls, list_del_init(&lkb->lkb_ownqueue); if (lkb->lkb_exflags & DLM_LKF_PERSISTENT) - lkb->lkb_flags |= DLM_IFL_ORPHAN; + lkb->lkb_dflags |= DLM_DFL_ORPHAN; else lkb->lkb_flags |= DLM_IFL_DEAD; out: @@ -6085,7 +6083,7 @@ int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc, /* debug functionality */ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len, - int lkb_nodeid, unsigned int lkb_flags, int lkb_status) + int lkb_nodeid, unsigned int lkb_dflags, int lkb_status) { struct dlm_lksb *lksb; struct dlm_lkb *lkb; @@ -6093,7 +6091,7 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len, int error; /* we currently can't set a valid user lock */ - if (lkb_flags & DLM_IFL_USER) + if (lkb_dflags & DLM_DFL_USER) return -EOPNOTSUPP; lksb = kzalloc(sizeof(*lksb), GFP_NOFS); @@ -6106,11 +6104,11 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len, return error; } - lkb->lkb_flags = lkb_flags; + lkb->lkb_dflags = lkb_dflags; lkb->lkb_nodeid = lkb_nodeid; lkb->lkb_lksb = lksb; /* user specific pointer, just don't have it NULL for kernel locks */ - if (~lkb_flags & DLM_IFL_USER) + if (~lkb_dflags & DLM_DFL_USER) lkb->lkb_astparam = (void *)0xDEADBEEF; error = find_rsb(ls, name, len, 0, R_REQUEST, &r); -- cgit v1.2.3