Skip to content

Commit

Permalink
dlm: change lock time stamping
Browse files Browse the repository at this point in the history
Use ktime instead of jiffies for timestamping lkb's.  Also stamp the
time on every lkb whenever it's added to a resource queue, instead of
just stamping locks subject to timeouts.  This will allow us to use
timestamps more widely for debugging all locks.

Signed-off-by: David Teigland <teigland@redhat.com>
  • Loading branch information
David Teigland committed Dec 23, 2008
1 parent fd22a51 commit eeda418
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)

static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r)
{
unsigned int waiting = 0;
uint64_t xid = 0;
u64 xid = 0;
u64 us;

if (lkb->lkb_flags & DLM_IFL_USER) {
if (lkb->lkb_ua)
xid = lkb->lkb_ua->xid;
}

if (lkb->lkb_timestamp)
waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp);
/* microseconds since lkb was added to current queue */
us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp));

/* id nodeid remid pid xid exflags flags sts grmode rqmode time_ms
/* id nodeid remid pid xid exflags flags sts grmode rqmode time_us
r_nodeid r_len r_name */

seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %u %u %d \"%s\"\n",
seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
lkb->lkb_id,
lkb->lkb_nodeid,
lkb->lkb_remid,
Expand All @@ -187,7 +187,7 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *
lkb->lkb_status,
lkb->lkb_grmode,
lkb->lkb_rqmode,
waiting,
(unsigned long long)us,
r->res_nodeid,
r->res_length,
r->res_name);
Expand Down
2 changes: 1 addition & 1 deletion fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ struct dlm_lkb {
struct list_head lkb_astqueue; /* need ast to be sent */
struct list_head lkb_ownqueue; /* list of locks for a process */
struct list_head lkb_time_list;
unsigned long lkb_timestamp;
ktime_t lkb_timestamp;
unsigned long lkb_timeout_cs;

char *lkb_lvbptr;
Expand Down
21 changes: 11 additions & 10 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ static void add_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb, int status)

DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););

lkb->lkb_timestamp = ktime_get();

lkb->lkb_status = status;

switch (status) {
Expand Down Expand Up @@ -1011,10 +1013,8 @@ static void add_timeout(struct dlm_lkb *lkb)
{
struct dlm_ls *ls = lkb->lkb_resource->res_ls;

if (is_master_copy(lkb)) {
lkb->lkb_timestamp = jiffies;
if (is_master_copy(lkb))
return;
}

if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) &&
!(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) {
Expand All @@ -1029,7 +1029,6 @@ static void add_timeout(struct dlm_lkb *lkb)
DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb););
mutex_lock(&ls->ls_timeout_mutex);
hold_lkb(lkb);
lkb->lkb_timestamp = jiffies;
list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout);
mutex_unlock(&ls->ls_timeout_mutex);
}
Expand Down Expand Up @@ -1057,6 +1056,7 @@ void dlm_scan_timeout(struct dlm_ls *ls)
struct dlm_rsb *r;
struct dlm_lkb *lkb;
int do_cancel, do_warn;
s64 wait_us;

for (;;) {
if (dlm_locking_stopped(ls))
Expand All @@ -1067,14 +1067,15 @@ void dlm_scan_timeout(struct dlm_ls *ls)
mutex_lock(&ls->ls_timeout_mutex);
list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) {

wait_us = ktime_to_us(ktime_sub(ktime_get(),
lkb->lkb_timestamp));

if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) &&
time_after_eq(jiffies, lkb->lkb_timestamp +
lkb->lkb_timeout_cs * HZ/100))
wait_us >= (lkb->lkb_timeout_cs * 10000))
do_cancel = 1;

if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) &&
time_after_eq(jiffies, lkb->lkb_timestamp +
dlm_config.ci_timewarn_cs * HZ/100))
wait_us >= dlm_config.ci_timewarn_cs * 10000)
do_warn = 1;

if (!do_cancel && !do_warn)
Expand Down Expand Up @@ -1120,12 +1121,12 @@ void dlm_scan_timeout(struct dlm_ls *ls)
void dlm_adjust_timeouts(struct dlm_ls *ls)
{
struct dlm_lkb *lkb;
long adj = jiffies - ls->ls_recover_begin;
u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin);

ls->ls_recover_begin = 0;
mutex_lock(&ls->ls_timeout_mutex);
list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list)
lkb->lkb_timestamp += adj;
lkb->lkb_timestamp = ktime_add_us(lkb->lkb_timestamp, adj_us);
mutex_unlock(&ls->ls_timeout_mutex);
}

Expand Down
1 change: 0 additions & 1 deletion fs/dlm/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
data->status = lkb->lkb_status;
data->grmode = lkb->lkb_grmode;
data->rqmode = lkb->lkb_rqmode;
data->timestamp = lkb->lkb_timestamp;
if (lkb->lkb_ua)
data->xid = lkb->lkb_ua->xid;
if (r) {
Expand Down

0 comments on commit eeda418

Please sign in to comment.