ext4: Optimize ext4 DIO overwrites
[linux/fpc-iii.git] / fs / ocfs2 / cluster / tcp.h
blobde87cbffd175fd888f27479ffa0badb58d3868a3
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
5 * tcp.h
7 * Function prototypes
9 * Copyright (C) 2004 Oracle. All rights reserved.
12 #ifndef O2CLUSTER_TCP_H
13 #define O2CLUSTER_TCP_H
15 #include <linux/socket.h>
16 #ifdef __KERNEL__
17 #include <net/sock.h>
18 #include <linux/tcp.h>
19 #else
20 #include <sys/socket.h>
21 #endif
22 #include <linux/inet.h>
23 #include <linux/in.h>
25 struct o2net_msg
27 __be16 magic;
28 __be16 data_len;
29 __be16 msg_type;
30 __be16 pad1;
31 __be32 sys_status;
32 __be32 status;
33 __be32 key;
34 __be32 msg_num;
35 __u8 buf[0];
38 typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data,
39 void **ret_data);
40 typedef void (o2net_post_msg_handler_func)(int status, void *data,
41 void *ret_data);
43 #define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg))
45 /* same as hb delay, we're waiting for another node to recognize our hb */
46 #define O2NET_RECONNECT_DELAY_MS_DEFAULT 2000
48 #define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000
49 #define O2NET_IDLE_TIMEOUT_MS_DEFAULT 30000
51 #define O2NET_TCP_USER_TIMEOUT 0x7fffffff
53 /* TODO: figure this out.... */
54 static inline int o2net_link_down(int err, struct socket *sock)
56 if (sock) {
57 if (sock->sk->sk_state != TCP_ESTABLISHED &&
58 sock->sk->sk_state != TCP_CLOSE_WAIT)
59 return 1;
62 if (err >= 0)
63 return 0;
64 switch (err) {
65 /* ????????????????????????? */
66 case -ERESTARTSYS:
67 case -EBADF:
68 /* When the server has died, an ICMP port unreachable
69 * message prompts ECONNREFUSED. */
70 case -ECONNREFUSED:
71 case -ENOTCONN:
72 case -ECONNRESET:
73 case -EPIPE:
74 return 1;
76 return 0;
79 enum {
80 O2NET_DRIVER_UNINITED,
81 O2NET_DRIVER_READY,
84 int o2net_send_message(u32 msg_type, u32 key, void *data, u32 len,
85 u8 target_node, int *status);
86 int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec,
87 size_t veclen, u8 target_node, int *status);
89 int o2net_register_handler(u32 msg_type, u32 key, u32 max_len,
90 o2net_msg_handler_func *func, void *data,
91 o2net_post_msg_handler_func *post_func,
92 struct list_head *unreg_list);
93 void o2net_unregister_handler_list(struct list_head *list);
95 void o2net_fill_node_map(unsigned long *map, unsigned bytes);
97 struct o2nm_node;
98 int o2net_register_hb_callbacks(void);
99 void o2net_unregister_hb_callbacks(void);
100 int o2net_start_listening(struct o2nm_node *node);
101 void o2net_stop_listening(struct o2nm_node *node);
102 void o2net_disconnect_node(struct o2nm_node *node);
103 int o2net_num_connected_peers(void);
105 int o2net_init(void);
106 void o2net_exit(void);
108 struct o2net_send_tracking;
109 struct o2net_sock_container;
111 #ifdef CONFIG_DEBUG_FS
112 void o2net_debugfs_init(void);
113 void o2net_debugfs_exit(void);
114 void o2net_debug_add_nst(struct o2net_send_tracking *nst);
115 void o2net_debug_del_nst(struct o2net_send_tracking *nst);
116 void o2net_debug_add_sc(struct o2net_sock_container *sc);
117 void o2net_debug_del_sc(struct o2net_sock_container *sc);
118 #else
119 static inline void o2net_debugfs_init(void)
122 static inline void o2net_debugfs_exit(void)
125 static inline void o2net_debug_add_nst(struct o2net_send_tracking *nst)
128 static inline void o2net_debug_del_nst(struct o2net_send_tracking *nst)
131 static inline void o2net_debug_add_sc(struct o2net_sock_container *sc)
134 static inline void o2net_debug_del_sc(struct o2net_sock_container *sc)
137 #endif /* CONFIG_DEBUG_FS */
139 #endif /* O2CLUSTER_TCP_H */