Commit e1af8728 authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland

fs: dlm: move internal flags to atomic ops

This patch will move the lkb_flags value to the recently introduced
lkb_iflags value. For lkb_iflags we use atomic bit operations because
some flags like DLM_IFL_CB_PENDING are used while non rsb lock is held
to avoid issues with other flag manipulations which might run at the
same time we switch to atomic bit operations. Snapshot the bit values to
an uint32_t value is only used for debugging/logging use cases and don't
need to be 100% correct.
Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 8a39dcd9
...@@ -188,7 +188,7 @@ static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, ...@@ -188,7 +188,7 @@ static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
lkb->lkb_ownpid, lkb->lkb_ownpid,
(unsigned long long)xid, (unsigned long long)xid,
lkb->lkb_exflags, lkb->lkb_exflags,
lkb->lkb_flags, dlm_iflags_val(lkb),
lkb->lkb_status, lkb->lkb_status,
lkb->lkb_grmode, lkb->lkb_grmode,
lkb->lkb_rqmode, lkb->lkb_rqmode,
...@@ -242,7 +242,7 @@ static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, ...@@ -242,7 +242,7 @@ static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
lkb->lkb_ownpid, lkb->lkb_ownpid,
(unsigned long long)xid, (unsigned long long)xid,
lkb->lkb_exflags, lkb->lkb_exflags,
lkb->lkb_flags, dlm_iflags_val(lkb),
lkb->lkb_status, lkb->lkb_status,
lkb->lkb_grmode, lkb->lkb_grmode,
lkb->lkb_rqmode, lkb->lkb_rqmode,
......
...@@ -194,17 +194,18 @@ struct dlm_args { ...@@ -194,17 +194,18 @@ struct dlm_args {
#define DLM_LKSTS_GRANTED 2 #define DLM_LKSTS_GRANTED 2
#define DLM_LKSTS_CONVERT 3 #define DLM_LKSTS_CONVERT 3
/* lkb_flags */ /* lkb_iflags */
#define DLM_IFL_MSTCPY 0x00010000 #define DLM_IFL_MSTCPY_BIT 16
#define DLM_IFL_RESEND 0x00020000 #define __DLM_IFL_MIN_BIT DLM_IFL_MSTCPY_BIT
#define DLM_IFL_DEAD 0x00040000 #define DLM_IFL_RESEND_BIT 17
#define DLM_IFL_OVERLAP_UNLOCK 0x00080000 #define DLM_IFL_DEAD_BIT 18
#define DLM_IFL_OVERLAP_CANCEL 0x00100000 #define DLM_IFL_OVERLAP_UNLOCK_BIT 19
#define DLM_IFL_ENDOFLIFE 0x00200000 #define DLM_IFL_OVERLAP_CANCEL_BIT 20
#define DLM_IFL_DEADLOCK_CANCEL 0x01000000 #define DLM_IFL_ENDOFLIFE_BIT 21
#define DLM_IFL_DEADLOCK_CANCEL_BIT 24
#define DLM_IFL_CB_PENDING_BIT 0 #define DLM_IFL_CB_PENDING_BIT 25
#define __DLM_IFL_MAX_BIT DLM_IFL_CB_PENDING_BIT
/* lkb_dflags */ /* lkb_dflags */
...@@ -235,7 +236,6 @@ struct dlm_lkb { ...@@ -235,7 +236,6 @@ struct dlm_lkb {
uint32_t lkb_remid; /* lock ID on remote partner */ uint32_t lkb_remid; /* lock ID on remote partner */
uint32_t lkb_exflags; /* external flags from caller */ uint32_t lkb_exflags; /* external flags from caller */
uint32_t lkb_sbflags; /* lksb flags */ uint32_t lkb_sbflags; /* lksb flags */
uint32_t lkb_flags; /* internal flags */
unsigned long lkb_dflags; /* distributed flags */ unsigned long lkb_dflags; /* distributed flags */
unsigned long lkb_iflags; /* internal flags */ unsigned long lkb_iflags; /* internal flags */
uint32_t lkb_lvbseq; /* lvb sequence number */ uint32_t lkb_lvbseq; /* lvb sequence number */
...@@ -748,6 +748,12 @@ static inline uint32_t dlm_flags_val(const unsigned long *addr, ...@@ -748,6 +748,12 @@ static inline uint32_t dlm_flags_val(const unsigned long *addr,
return val; return val;
} }
static inline uint32_t dlm_iflags_val(const struct dlm_lkb *lkb)
{
return dlm_flags_val(&lkb->lkb_iflags, __DLM_IFL_MIN_BIT,
__DLM_IFL_MAX_BIT);
}
static inline uint32_t dlm_dflags_val(const struct dlm_lkb *lkb) static inline uint32_t dlm_dflags_val(const struct dlm_lkb *lkb)
{ {
return dlm_flags_val(&lkb->lkb_dflags, __DLM_DFL_MIN_BIT, return dlm_flags_val(&lkb->lkb_dflags, __DLM_DFL_MIN_BIT,
......
This diff is collapsed.
...@@ -741,7 +741,7 @@ static int lkb_idr_free(int id, void *p, void *data) ...@@ -741,7 +741,7 @@ static int lkb_idr_free(int id, void *p, void *data)
{ {
struct dlm_lkb *lkb = p; struct dlm_lkb *lkb = p;
if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY) if (lkb->lkb_lvbptr && test_bit(DLM_IFL_MSTCPY_BIT, &lkb->lkb_iflags))
dlm_free_lvb(lkb->lkb_lvbptr); dlm_free_lvb(lkb->lkb_lvbptr);
dlm_free_lkb(lkb); dlm_free_lkb(lkb);
......
...@@ -403,7 +403,7 @@ static void set_lock_master(struct list_head *queue, int nodeid) ...@@ -403,7 +403,7 @@ static void set_lock_master(struct list_head *queue, int nodeid)
struct dlm_lkb *lkb; struct dlm_lkb *lkb;
list_for_each_entry(lkb, queue, lkb_statequeue) { list_for_each_entry(lkb, queue, lkb_statequeue) {
if (!(lkb->lkb_flags & DLM_IFL_MSTCPY)) { if (!test_bit(DLM_IFL_MSTCPY_BIT, &lkb->lkb_iflags)) {
lkb->lkb_nodeid = nodeid; lkb->lkb_nodeid = nodeid;
lkb->lkb_remid = 0; lkb->lkb_remid = 0;
} }
......
...@@ -184,7 +184,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, ...@@ -184,7 +184,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
int rv; int rv;
if (test_bit(DLM_DFL_ORPHAN_BIT, &lkb->lkb_dflags) || if (test_bit(DLM_DFL_ORPHAN_BIT, &lkb->lkb_dflags) ||
lkb->lkb_flags & DLM_IFL_DEAD) test_bit(DLM_IFL_DEAD_BIT, &lkb->lkb_iflags))
return; return;
ls = lkb->lkb_resource->res_ls; ls = lkb->lkb_resource->res_ls;
...@@ -197,7 +197,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, ...@@ -197,7 +197,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
began before clear_proc_locks did its cancel/unlock. */ began before clear_proc_locks did its cancel/unlock. */
if (test_bit(DLM_DFL_ORPHAN_BIT, &lkb->lkb_dflags) || if (test_bit(DLM_DFL_ORPHAN_BIT, &lkb->lkb_dflags) ||
lkb->lkb_flags & DLM_IFL_DEAD) test_bit(DLM_IFL_DEAD_BIT, &lkb->lkb_iflags))
goto out; goto out;
DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb);); DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););
...@@ -208,7 +208,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, ...@@ -208,7 +208,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
goto out; goto out;
if ((flags & DLM_CB_CAST) && lkb_is_endoflife(mode, status)) if ((flags & DLM_CB_CAST) && lkb_is_endoflife(mode, status))
lkb->lkb_flags |= DLM_IFL_ENDOFLIFE; set_bit(DLM_IFL_ENDOFLIFE_BIT, &lkb->lkb_iflags);
spin_lock(&proc->asts_spin); spin_lock(&proc->asts_spin);
...@@ -231,7 +231,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, ...@@ -231,7 +231,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
} }
spin_unlock(&proc->asts_spin); spin_unlock(&proc->asts_spin);
if (lkb->lkb_flags & DLM_IFL_ENDOFLIFE) { if (test_bit(DLM_IFL_ENDOFLIFE_BIT, &lkb->lkb_iflags)) {
/* N.B. spin_lock locks_spin, not asts_spin */ /* N.B. spin_lock locks_spin, not asts_spin */
spin_lock(&proc->locks_spin); spin_lock(&proc->locks_spin);
if (!list_empty(&lkb->lkb_ownqueue)) { if (!list_empty(&lkb->lkb_ownqueue)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment