aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster/tcp.c
diff options
context:
space:
mode:
authorSunil Mushran <sunil.mushran@oracle.com>2010-12-22 15:39:39 -0500
committerJoel Becker <joel.becker@oracle.com>2010-12-22 21:37:57 -0500
commitff1becbf85bf4d4d4652915b7ab27db949585f6b (patch)
treea037c063caa2ea0dda28d2967bffd399dfdc7cc6 /fs/ocfs2/cluster/tcp.c
parent3f9c14fab0a2e90af9995f261a123f59e0b41141 (diff)
ocfs2/cluster: Use ktime instead of timeval in struct o2net_sock_container
Replace time trackers in struct o2net_sock_container from struct timeval to union ktime. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/cluster/tcp.c')
-rw-r--r--fs/ocfs2/cluster/tcp.c91
1 files changed, 53 insertions, 38 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 49c1a95e352e..efd848334052 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -153,61 +153,75 @@ static void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
153 nst->st_node = node; 153 nst->st_node = node;
154} 154}
155 155
156static void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) 156static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst)
157{ 157{
158 nst->st_sock_time = ktime_get(); 158 nst->st_sock_time = ktime_get();
159} 159}
160 160
161static void o2net_set_nst_send_time(struct o2net_send_tracking *nst) 161static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst)
162{ 162{
163 nst->st_send_time = ktime_get(); 163 nst->st_send_time = ktime_get();
164} 164}
165 165
166static void o2net_set_nst_status_time(struct o2net_send_tracking *nst) 166static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst)
167{ 167{
168 nst->st_status_time = ktime_get(); 168 nst->st_status_time = ktime_get();
169} 169}
170 170
171static void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, 171static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
172 struct o2net_sock_container *sc) 172 struct o2net_sock_container *sc)
173{ 173{
174 nst->st_sc = sc; 174 nst->st_sc = sc;
175} 175}
176 176
177static void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id) 177static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst,
178 u32 msg_id)
178{ 179{
179 nst->st_id = msg_id; 180 nst->st_id = msg_id;
180} 181}
181 182
182#else /* CONFIG_DEBUG_FS */ 183static inline void o2net_set_sock_timer(struct o2net_sock_container *sc)
183
184static inline void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
185 u32 msgkey, struct task_struct *task, u8 node)
186{ 184{
185 sc->sc_tv_timer = ktime_get();
187} 186}
188 187
189static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) 188static inline void o2net_set_data_ready_time(struct o2net_sock_container *sc)
190{ 189{
190 sc->sc_tv_data_ready = ktime_get();
191} 191}
192 192
193static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst) 193static inline void o2net_set_advance_start_time(struct o2net_sock_container *sc)
194{ 194{
195 sc->sc_tv_advance_start = ktime_get();
195} 196}
196 197
197static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst) 198static inline void o2net_set_advance_stop_time(struct o2net_sock_container *sc)
198{ 199{
200 sc->sc_tv_advance_stop = ktime_get();
199} 201}
200 202
201static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, 203static inline void o2net_set_func_start_time(struct o2net_sock_container *sc)
202 struct o2net_sock_container *sc)
203{ 204{
205 sc->sc_tv_func_start = ktime_get();
204} 206}
205 207
206static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, 208static inline void o2net_set_func_stop_time(struct o2net_sock_container *sc)
207 u32 msg_id)
208{ 209{
210 sc->sc_tv_func_stop = ktime_get();
209} 211}
210 212#else /* CONFIG_DEBUG_FS */
213# define o2net_init_nst(a, b, c, d, e)
214# define o2net_set_nst_sock_time(a)
215# define o2net_set_nst_send_time(a)
216# define o2net_set_nst_status_time(a)
217# define o2net_set_nst_sock_container(a, b)
218# define o2net_set_nst_msg_id(a, b)
219# define o2net_set_sock_timer(a)
220# define o2net_set_data_ready_time(a)
221# define o2net_set_advance_start_time(a)
222# define o2net_set_advance_stop_time(a)
223# define o2net_set_func_start_time(a)
224# define o2net_set_func_stop_time(a)
211#endif /* CONFIG_DEBUG_FS */ 225#endif /* CONFIG_DEBUG_FS */
212 226
213static inline int o2net_reconnect_delay(void) 227static inline int o2net_reconnect_delay(void)
@@ -555,7 +569,7 @@ static void o2net_data_ready(struct sock *sk, int bytes)
555 if (sk->sk_user_data) { 569 if (sk->sk_user_data) {
556 struct o2net_sock_container *sc = sk->sk_user_data; 570 struct o2net_sock_container *sc = sk->sk_user_data;
557 sclog(sc, "data_ready hit\n"); 571 sclog(sc, "data_ready hit\n");
558 do_gettimeofday(&sc->sc_tv_data_ready); 572 o2net_set_data_ready_time(sc);
559 o2net_sc_queue_work(sc, &sc->sc_rx_work); 573 o2net_sc_queue_work(sc, &sc->sc_rx_work);
560 ready = sc->sc_data_ready; 574 ready = sc->sc_data_ready;
561 } else { 575 } else {
@@ -1192,13 +1206,13 @@ static int o2net_process_message(struct o2net_sock_container *sc,
1192 if (syserr != O2NET_ERR_NONE) 1206 if (syserr != O2NET_ERR_NONE)
1193 goto out_respond; 1207 goto out_respond;
1194 1208
1195 do_gettimeofday(&sc->sc_tv_func_start); 1209 o2net_set_func_start_time(sc);
1196 sc->sc_msg_key = be32_to_cpu(hdr->key); 1210 sc->sc_msg_key = be32_to_cpu(hdr->key);
1197 sc->sc_msg_type = be16_to_cpu(hdr->msg_type); 1211 sc->sc_msg_type = be16_to_cpu(hdr->msg_type);
1198 handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) + 1212 handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) +
1199 be16_to_cpu(hdr->data_len), 1213 be16_to_cpu(hdr->data_len),
1200 nmh->nh_func_data, &ret_data); 1214 nmh->nh_func_data, &ret_data);
1201 do_gettimeofday(&sc->sc_tv_func_stop); 1215 o2net_set_func_stop_time(sc);
1202 1216
1203out_respond: 1217out_respond:
1204 /* this destroys the hdr, so don't use it after this */ 1218 /* this destroys the hdr, so don't use it after this */
@@ -1309,7 +1323,7 @@ static int o2net_advance_rx(struct o2net_sock_container *sc)
1309 size_t datalen; 1323 size_t datalen;
1310 1324
1311 sclog(sc, "receiving\n"); 1325 sclog(sc, "receiving\n");
1312 do_gettimeofday(&sc->sc_tv_advance_start); 1326 o2net_set_advance_start_time(sc);
1313 1327
1314 if (unlikely(sc->sc_handshake_ok == 0)) { 1328 if (unlikely(sc->sc_handshake_ok == 0)) {
1315 if(sc->sc_page_off < sizeof(struct o2net_handshake)) { 1329 if(sc->sc_page_off < sizeof(struct o2net_handshake)) {
@@ -1384,7 +1398,7 @@ static int o2net_advance_rx(struct o2net_sock_container *sc)
1384 1398
1385out: 1399out:
1386 sclog(sc, "ret = %d\n", ret); 1400 sclog(sc, "ret = %d\n", ret);
1387 do_gettimeofday(&sc->sc_tv_advance_stop); 1401 o2net_set_advance_stop_time(sc);
1388 return ret; 1402 return ret;
1389} 1403}
1390 1404
@@ -1484,27 +1498,28 @@ static void o2net_idle_timer(unsigned long data)
1484{ 1498{
1485 struct o2net_sock_container *sc = (struct o2net_sock_container *)data; 1499 struct o2net_sock_container *sc = (struct o2net_sock_container *)data;
1486 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); 1500 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);
1487 struct timeval now;
1488 1501
1489 do_gettimeofday(&now); 1502#ifdef CONFIG_DEBUG_FS
1503 ktime_t now = ktime_get();
1504#endif
1490 1505
1491 printk(KERN_NOTICE "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u " 1506 printk(KERN_NOTICE "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u "
1492 "seconds, shutting it down.\n", SC_NODEF_ARGS(sc), 1507 "seconds, shutting it down.\n", SC_NODEF_ARGS(sc),
1493 o2net_idle_timeout() / 1000, 1508 o2net_idle_timeout() / 1000,
1494 o2net_idle_timeout() % 1000); 1509 o2net_idle_timeout() % 1000);
1495 mlog(ML_NOTICE, "here are some times that might help debug the " 1510
1496 "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " 1511#ifdef CONFIG_DEBUG_FS
1497 "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", 1512 mlog(ML_NOTICE, "Here are some times that might help debug the "
1498 sc->sc_tv_timer.tv_sec, (long) sc->sc_tv_timer.tv_usec, 1513 "situation: (Timer: %lld, Now %lld, DataReady %lld, Advance %lld-%lld, "
1499 now.tv_sec, (long) now.tv_usec, 1514 "Key 0x%08x, Func %u, FuncTime %lld-%lld)\n",
1500 sc->sc_tv_data_ready.tv_sec, (long) sc->sc_tv_data_ready.tv_usec, 1515 (long long)ktime_to_us(sc->sc_tv_timer), (long long)ktime_to_us(now),
1501 sc->sc_tv_advance_start.tv_sec, 1516 (long long)ktime_to_us(sc->sc_tv_data_ready),
1502 (long) sc->sc_tv_advance_start.tv_usec, 1517 (long long)ktime_to_us(sc->sc_tv_advance_start),
1503 sc->sc_tv_advance_stop.tv_sec, 1518 (long long)ktime_to_us(sc->sc_tv_advance_stop),
1504 (long) sc->sc_tv_advance_stop.tv_usec,
1505 sc->sc_msg_key, sc->sc_msg_type, 1519 sc->sc_msg_key, sc->sc_msg_type,
1506 sc->sc_tv_func_start.tv_sec, (long) sc->sc_tv_func_start.tv_usec, 1520 (long long)ktime_to_us(sc->sc_tv_func_start),
1507 sc->sc_tv_func_stop.tv_sec, (long) sc->sc_tv_func_stop.tv_usec); 1521 (long long)ktime_to_us(sc->sc_tv_func_stop));
1522#endif
1508 1523
1509 /* 1524 /*
1510 * Initialize the nn_timeout so that the next connection attempt 1525 * Initialize the nn_timeout so that the next connection attempt
@@ -1520,7 +1535,7 @@ static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc)
1520 o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); 1535 o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work);
1521 o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, 1536 o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work,
1522 msecs_to_jiffies(o2net_keepalive_delay())); 1537 msecs_to_jiffies(o2net_keepalive_delay()));
1523 do_gettimeofday(&sc->sc_tv_timer); 1538 o2net_set_sock_timer(sc);
1524 mod_timer(&sc->sc_idle_timeout, 1539 mod_timer(&sc->sc_idle_timeout,
1525 jiffies + msecs_to_jiffies(o2net_idle_timeout())); 1540 jiffies + msecs_to_jiffies(o2net_idle_timeout()));
1526} 1541}