diff options
author | Alexander Aring <aahringo@redhat.com> | 2023-03-06 23:48:14 +0300 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2023-03-07 00:49:07 +0300 |
commit | 8c11ba64ce577a993701616e335319a0afbbd49a (patch) | |
tree | c5c9f015a3c4d79d9470752177871e92076ec80d | |
parent | 9f48eead5ea4c55692dd5628699a0d5715416615 (diff) | |
download | linux-8c11ba64ce577a993701616e335319a0afbbd49a.tar.xz |
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>
-rw-r--r-- | fs/dlm/ast.c | 2 | ||||
-rw-r--r-- | fs/dlm/debug_fs.c | 4 | ||||
-rw-r--r-- | fs/dlm/dlm_internal.h | 15 | ||||
-rw-r--r-- | fs/dlm/lock.c | 28 | ||||
-rw-r--r-- | fs/dlm/memory.c | 2 | ||||
-rw-r--r-- | fs/dlm/rcom.c | 2 | ||||
-rw-r--r-- | fs/dlm/user.c | 6 | ||||
-rw-r--r-- | include/trace/events/dlm.h | 11 |
8 files changed, 29 insertions, 41 deletions
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index 39805aea3336..28b7b5288bd4 100644 --- a/fs/dlm/ast.c +++ b/fs/dlm/ast.c @@ -139,7 +139,7 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status, struct dlm_ls *ls = lkb->lkb_resource->res_ls; int rv; - if (lkb->lkb_flags & DLM_IFL_USER) { + if (lkb->lkb_dflags & DLM_DFL_USER) { dlm_user_add_ast(lkb, flags, mode, status, sbflags); return; } diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 8a0e1b1f74ad..65cfb58eaa6b 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c @@ -170,7 +170,7 @@ static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, u64 xid = 0; u64 us; - if (lkb->lkb_flags & DLM_IFL_USER) { + if (lkb->lkb_dflags & DLM_DFL_USER) { if (lkb->lkb_ua) xid = lkb->lkb_ua->xid; } @@ -230,7 +230,7 @@ static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, { u64 xid = 0; - if (lkb->lkb_flags & DLM_IFL_USER) { + if (lkb->lkb_dflags & DLM_DFL_USER) { if (lkb->lkb_ua) xid = lkb->lkb_ua->xid; } diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 3bdb2f4e132e..748bb483da1c 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h @@ -206,16 +206,10 @@ struct dlm_args { #define DLM_IFL_CB_PENDING_BIT 0 -/* least significant 2 bytes are message changed, they are full transmitted - * but at receive side only the 2 bytes LSB will be set. - * - * Even wireshark dlm dissector does only evaluate the lower bytes and note - * that they may not be used on transceiver side, we assume the higher bytes - * are for internal use or reserved so long they are not parsed on receiver - * side. - */ -#define DLM_IFL_USER 0x00000001 -#define DLM_IFL_ORPHAN 0x00000002 +/* lkb_dflags */ + +#define DLM_DFL_USER 0x00000001 +#define DLM_DFL_ORPHAN 0x00000002 #define DLM_CB_CAST 0x00000001 #define DLM_CB_BAST 0x00000002 @@ -240,6 +234,7 @@ struct dlm_lkb { uint32_t lkb_exflags; /* external flags from caller */ uint32_t lkb_sbflags; /* lksb flags */ uint32_t lkb_flags; /* internal flags */ + uint32_t lkb_dflags; /* distributed flags */ unsigned long lkb_iflags; /* internal flags */ uint32_t lkb_lvbseq; /* lvb sequence number */ 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); diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c index cdbaa452fc05..c1a832e8a72b 100644 --- a/fs/dlm/memory.c +++ b/fs/dlm/memory.c @@ -118,7 +118,7 @@ struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls) void dlm_free_lkb(struct dlm_lkb *lkb) { - if (lkb->lkb_flags & DLM_IFL_USER) { + if (lkb->lkb_dflags & DLM_DFL_USER) { struct dlm_user_args *ua; ua = lkb->lkb_ua; if (ua) { diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index b76d52e2f6bd..005ee85218c5 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c @@ -415,7 +415,7 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, rl->rl_ownpid = cpu_to_le32(lkb->lkb_ownpid); rl->rl_lkid = cpu_to_le32(lkb->lkb_id); rl->rl_exflags = cpu_to_le32(lkb->lkb_exflags); - rl->rl_flags = cpu_to_le32(lkb->lkb_flags); + rl->rl_flags = cpu_to_le32(lkb->lkb_dflags); rl->rl_lvbseq = cpu_to_le32(lkb->lkb_lvbseq); rl->rl_rqmode = lkb->lkb_rqmode; rl->rl_grmode = lkb->lkb_grmode; diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 0951ca5754e2..dd4b9c8f226c 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c @@ -183,7 +183,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, struct dlm_user_proc *proc; int rv; - if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) + if (lkb->lkb_dflags & DLM_DFL_ORPHAN || + lkb->lkb_flags & DLM_IFL_DEAD) return; ls = lkb->lkb_resource->res_ls; @@ -195,7 +196,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, for cases where a completion ast is received for an operation that began before clear_proc_locks did its cancel/unlock. */ - if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) + if (lkb->lkb_dflags & DLM_DFL_ORPHAN || + lkb->lkb_flags & DLM_IFL_DEAD) goto out; DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb);); diff --git a/include/trace/events/dlm.h b/include/trace/events/dlm.h index cd00b2d34e33..6fa4798e1939 100644 --- a/include/trace/events/dlm.h +++ b/include/trace/events/dlm.h @@ -47,15 +47,8 @@ { DLM_SBF_ALTMODE, "ALTMODE" }) #define show_lkb_flags(flags) __print_flags(flags, "|", \ - { DLM_IFL_MSTCPY, "MSTCPY" }, \ - { DLM_IFL_RESEND, "RESEND" }, \ - { DLM_IFL_DEAD, "DEAD" }, \ - { DLM_IFL_OVERLAP_UNLOCK, "OVERLAP_UNLOCK" }, \ - { DLM_IFL_OVERLAP_CANCEL, "OVERLAP_CANCEL" }, \ - { DLM_IFL_ENDOFLIFE, "ENDOFLIFE" }, \ - { DLM_IFL_DEADLOCK_CANCEL, "DEADLOCK_CANCEL" }, \ - { DLM_IFL_USER, "USER" }, \ - { DLM_IFL_ORPHAN, "ORPHAN" }) + { DLM_DFL_USER, "USER" }, \ + { DLM_DFL_ORPHAN, "ORPHAN" }) #define show_header_cmd(cmd) __print_symbolic(cmd, \ { DLM_MSG, "MSG"}, \ |