aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lock.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2008-12-09 15:12:21 -0500
committerDavid Teigland <teigland@redhat.com>2008-12-23 11:18:17 -0500
commiteeda418d8c2646f33f24e9ad33d86c239adc6de7 (patch)
treefecfb293e62cc043d57535481913b37347006a4c /fs/dlm/lock.c
parentfd22a51bcc0b7b76fc729b02316214fd979f9fe1 (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>
Diffstat (limited to 'fs/dlm/lock.c')
-rw-r--r--fs/dlm/lock.c21
1 files changed, 11 insertions, 10 deletions
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)
1120void dlm_adjust_timeouts(struct dlm_ls *ls) 1121void 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