Skip to content

Commit 8c11ba6

Browse files
Alexander Aringteigland
authored andcommitted
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 <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 9f48eea commit 8c11ba6

8 files changed

Lines changed: 29 additions & 41 deletions

File tree

fs/dlm/ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status,
139139
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
140140
int rv;
141141

142-
if (lkb->lkb_flags & DLM_IFL_USER) {
142+
if (lkb->lkb_dflags & DLM_DFL_USER) {
143143
dlm_user_add_ast(lkb, flags, mode, status, sbflags);
144144
return;
145145
}

fs/dlm/debug_fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
170170
u64 xid = 0;
171171
u64 us;
172172

173-
if (lkb->lkb_flags & DLM_IFL_USER) {
173+
if (lkb->lkb_dflags & DLM_DFL_USER) {
174174
if (lkb->lkb_ua)
175175
xid = lkb->lkb_ua->xid;
176176
}
@@ -230,7 +230,7 @@ static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
230230
{
231231
u64 xid = 0;
232232

233-
if (lkb->lkb_flags & DLM_IFL_USER) {
233+
if (lkb->lkb_dflags & DLM_DFL_USER) {
234234
if (lkb->lkb_ua)
235235
xid = lkb->lkb_ua->xid;
236236
}

fs/dlm/dlm_internal.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,10 @@ struct dlm_args {
206206

207207
#define DLM_IFL_CB_PENDING_BIT 0
208208

209-
/* least significant 2 bytes are message changed, they are full transmitted
210-
* but at receive side only the 2 bytes LSB will be set.
211-
*
212-
* Even wireshark dlm dissector does only evaluate the lower bytes and note
213-
* that they may not be used on transceiver side, we assume the higher bytes
214-
* are for internal use or reserved so long they are not parsed on receiver
215-
* side.
216-
*/
217-
#define DLM_IFL_USER 0x00000001
218-
#define DLM_IFL_ORPHAN 0x00000002
209+
/* lkb_dflags */
210+
211+
#define DLM_DFL_USER 0x00000001
212+
#define DLM_DFL_ORPHAN 0x00000002
219213

220214
#define DLM_CB_CAST 0x00000001
221215
#define DLM_CB_BAST 0x00000002
@@ -240,6 +234,7 @@ struct dlm_lkb {
240234
uint32_t lkb_exflags; /* external flags from caller */
241235
uint32_t lkb_sbflags; /* lksb flags */
242236
uint32_t lkb_flags; /* internal flags */
237+
uint32_t lkb_dflags; /* distributed flags */
243238
unsigned long lkb_iflags; /* internal flags */
244239
uint32_t lkb_lvbseq; /* lvb sequence number */
245240

fs/dlm/lock.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,8 +3675,7 @@ static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms)
36753675
{
36763676
lkb->lkb_exflags = le32_to_cpu(ms->m_exflags);
36773677
lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags);
3678-
lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) |
3679-
(le32_to_cpu(ms->m_flags) & 0x0000FFFF);
3678+
lkb->lkb_dflags = le32_to_cpu(ms->m_flags);
36803679
}
36813680

36823681
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,
36863685
return;
36873686

36883687
lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags);
3689-
lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) |
3690-
(le32_to_cpu(ms->m_flags) & 0x0000FFFF);
3688+
lkb->lkb_dflags = le32_to_cpu(ms->m_flags);
36913689
}
36923690

36933691
static int receive_extralen(struct dlm_message *ms)
@@ -3788,8 +3786,8 @@ static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms)
37883786
int error = 0;
37893787

37903788
/* currently mixing of user/kernel locks are not supported */
3791-
if (ms->m_flags & cpu_to_le32(DLM_IFL_USER) &&
3792-
~lkb->lkb_flags & DLM_IFL_USER) {
3789+
if (ms->m_flags & cpu_to_le32(DLM_DFL_USER) &&
3790+
~lkb->lkb_dflags & DLM_DFL_USER) {
37933791
log_error(lkb->lkb_resource->res_ls,
37943792
"got user dlm message for a kernel lock");
37953793
error = -EINVAL;
@@ -5347,7 +5345,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
53475345
lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid);
53485346
lkb->lkb_remid = le32_to_cpu(rl->rl_lkid);
53495347
lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags);
5350-
lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF;
5348+
lkb->lkb_dflags = le32_to_cpu(rl->rl_flags);
53515349
lkb->lkb_flags |= DLM_IFL_MSTCPY;
53525350
lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq);
53535351
lkb->lkb_rqmode = rl->rl_rqmode;
@@ -5573,9 +5571,9 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
55735571
}
55745572

55755573
/* After ua is attached to lkb it will be freed by dlm_free_lkb().
5576-
When DLM_IFL_USER is set, the dlm knows that this is a userspace
5574+
When DLM_DFL_USER is set, the dlm knows that this is a userspace
55775575
lock and that lkb_astparam is the dlm_user_args structure. */
5578-
lkb->lkb_flags |= DLM_IFL_USER;
5576+
lkb->lkb_dflags |= DLM_DFL_USER;
55795577
error = request_lock(ls, lkb, name, namelen, &args);
55805578

