1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Author: Liang Zhen <liangzhen@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org
8 * kernel structure for LST console
11 #ifndef __LST_CONSOLE_H__
12 #define __LST_CONSOLE_H__
16 #include <libcfs/kp30.h>
17 #include <lnet/lnet.h>
18 #include <lnet/lib-types.h>
19 #include <lnet/lnetst.h>
23 typedef struct lstcon_node {
24 lnet_process_id_t nd_id; /* id of the node */
25 int nd_ref; /* reference count */
26 int nd_state; /* state of the node */
27 int nd_timeout; /* session timeout */
28 cfs_time_t nd_stamp; /* timestamp of last replied RPC */
29 struct lstcon_rpc nd_ping; /* ping rpc */
30 } lstcon_node_t; /*** node descriptor */
33 struct list_head ndl_link; /* chain on list */
34 struct list_head ndl_hlink; /* chain on hash */
35 lstcon_node_t *ndl_node; /* pointer to node */
36 } lstcon_ndlink_t; /*** node link descriptor */
39 struct list_head grp_link; /* chain on global group list */
40 int grp_ref; /* reference count */
41 int grp_userland; /* has userland nodes */
42 int grp_nnode; /* # of nodes */
43 char grp_name[LST_NAME_SIZE]; /* group name */
45 struct list_head grp_trans_list; /* transaction list */
46 struct list_head grp_ndl_list; /* nodes list */
47 struct list_head grp_ndl_hash[0];/* hash table for nodes */
48 } lstcon_group_t; /*** (alias of nodes) group descriptor */
50 #define LST_BATCH_IDLE 0xB0 /* idle batch */
51 #define LST_BATCH_RUNNING 0xB1 /* running batch */
53 typedef struct lstcon_tsb_hdr {
54 lst_bid_t tsb_id; /* batch ID */
55 int tsb_index; /* test index */
59 lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
60 struct list_head bat_link; /* chain on session's batches list */
61 int bat_ntest; /* # of test */
62 int bat_state; /* state of the batch */
63 int bat_arg; /* parameter for run|stop, timeout for run, force for stop */
64 char bat_name[LST_NAME_SIZE]; /* name of batch */
66 struct list_head bat_test_list; /* list head of tests (lstcon_test_t) */
67 struct list_head bat_trans_list; /* list head of transaction */
68 struct list_head bat_cli_list; /* list head of client nodes (lstcon_node_t) */
69 struct list_head *bat_cli_hash; /* hash table of client nodes */
70 struct list_head bat_srv_list; /* list head of server nodes */
71 struct list_head *bat_srv_hash; /* hash table of server nodes */
72 } lstcon_batch_t; /*** (tests ) batch descritptor */
74 typedef struct lstcon_test {
75 lstcon_tsb_hdr_t tes_hdr; /* test batch header */
76 struct list_head tes_link; /* chain on batch's tests list */
77 lstcon_batch_t *tes_batch; /* pointer to batch */
79 int tes_type; /* type of the test, i.e: bulk, ping */
80 int tes_stop_onerr; /* stop on error */
81 int tes_oneside; /* one-sided test */
82 int tes_concur; /* concurrency */
83 int tes_loop; /* loop count */
84 int tes_dist; /* nodes distribution of target group */
85 int tes_span; /* nodes span of target group */
86 int tes_cliidx; /* client index, used for RPC creating */
88 struct list_head tes_trans_list; /* transaction list */
89 lstcon_group_t *tes_src_grp; /* group run the test */
90 lstcon_group_t *tes_dst_grp; /* target group */
92 int tes_paramlen; /* test parameter length */
93 char tes_param[0]; /* test parameter */
94 } lstcon_test_t; /*** a single test descriptor */
96 #define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
97 #define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
99 #define LST_SESSION_NONE 0x0 /* no session */
100 #define LST_SESSION_ACTIVE 0x1 /* working session */
102 #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
105 struct semaphore ses_mutex; /* lock for session, only one thread can enter session */
106 lst_sid_t ses_id; /* global session id */
107 int ses_key; /* local session key */
108 int ses_state; /* state of session */
109 int ses_timeout; /* timeout in seconds */
110 time_t ses_laststamp; /* last operation stamp (seconds) */
111 int ses_force:1; /* force creating */
112 int ses_shutdown:1; /* session is shutting down */
113 int ses_expired:1; /* console is timedout */
114 __u64 ses_id_cookie; /* batch id cookie */
115 char ses_name[LST_NAME_SIZE]; /* session name */
116 lstcon_rpc_trans_t *ses_ping; /* session pinger */
117 stt_timer_t ses_ping_timer; /* timer for pinger */
118 lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
120 struct list_head ses_trans_list; /* global list of transaction */
121 struct list_head ses_grp_list; /* global list of groups */
122 struct list_head ses_bat_list; /* global list of batches */
123 struct list_head ses_ndl_list; /* global list of nodes */
124 struct list_head *ses_ndl_hash; /* hash table of nodes */
126 spinlock_t ses_rpc_lock; /* serialize */
127 atomic_t ses_rpc_counter;/* # of initialized RPCs */
128 struct list_head ses_rpc_freelist; /* idle console rpc */
129 } lstcon_session_t; /*** session descriptor */
131 extern lstcon_session_t console_session;
132 static inline lstcon_trans_stat_t *
133 lstcon_trans_stat(void)
135 return &console_session.ses_trans_stat;
138 static inline struct list_head *
139 lstcon_id2hash (lnet_process_id_t id, struct list_head *hash)
141 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
146 extern int lstcon_session_match(lst_sid_t sid);
147 extern int lstcon_session_new(char *name, int key,
148 int timeout, int flags, lst_sid_t *sid_up);
149 extern int lstcon_session_info(lst_sid_t *sid_up, int *key,
150 lstcon_ndlist_ent_t *entp, char *name_up, int len);
151 extern int lstcon_session_end(void);
152 extern int lstcon_session_debug(int timeout, struct list_head *result_up);
153 extern int lstcon_batch_debug(int timeout, char *name,
154 int client, struct list_head *result_up);
155 extern int lstcon_group_debug(int timeout, char *name,
156 struct list_head *result_up);
157 extern int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t *nds_up,
158 struct list_head *result_up);
159 extern int lstcon_group_add(char *name);
160 extern int lstcon_group_del(char *name);
161 extern int lstcon_group_clean(char *name, int args);
162 extern int lstcon_group_refresh(char *name, struct list_head *result_up);
163 extern int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t *nds_up,
164 struct list_head *result_up);
165 extern int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t *nds_up,
166 struct list_head *result_up);
167 extern int lstcon_group_info(char *name, lstcon_ndlist_ent_t *gent_up,
168 int *index_p, int *ndent_p, lstcon_node_ent_t *ndents_up);
169 extern int lstcon_group_list(int idx, int len, char *name_up);
170 extern int lstcon_batch_add(char *name);
171 extern int lstcon_batch_run(char *name, int timeout, struct list_head *result_up);
172 extern int lstcon_batch_stop(char *name, int force, struct list_head *result_up);
173 extern int lstcon_test_batch_query(char *name, int testidx,
174 int client, int timeout,
175 struct list_head *result_up);
176 extern int lstcon_batch_del(char *name);
177 extern int lstcon_batch_list(int idx, int namelen, char *name_up);
178 extern int lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up,
179 int server, int testidx, int *index_p,
180 int *ndent_p, lstcon_node_ent_t *dents_up);
181 extern int lstcon_group_stat(char *grp_name, int timeout,
182 struct list_head *result_up);
183 extern int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
184 int timeout, struct list_head *result_up);
185 extern int lstcon_test_add(char *name, int type, int loop, int concur,
186 int dist, int span, char *src_name, char * dst_name,
187 void *param, int paramlen, int *retp, struct list_head *result_up);