dlm: change lock time stamping
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>
This commit is contained in:
parent
fd22a51bcc
commit
eeda418d8c
@ -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)
|
static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r)
|
||||||
{
|
{
|
||||||
unsigned int waiting = 0;
|
u64 xid = 0;
|
||||||
uint64_t xid = 0;
|
u64 us;
|
||||||
|
|
||||||
if (lkb->lkb_flags & DLM_IFL_USER) {
|
if (lkb->lkb_flags & DLM_IFL_USER) {
|
||||||
if (lkb->lkb_ua)
|
if (lkb->lkb_ua)
|
||||||
xid = lkb->lkb_ua->xid;
|
xid = lkb->lkb_ua->xid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lkb->lkb_timestamp)
|
/* microseconds since lkb was added to current queue */
|
||||||
waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp);
|
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 */
|
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_id,
|
||||||
lkb->lkb_nodeid,
|
lkb->lkb_nodeid,
|
||||||
lkb->lkb_remid,
|
lkb->lkb_remid,
|
||||||
@ -187,7 +187,7 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *
|
|||||||
lkb->lkb_status,
|
lkb->lkb_status,
|
||||||
lkb->lkb_grmode,
|
lkb->lkb_grmode,
|
||||||
lkb->lkb_rqmode,
|
lkb->lkb_rqmode,
|
||||||
waiting,
|
(unsigned long long)us,
|
||||||
r->res_nodeid,
|
r->res_nodeid,
|
||||||
r->res_length,
|
r->res_length,
|
||||||
r->res_name);
|
r->res_name);
|
||||||
|
@ -245,7 +245,7 @@ struct dlm_lkb {
|
|||||||
struct list_head lkb_astqueue; /* need ast to be sent */
|
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_ownqueue; /* list of locks for a process */
|
||||||
struct list_head lkb_time_list;
|
struct list_head lkb_time_list;
|
||||||
unsigned long lkb_timestamp;
|
ktime_t lkb_timestamp;
|
||||||
unsigned long lkb_timeout_cs;
|
unsigned long lkb_timeout_cs;
|
||||||
|
|
||||||
char *lkb_lvbptr;
|
char *lkb_lvbptr;
|
||||||
|
@ -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););
|
DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););
|
||||||
|
|
||||||
|
lkb->lkb_timestamp = ktime_get();
|
||||||
|
|
||||||
lkb->lkb_status = status;
|
lkb->lkb_status = status;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@ -1011,10 +1013,8 @@ static void add_timeout(struct dlm_lkb *lkb)
|
|||||||
{
|
{
|
||||||
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
|
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
|
||||||
|
|
||||||
if (is_master_copy(lkb)) {
|
if (is_master_copy(lkb))
|
||||||
lkb->lkb_timestamp = jiffies;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) &&
|
if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) &&
|
||||||
!(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) {
|
!(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) {
|
||||||
@ -1029,7 +1029,6 @@ static void add_timeout(struct dlm_lkb *lkb)
|
|||||||
DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb););
|
DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb););
|
||||||
mutex_lock(&ls->ls_timeout_mutex);
|
mutex_lock(&ls->ls_timeout_mutex);
|
||||||
hold_lkb(lkb);
|
hold_lkb(lkb);
|
||||||
lkb->lkb_timestamp = jiffies;
|
|
||||||
list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout);
|
list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout);
|
||||||
mutex_unlock(&ls->ls_timeout_mutex);
|
mutex_unlock(&ls->ls_timeout_mutex);
|
||||||
}
|
}
|
||||||
@ -1057,6 +1056,7 @@ void dlm_scan_timeout(struct dlm_ls *ls)
|
|||||||
struct dlm_rsb *r;
|
struct dlm_rsb *r;
|
||||||
struct dlm_lkb *lkb;
|
struct dlm_lkb *lkb;
|
||||||
int do_cancel, do_warn;
|
int do_cancel, do_warn;
|
||||||
|
s64 wait_us;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (dlm_locking_stopped(ls))
|
if (dlm_locking_stopped(ls))
|
||||||
@ -1067,14 +1067,15 @@ void dlm_scan_timeout(struct dlm_ls *ls)
|
|||||||
mutex_lock(&ls->ls_timeout_mutex);
|
mutex_lock(&ls->ls_timeout_mutex);
|
||||||
list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) {
|
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) &&
|
if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) &&
|
||||||
time_after_eq(jiffies, lkb->lkb_timestamp +
|
wait_us >= (lkb->lkb_timeout_cs * 10000))
|
||||||
lkb->lkb_timeout_cs * HZ/100))
|
|
||||||
do_cancel = 1;
|
do_cancel = 1;
|
||||||
|
|
||||||
if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) &&
|
if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) &&
|
||||||
time_after_eq(jiffies, lkb->lkb_timestamp +
|
wait_us >= dlm_config.ci_timewarn_cs * 10000)
|
||||||
dlm_config.ci_timewarn_cs * HZ/100))
|
|
||||||
do_warn = 1;
|
do_warn = 1;
|
||||||
|
|
||||||
if (!do_cancel && !do_warn)
|
if (!do_cancel && !do_warn)
|
||||||
@ -1120,12 +1121,12 @@ void dlm_scan_timeout(struct dlm_ls *ls)
|
|||||||
void dlm_adjust_timeouts(struct dlm_ls *ls)
|
void dlm_adjust_timeouts(struct dlm_ls *ls)
|
||||||
{
|
{
|
||||||
struct dlm_lkb *lkb;
|
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;
|
ls->ls_recover_begin = 0;
|
||||||
mutex_lock(&ls->ls_timeout_mutex);
|
mutex_lock(&ls->ls_timeout_mutex);
|
||||||
list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list)
|
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);
|
mutex_unlock(&ls->ls_timeout_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
|
|||||||
data->status = lkb->lkb_status;
|
data->status = lkb->lkb_status;
|
||||||
data->grmode = lkb->lkb_grmode;
|
data->grmode = lkb->lkb_grmode;
|
||||||
data->rqmode = lkb->lkb_rqmode;
|
data->rqmode = lkb->lkb_rqmode;
|
||||||
data->timestamp = lkb->lkb_timestamp;
|
|
||||||
if (lkb->lkb_ua)
|
if (lkb->lkb_ua)
|
||||||
data->xid = lkb->lkb_ua->xid;
|
data->xid = lkb->lkb_ua->xid;
|
||||||
if (r) {
|
if (r) {
|
||||||
|
Loading…
Reference in New Issue
Block a user