55815579
switch (error) {
@@ -5690,7 +5688,7 @@ int dlm_user_adopt_orphan(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
56905688

56915689
lkb = iter;
56925690
list_del_init(&iter->lkb_ownqueue);
5693-
iter->lkb_flags &= ~DLM_IFL_ORPHAN;
5691+
iter->lkb_dflags &= ~DLM_DFL_ORPHAN;
56945692
*lkid = iter->lkb_id;
56955693
break;
56965694
}
@@ -5934,7 +5932,7 @@ static struct dlm_lkb *del_proc_lock(struct dlm_ls *ls,
59345932
list_del_init(&lkb->lkb_ownqueue);
59355933

59365934
if (lkb->lkb_exflags & DLM_LKF_PERSISTENT)
5937-
lkb->lkb_flags |= DLM_IFL_ORPHAN;
5935+
lkb->lkb_dflags |= DLM_DFL_ORPHAN;
59385936
else
59395937
lkb->lkb_flags |= DLM_IFL_DEAD;
59405938
out:
@@ -6085,15 +6083,15 @@ int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
60856083

60866084
/* debug functionality */
60876085
int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
6088-
int lkb_nodeid, unsigned int lkb_flags, int lkb_status)
6086+
int lkb_nodeid, unsigned int lkb_dflags, int lkb_status)
60896087
{
60906088
struct dlm_lksb *lksb;
60916089
struct dlm_lkb *lkb;
60926090
struct dlm_rsb *r;
60936091
int error;
60946092

60956093
/* we currently can't set a valid user lock */
6096-
if (lkb_flags & DLM_IFL_USER)
6094+
if (lkb_dflags & DLM_DFL_USER)
60976095
return -EOPNOTSUPP;
60986096

60996097
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,
61066104
return error;
61076105
}
61086106

6109-
lkb->lkb_flags = lkb_flags;
6107+
lkb->lkb_dflags = lkb_dflags;
61106108
lkb->lkb_nodeid = lkb_nodeid;
61116109
lkb->lkb_lksb = lksb;
61126110
/* user specific pointer, just don't have it NULL for kernel locks */
6113-
if (~lkb_flags & DLM_IFL_USER)
6111+
if (~lkb_dflags & DLM_DFL_USER)
61146112
lkb->lkb_astparam = (void *)0xDEADBEEF;
61156113

61166114
error = find_rsb(ls, name, len, 0, R_REQUEST, &r);

fs/dlm/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
118118

119119
void dlm_free_lkb(struct dlm_lkb *lkb)
120120
{
121-
if (lkb->lkb_flags & DLM_IFL_USER) {
121+
if (lkb->lkb_dflags & DLM_DFL_USER) {
122122
struct dlm_user_args *ua;
123123
ua = lkb->lkb_ua;
124124
if (ua) {

fs/dlm/rcom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb,
415415
rl->rl_ownpid = cpu_to_le32(lkb->lkb_ownpid);
416416
rl->rl_lkid = cpu_to_le32(lkb->lkb_id);
417417
rl->rl_exflags = cpu_to_le32(lkb->lkb_exflags);
418-
rl->rl_flags = cpu_to_le32(lkb->lkb_flags);
418+
rl->rl_flags = cpu_to_le32(lkb->lkb_dflags);
419419
rl->rl_lvbseq = cpu_to_le32(lkb->lkb_lvbseq);
420420
rl->rl_rqmode = lkb->lkb_rqmode;
421421
rl->rl_grmode = lkb->lkb_grmode;

fs/dlm/user.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
183183
struct dlm_user_proc *proc;
184184
int rv;
185185

186-
if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
186+
if (lkb->lkb_dflags & DLM_DFL_ORPHAN ||
187+
lkb->lkb_flags & DLM_IFL_DEAD)
187188
return;
188189

189190
ls = lkb->lkb_resource->res_ls;
@@ -195,7 +196,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
195196
for cases where a completion ast is received for an operation that
196197
began before clear_proc_locks did its cancel/unlock. */
197198

198-
if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
199+
if (lkb->lkb_dflags & DLM_DFL_ORPHAN ||
200+
lkb->lkb_flags & DLM_IFL_DEAD)
199201
goto out;
200202

201203
DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););

include/trace/events/dlm.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,8 @@
4747
{ DLM_SBF_ALTMODE, "ALTMODE" })
4848

4949
#define show_lkb_flags(flags) __print_flags(flags, "|", \
50-
{ DLM_IFL_MSTCPY, "MSTCPY" }, \
51-
{ DLM_IFL_RESEND, "RESEND" }, \
52-
{ DLM_IFL_DEAD, "DEAD" }, \
53-
{ DLM_IFL_OVERLAP_UNLOCK, "OVERLAP_UNLOCK" }, \
54-
{ DLM_IFL_OVERLAP_CANCEL, "OVERLAP_CANCEL" }, \
55-
{ DLM_IFL_ENDOFLIFE, "ENDOFLIFE" }, \
56-
{ DLM_IFL_DEADLOCK_CANCEL, "DEADLOCK_CANCEL" }, \
57-
{ DLM_IFL_USER, "USER" }, \
58-
{ DLM_IFL_ORPHAN, "ORPHAN" })
50+
{ DLM_DFL_USER, "USER" }, \
51+
{ DLM_DFL_ORPHAN, "ORPHAN" })
5952

6053
#define show_header_cmd(cmd) __print_symbolic(cmd, \
6154
{ DLM_MSG, "MSG"}, \

0 commit comments

Comments
 (0)