]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: David Teigland <teigland@redhat.com> |
2 | commit eeda418d8c2646f33f24e9ad33d86c239adc6de7 | |
3 | Author: David Teigland <teigland@redhat.com> | |
4 | Date: Tue Dec 9 14:12:21 2008 -0600 | |
5 | Subject: dlm: change lock time stamping | |
6 | ||
7 | Use ktime instead of jiffies for timestamping lkb's. Also stamp the | |
8 | time on every lkb whenever it's added to a resource queue, instead of | |
9 | just stamping locks subject to timeouts. This will allow us to use | |
10 | timestamps more widely for debugging all locks. | |
11 | ||
12 | Signed-off-by: David Teigland <teigland@redhat.com> | |
13 | Signed-off-by: Coly Li <coly.li@suse.de> | |
14 | ||
15 | diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c | |
16 | index 8fc24f4..19e4f9e 100644 | |
17 | --- a/fs/dlm/debug_fs.c | |
18 | +++ b/fs/dlm/debug_fs.c | |
19 | @@ -162,21 +162,21 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s) | |
20 | ||
21 | static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) | |
22 | { | |
23 | - unsigned int waiting = 0; | |
24 | - uint64_t xid = 0; | |
25 | + u64 xid = 0; | |
26 | + u64 us; | |
27 | ||
28 | if (lkb->lkb_flags & DLM_IFL_USER) { | |
29 | if (lkb->lkb_ua) | |
30 | xid = lkb->lkb_ua->xid; | |
31 | } | |
32 | ||
33 | - if (lkb->lkb_timestamp) | |
34 | - waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp); | |
35 | + /* microseconds since lkb was added to current queue */ | |
36 | + us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp)); | |
37 | ||
38 | - /* id nodeid remid pid xid exflags flags sts grmode rqmode time_ms | |
39 | + /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us | |
40 | r_nodeid r_len r_name */ | |
41 | ||
42 | - seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %u %u %d \"%s\"\n", | |
43 | + seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", | |
44 | lkb->lkb_id, | |
45 | lkb->lkb_nodeid, | |
46 | lkb->lkb_remid, | |
47 | @@ -187,7 +187,7 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb * | |
48 | lkb->lkb_status, | |
49 | lkb->lkb_grmode, | |
50 | lkb->lkb_rqmode, | |
51 | - waiting, | |
52 | + (unsigned long long)us, | |
53 | r->res_nodeid, | |
54 | r->res_length, | |
55 | r->res_name); | |
56 | diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h | |
57 | index 868e4c9..e69135c 100644 | |
58 | --- a/fs/dlm/dlm_internal.h | |
59 | +++ b/fs/dlm/dlm_internal.h | |
60 | @@ -245,7 +245,7 @@ struct dlm_lkb { | |
61 | struct list_head lkb_astqueue; /* need ast to be sent */ | |
62 | struct list_head lkb_ownqueue; /* list of locks for a process */ | |
63 | struct list_head lkb_time_list; | |
64 | - unsigned long lkb_timestamp; | |
65 | + ktime_t lkb_timestamp; | |
66 | unsigned long lkb_timeout_cs; | |
67 | ||
68 | char *lkb_lvbptr; | |
69 | diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c | |
70 | index 7b758da..dfc57ae 100644 | |
71 | --- a/fs/dlm/lock.c | |
72 | +++ b/fs/dlm/lock.c | |
73 | @@ -742,6 +742,8 @@ static void add_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb, int status) | |
74 | ||
75 | DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); | |
76 | ||
77 | + lkb->lkb_timestamp = ktime_get(); | |
78 | + | |
79 | lkb->lkb_status = status; | |
80 | ||
81 | switch (status) { | |
82 | @@ -1011,10 +1013,8 @@ static void add_timeout(struct dlm_lkb *lkb) | |
83 | { | |
84 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; | |
85 | ||
86 | - if (is_master_copy(lkb)) { | |
87 | - lkb->lkb_timestamp = jiffies; | |
88 | + if (is_master_copy(lkb)) | |
89 | return; | |
90 | - } | |
91 | ||
92 | if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && | |
93 | !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { | |
94 | @@ -1029,7 +1029,6 @@ static void add_timeout(struct dlm_lkb *lkb) | |
95 | DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); | |
96 | mutex_lock(&ls->ls_timeout_mutex); | |
97 | hold_lkb(lkb); | |
98 | - lkb->lkb_timestamp = jiffies; | |
99 | list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); | |
100 | mutex_unlock(&ls->ls_timeout_mutex); | |
101 | } | |
102 | @@ -1057,6 +1056,7 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |
103 | struct dlm_rsb *r; | |
104 | struct dlm_lkb *lkb; | |
105 | int do_cancel, do_warn; | |
106 | + s64 wait_us; | |
107 | ||
108 | for (;;) { | |
109 | if (dlm_locking_stopped(ls)) | |
110 | @@ -1067,14 +1067,15 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |
111 | mutex_lock(&ls->ls_timeout_mutex); | |
112 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { | |
113 | ||
114 | + wait_us = ktime_to_us(ktime_sub(ktime_get(), | |
115 | + lkb->lkb_timestamp)); | |
116 | + | |
117 | if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && | |
118 | - time_after_eq(jiffies, lkb->lkb_timestamp + | |
119 | - lkb->lkb_timeout_cs * HZ/100)) | |
120 | + wait_us >= (lkb->lkb_timeout_cs * 10000)) | |
121 | do_cancel = 1; | |
122 | ||
123 | if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && | |
124 | - time_after_eq(jiffies, lkb->lkb_timestamp + | |
125 | - dlm_config.ci_timewarn_cs * HZ/100)) | |
126 | + wait_us >= dlm_config.ci_timewarn_cs * 10000) | |
127 | do_warn = 1; | |
128 | ||
129 | if (!do_cancel && !do_warn) | |
130 | @@ -1120,12 +1121,12 @@ void dlm_scan_timeout(struct dlm_ls *ls) | |
131 | void dlm_adjust_timeouts(struct dlm_ls *ls) | |
132 | { | |
133 | struct dlm_lkb *lkb; | |
134 | - long adj = jiffies - ls->ls_recover_begin; | |
135 | + u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin); | |
136 | ||
137 | ls->ls_recover_begin = 0; | |
138 | mutex_lock(&ls->ls_timeout_mutex); | |
139 | list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) | |
140 | - lkb->lkb_timestamp += adj; | |
141 | + lkb->lkb_timestamp = ktime_add_us(lkb->lkb_timestamp, adj_us); | |
142 | mutex_unlock(&ls->ls_timeout_mutex); | |
143 | } | |
144 | ||
145 | diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c | |
146 | index 18bda83..46e582c 100644 | |
147 | --- a/fs/dlm/netlink.c | |
148 | +++ b/fs/dlm/netlink.c | |
149 | @@ -115,7 +115,6 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) | |
150 | data->status = lkb->lkb_status; | |
151 | data->grmode = lkb->lkb_grmode; | |
152 | data->rqmode = lkb->lkb_rqmode; | |
153 | - data->timestamp = lkb->lkb_timestamp; | |
154 | if (lkb->lkb_ua) | |
155 | data->xid = lkb->lkb_ua->xid; | |
156 | if (r) { |