diff options
| author | David Teigland <teigland@redhat.com> | 2008-12-09 15:12:21 -0500 |
|---|---|---|
| committer | David Teigland <teigland@redhat.com> | 2008-12-23 11:18:17 -0500 |
| commit | eeda418d8c2646f33f24e9ad33d86c239adc6de7 (patch) | |
| tree | fecfb293e62cc043d57535481913b37347006a4c | |
| parent | fd22a51bcc0b7b76fc729b02316214fd979f9fe1 (diff) | |
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>
| -rw-r--r-- | fs/dlm/debug_fs.c | 14 | ||||
| -rw-r--r-- | fs/dlm/dlm_internal.h | 2 | ||||
| -rw-r--r-- | fs/dlm/lock.c | 21 | ||||
| -rw-r--r-- | fs/dlm/netlink.c | 1 |
4 files changed, 19 insertions, 19 deletions
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 8fc24f4507a3..19e4f9eb44e1 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
| @@ -162,21 +162,21 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s) | |||
| 162 | 162 | ||
| 163 | static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) | 163 | static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) |
| 164 | { | 164 | { |
| 165 | unsigned int waiting = 0; | 165 | u64 xid = 0; |
| 166 | uint64_t xid = 0; | 166 | u64 us; |
| 167 | 167 | ||
| 168 | if (lkb->lkb_flags & DLM_IFL_USER) { | 168 | if (lkb->lkb_flags & DLM_IFL_USER) { |
| 169 | if (lkb->lkb_ua) | 169 | if (lkb->lkb_ua) |
| 170 | xid = lkb->lkb_ua->xid; | 170 | xid = lkb->lkb_ua->xid; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | if (lkb->lkb_timestamp) | 173 | /* microseconds since lkb was added to current queue */ |
| 174 | waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp); | 174 | us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp)); |
| 175 | 175 | ||
| 176 | /* id nodeid remid pid xid exflags flags sts grmode rqmode time_ms | 176 | /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us |
| 177 | r_nodeid r_len r_name */ | 177 | r_nodeid r_len r_name */ |
| 178 | 178 | ||
| 179 | seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %u %u %d \"%s\"\n", | 179 | seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", |
| 180 | lkb->lkb_id, | 180 | lkb->lkb_id, |
| 181 | lkb->lkb_nodeid, | 181 | lkb->lkb_nodeid, |
| 182 | lkb->lkb_remid, | 182 | lkb->lkb_remid, |
| @@ -187,7 +187,7 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb * | |||
| 187 | lkb->lkb_status, | 187 | lkb->lkb_status, |
| 188 | lkb->lkb_grmode, | 188 | lkb->lkb_grmode, |
| 189 | lkb->lkb_rqmode, | 189 | lkb->lkb_rqmode, |
| 190 | waiting, | 190 | (unsigned long long)us, |
| 191 | r->res_nodeid, | 191 | r->res_nodeid, |
| 192 | r->res_length, | 192 | r->res_length, |
| 193 | r->res_name); | 193 | r->res_name); |
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 868e4c9ef127..e69135c83d5d 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
| @@ -245,7 +245,7 @@ struct dlm_lkb { | |||
| 245 | struct list_head lkb_astqueue; /* need ast to be sent */ | 245 | struct list_head lkb_astqueue; /* need ast to be sent */ |
| 246 | struct list_head lkb_ownqueue; /* list of locks for a process */ | 246 | struct list_head lkb_ownqueue; /* list of locks for a process */ |
| 247 | struct list_head lkb_time_list; | 247 | struct list_head lkb_time_list; |
| 248 | unsigned long lkb_timestamp; | 248 | ktime_t lkb_timestamp; |
| 249 | unsigned long lkb_timeout_cs; | 249 | unsigned long lkb_timeout_cs; |
| 250 | 250 | ||
| 251 | char *lkb_lvbptr; | 251 | char *lkb_lvbptr; |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 7b758dadbdd6..dfc57ae27045 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
| @@ -742,6 +742,8 @@ static void add_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb, int status) | |||
| 742 | 742 | ||
| 743 | DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); | 743 | DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); |
| 744 | 744 | ||
| 745 | lkb->lkb_timestamp = ktime_get(); | ||
| 746 | |||
| 745 | lkb->lkb_status = status; | 747 | lkb->lkb_status = status; |
| 746 | 748 | ||
| 747 | switch (status) { | 749 | switch (status) { |
| @@ -1011,10 +1013,8 @@ static void add_timeout(struct dlm_lkb *lkb) | |||
| 1011 | { | 1013 | { |
| 1012 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; | 1014 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; |
| 1013 | 1015 | ||
| 1014 | if (is_master_copy(lkb)) { | 1016 | if (is_master_copy(lkb)) |
| 1015 | lkb->lkb_timestamp = jiffies; | ||
| 1016 | return; | 1017 | return; |
| 1017 | } | ||
| 1018 | 1018 | ||
| 1019 | if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && | 1019 | if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && |
| 1020 | !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { | 1020 | !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { |
| @@ -1029,7 +1029,6 @@ static void add_timeout(struct dlm_lkb *lkb) | |||
| 1029 | DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); | 1029 | DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); |
| 1030 | mutex_lock(&ls->ls_timeout_mutex); | 1030 | mutex_lock(&ls->ls_timeout_mutex); |
| 1031 | hold_lkb(lkb); | 1031 | hold_lkb(lkb); |
| 1032 | lkb->lkb_timestamp = jiffies; | ||
| 1033 | list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); | 1032 | list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); |
| 1034 | mutex_unlock(&ls->ls_timeout_mutex); | 1033 | mutex_unlock(&ls->ls_timeout_mutex); |
| 1035 | } | 1034 | } |
| @@ -1057,6 +1056,7 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |||
| 1057 | struct dlm_rsb *r; | 1056 | struct dlm_rsb *r; |
| 1058 | struct dlm_lkb *lkb; | 1057 | struct dlm_lkb *lkb; |
| 1059 | int do_cancel, do_warn; | 1058 | int do_cancel, do_warn; |
| 1059 | s64 wait_us; | ||
| 1060 | 1060 | ||
| 1061 | for (;;) { | 1061 | for (;;) { |
| 1062 | if (dlm_locking_stopped(ls)) | 1062 | if (dlm_locking_stopped(ls)) |
| @@ -1067,14 +1067,15 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |||
| 1067 | mutex_lock(&ls->ls_timeout_mutex); | 1067 | mutex_lock(&ls->ls_timeout_mutex); |
| 1068 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { | 1068 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { |
| 1069 | 1069 | ||
| 1070 | wait_us = ktime_to_us(ktime_sub(ktime_get(), | ||
| 1071 | lkb->lkb_timestamp)); | ||
| 1072 | |||
| 1070 | if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && | 1073 | if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && |
| 1071 | time_after_eq(jiffies, lkb->lkb_timestamp + | 1074 | wait_us >= (lkb->lkb_timeout_cs * 10000)) |
| 1072 | lkb->lkb_timeout_cs * HZ/100)) | ||
| 1073 | do_cancel = 1; | 1075 | do_cancel = 1; |
| 1074 | 1076 | ||
| 1075 | if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && | 1077 | if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && |
| 1076 | time_after_eq(jiffies, lkb->lkb_timestamp + | 1078 | wait_us >= dlm_config.ci_timewarn_cs * 10000) |
| 1077 | dlm_config.ci_timewarn_cs * HZ/100)) | ||
| 1078 | do_warn = 1; | 1079 | do_warn = 1; |
| 1079 | 1080 | ||
| 1080 | if (!do_cancel && !do_warn) | 1081 | if (!do_cancel && !do_warn) |
| @@ -1120,12 +1121,12 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |||
| 1120 | void dlm_adjust_timeouts(struct dlm_ls *ls) | 1121 | void dlm_adjust_timeouts(struct dlm_ls *ls) |
| 1121 | { | 1122 | { |
| 1122 | struct dlm_lkb *lkb; | 1123 | struct dlm_lkb *lkb; |
| 1123 | long adj = jiffies - ls->ls_recover_begin; | 1124 | u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin); |
| 1124 | 1125 | ||
| 1125 | ls->ls_recover_begin = 0; | 1126 | ls->ls_recover_begin = 0; |
| 1126 | mutex_lock(&ls->ls_timeout_mutex); | 1127 | mutex_lock(&ls->ls_timeout_mutex); |
| 1127 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) | 1128 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) |
| 1128 | lkb->lkb_timestamp += adj; | 1129 | lkb->lkb_timestamp = ktime_add_us(lkb->lkb_timestamp, adj_us); |
| 1129 | mutex_unlock(&ls->ls_timeout_mutex); | 1130 | mutex_unlock(&ls->ls_timeout_mutex); |
| 1130 | } | 1131 | } |
| 1131 | 1132 | ||
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c index 18bda83cc892..46e582c8d603 100644 --- a/fs/dlm/netlink.c +++ b/fs/dlm/netlink.c | |||
| @@ -115,7 +115,6 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) | |||
| 115 | data->status = lkb->lkb_status; | 115 | data->status = lkb->lkb_status; |
| 116 | data->grmode = lkb->lkb_grmode; | 116 | data->grmode = lkb->lkb_grmode; |
| 117 | data->rqmode = lkb->lkb_rqmode; | 117 | data->rqmode = lkb->lkb_rqmode; |
| 118 | data->timestamp = lkb->lkb_timestamp; | ||
| 119 | if (lkb->lkb_ua) | 118 | if (lkb->lkb_ua) |
| 120 | data->xid = lkb->lkb_ua->xid; | 119 | data->xid = lkb->lkb_ua->xid; |
| 121 | if (r) { | 120 | if (r) { |
