Skip to content

Commit

Permalink
fs: dlm: move internal flags to atomic ops
Browse files Browse the repository at this point in the history
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: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
  • Loading branch information
Alexander Aring authored and David Teigland committed Mar 6, 2023
1 parent 8a39dcd commit e1af872
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 83 deletions.
4 changes: 2 additions & 2 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
lkb->lkb_ownpid,
(unsigned long long)xid,
lkb->lkb_exflags,
lkb->lkb_flags,
dlm_iflags_val(lkb),
lkb->lkb_status,
lkb->lkb_grmode,
lkb->lkb_rqmode,
Expand Down Expand Up @@ -242,7 +242,7 @@ static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
lkb->lkb_ownpid,
(unsigned long long)xid,
lkb->lkb_exflags,
lkb->lkb_flags,
dlm_iflags_val(lkb),
lkb->lkb_status,
lkb->lkb_grmode,
lkb->lkb_rqmode,
Expand Down
30 changes: 18 additions & 12 deletions fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,18 @@ struct dlm_args {
#define DLM_LKSTS_GRANTED 2
#define DLM_LKSTS_CONVERT 3

/* lkb_flags */

#define DLM_IFL_MSTCPY 0x00010000
#define DLM_IFL_RESEND 0x00020000
#define DLM_IFL_DEAD 0x00040000
#define DLM_IFL_OVERLAP_UNLOCK 0x00080000
#define DLM_IFL_OVERLAP_CANCEL 0x00100000
#define DLM_IFL_ENDOFLIFE 0x00200000
#define DLM_IFL_DEADLOCK_CANCEL 0x01000000

#define DLM_IFL_CB_PENDING_BIT 0
/* lkb_iflags */

#define DLM_IFL_MSTCPY_BIT 16
#define __DLM_IFL_MIN_BIT DLM_IFL_MSTCPY_BIT
#define DLM_IFL_RESEND_BIT 17
#define DLM_IFL_DEAD_BIT 18
#define DLM_IFL_OVERLAP_UNLOCK_BIT 19
#define DLM_IFL_OVERLAP_CANCEL_BIT 20
#define DLM_IFL_ENDOFLIFE_BIT 21
#define DLM_IFL_DEADLOCK_CANCEL_BIT 24
#define DLM_IFL_CB_PENDING_BIT 25
#define __DLM_IFL_MAX_BIT DLM_IFL_CB_PENDING_BIT

/* lkb_dflags */

Expand Down Expand Up @@ -235,7 +236,6 @@ struct dlm_lkb {
uint32_t lkb_remid; /* lock ID on remote partner */
uint32_t lkb_exflags; /* external flags from caller */
uint32_t lkb_sbflags; /* lksb flags */
uint32_t lkb_flags; /* internal flags */
unsigned long lkb_dflags; /* distributed flags */
unsigned long lkb_iflags; /* internal flags */
uint32_t lkb_lvbseq; /* lvb sequence number */
Expand Down Expand Up @@ -748,6 +748,12 @@ static inline uint32_t dlm_flags_val(const unsigned long *addr,
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)
{
return dlm_flags_val(&lkb->lkb_dflags, __DLM_DFL_MIN_BIT,
Expand Down
Loading

0 comments on commit e1af872

Please sign in to comment.