Import TBBT (NFS trace replay).
[bluesky.git] / TBBT / trace_play / rfs_c_dat.c
1 #include "rfs_c_def.h"
2 #include "generic_hash.h"
3 dep_tab_t dep_tab[DEP_TAB_SIZE];
4 int req_num_with_new_fh = 0;
5 int     req_num_with_discard_fh = 0;
6 int req_num_with_init_fh =0;
7
8 int event_order [EVENT_ORDER_SIZE];
9 int event_order_index = 0;
10
11 memory_trace_ent_t memory_trace[MAX_MEMORY_TRACE_LINES];
12         
13 /* the offset between the replay time and timestamp in the log */
14 struct ladtime current;
15 #if     0
16 //struct ladtime trace_starttime = {1003636801, 39949, 0};
17 struct ladtime trace_starttime = {1003723201, 313373, 0};
18 #else
19 /* timestamp extracted from the used trace. G. Jason Peng */
20 //struct ladtime trace_starttime = {1005620400, 499221, 0};
21 /* timestamp extracted nfsdump.gzip.pair Ningning for osdi measurement */
22 struct ladtime trace_starttime = {1085067131, 107476, 0};
23 #endif
24 struct ladtime time_offset;
25
26 fh_map_t fh_map [FH_MAP_SIZE];
27 struct generic_entry * fh_htable[FH_HTABLE_SIZE];
28 int fh_i=0;
29 int fh_map_debug = 0;
30 struct generic_entry * fh_htable [FH_HTABLE_SIZE];
31
32 #ifdef notdef
33 /* the array is indexed by sfs operation number */
34 rfs_op_type rfs_Ops[TOTAL] = {
35 {NFSPROC3_NULL,         setbuf_void,            setbuf_void, xdr_void, xdr_void},
36 {NFSPROC3_GETATTR,      setarg_GETATTR3,        setbuf_void, xdr_GETATTR3args, xdr_GETATTR3res},
37 {NFSPROC3_SETATTR,      setarg_SETATTR3,        setbuf_void, xdr_SETATTR3args, xdr_SETATTR3res},
38 {NFSPROC3_INVALID,      setbuf_invalid,         setbuf_invalid, xdr_invalid, xdr_invalid},
39 {NFSPROC3_LOOKUP,       setarg_LOOKUP3,         setres_lookup, xdr_LOOKUP3args, xdr_LOOKUP3res},
40 {NFSPROC3_READLINK, setarg_READLINK3,   setres_readlink, xdr_READLINK3args, xdr_READLINK3res},
41 {NFSPROC3_READ,         setarg_READ3,           setres_read, xdr_READ3args, xdr_READ3res},
42 {NFSPROC3_INVALID,      setarg_invalid,         setbuf_invalid, xdr_invalid, xdr_invalid},
43 {NFSPROC3_WRITE,        setarg_WRITE3,          setbuf_void, xdr_WRITE3args, xdr_WRITE3res},
44 {NFSPROC3_CREATE,       setarg_CREATE3,         setbuf_void, xdr_CREATE3args, xdr_CREATE3res},
45 {NFSPROC3_REMOVE,       setarg_REMOVE3,         setbuf_void, xdr_REMOVE3args, xdr_REMOVE3res},
46 {NFSPROC3_RENAME,       setarg_RENAME3,         setbuf_void, xdr_RENAME3args, xdr_RENAME3res},
47 {NFSPROC3_LINK,         setarg_LINK3,           setbuf_void, xdr_LINK3args, xdr_LINK3res},
48 {NFSPROC3_SYMLINK,      setarg_SYMLINK3,        setbuf_void, xdr_SYMLINK3args, xdr_SYMLINK3res},
49 {NFSPROC3_MKDIR,        setarg_MKDIR3,          setbuf_void, xdr_MKDIR3args, xdr_MKDIR3res},
50 {NFSPROC3_RMDIR,        setarg_RMDIR3,          setbuf_void, xdr_RMDIR3args, xdr_RMDIR3res},
51 {NFSPROC3_READDIR,      setarg_READDIR3,        setres_readdir, xdr_READDIR3args, xdr_READDIR3res},
52 {NFSPROC3_FSSTAT,       setarg_FSSTAT3,         setbuf_void, xdr_FSSTAT3args, xdr_FSSTAT3res},
53 {NFSPROC3_ACCESS,       setarg_ACCESS3,         setbuf_void, xdr_ACCESS3args, xdr_ACCESS3res},
54 {NFSPROC3_COMMIT,       setarg_COMMIT3,         setbuf_void, xdr_COMMIT3args, xdr_COMMIT3res},
55 {NFSPROC3_FSINFO,       setarg_FSINFO3,         setbuf_void,  xdr_FSINFO3args, xdr_FSINFO3res},
56 {NFSPROC3_MKNOD,        setarg_MKNOD3,          setbuf_void, xdr_MKNOD3args, xdr_MKNOD3res},
57 {NFSPROC3_PATHCONF, setarg_PATHCONF3,   setbuf_void, xdr_PATHCONF3args, xdr_PATHCONF3res}
58 {NFSPROC3_READDIRPLUS, setarg_READDIRPLUS3, setres_readdirplus, xdr_READDIRPLUS3args, xdr_READDIRPLUS3res}};
59
60 /*
61  * --------------------  NFS ops vector --------------------
62  */
63 /*
64  * per operation information
65  */
66 sfs_op_type nfsv3_Ops[] = {
67
68 /* name        mix    op    call  no  req  req  req  results */
69 /*             pcnt  class  targ call pcnt cnt  targ         */
70
71  { "null",        0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
72  { "getattr",    11, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
73  { "setattr",     1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
74  { "root",        0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
75  { "lookup",     27, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
76  { "readlink",    7, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
77  { "read",       18, Read,    0,  0,  0.0,  0,   0,  { 0, }},
78  { "wrcache",     0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
79  { "write",       9, Write,   0,  0,  0.0,  0,   0,  { 0, }},
80  { "create",      1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
81  { "remove",      1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
82  { "rename",      0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
83  { "link",        0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
84  { "symlink",     0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
85  { "mkdir",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
86  { "rmdir",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
87  { "readdir",     2, Read,    0,  0,  0.0,  0,   0,  { 0, }},
88  { "fsstat",      1, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
89  { "access",      7, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
90  { "commit",      5, Write,   0,  0,  0.0,  0,   0,  { 0, }},
91  { "fsinfo",      1, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
92  { "mknod",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
93  { "pathconf",    0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
94  { "readdirplus", 9, Read,   0,  0,  0.0,  0,   0,  { 0, }},
95  { "TOTAL",     100, Lookup,  0,  0,  0.0,  0,   0,  { 0, }}
96 };
97 #endif
98
99 sfs_op_type *Ops;
100
101 int num_out_reqs = 0;
102
103 cyclic_index_t dep_tab_index;
104 cyclic_index_t dep_window_index;
105 cyclic_index_t memory_trace_index;
106 int dep_window_max = 0;
107
108 /* note that for each dep_tab entry, there is a memory trace line, but
109  * not vise vesa because some memory trace line may not have corresponding
110  * dep_tab entry. According entry TIMESTAMP value, the order is
111  *
112  * memory_trace_tail line < dep_tab_tail entry < dep_window_max entry <
113  * dep_tab_head entry < memory_trace_head entry */
114
115 int rfs_debug = 0;
116 int per_packet_debug = 0;
117 int adjust_play_window_debug = 0;
118 int dependency_debug = 0;
119 int profile_debug = 0;
120 int quiet_flag = 0;
121 int stage = FIRST_STAGE;
122 int read_data_owe = 0;
123 int read_data_total = 0;
124 int write_data_owe = 0;
125 int write_data_total = 0;
126 int read_data_adjust_times = 0;
127 int write_data_adjust_times = 0;
128 int read_data_owe_GB = 0;
129 int write_data_owe_GB = 0;
130 int read_data_total_GB = 0;
131 int write_data_total_GB = 0;
132
133 int failed_create_command_num = 0;
134 int failed_other_command_num = 0;
135 int skipped_readlink_command_num = 0;
136 int skipped_custom_command_num = 0;
137 int fh_path_map_err_num = 0;
138 int skipped_fsstat_command_num = 0;
139 int missing_reply_num = 0;
140 int rename_rmdir_noent_reply_num = 0;
141 int rmdir_not_empty_reply_num = 0;
142 int loose_access_control_reply_num = 0;
143 int lookup_err_due_to_rename_num = 0;
144 int lookup_err_due_to_parallel_remove_num = 0;
145 int lookup_eaccess_enoent_mismatch_num = 0;
146 int read_io_err_num = 0;
147 int stale_fhandle_err_num = 0;
148 int proper_reply_num = 0;
149 int run_stage_proper_reply_num = 0;
150 int lookup_retry_num = 0;
151 int can_not_catch_speed_num = 0;
152 int can_not_catch_speed_num_total = 0;
153 int poll_timeout_0_num = 0;
154 int poll_timeout_pos_num = 0;
155 int abnormal_EEXIST_num = 0;
156 int abnormal_ENOENT_num = 0;
157
158 FILE * profile_fp = 0;
159 profile_t total_profile;
160 profile_t valid_get_nextop_profile;
161 profile_t invalid_get_nextop_profile;
162 profile_t valid_poll_and_get_reply_profile;
163 profile_t invalid_poll_and_get_reply_profile;
164 profile_t execute_next_request_profile;
165 profile_t receive_next_reply_profile;
166 profile_t decode_reply_profile;
167 profile_t check_reply_profile;
168 profile_t add_create_object_profile;
169 profile_t prepare_argument_profile;
170 profile_t biod_clnt_call_profile;
171 profile_t check_timeout_profile;
172 profile_t adjust_play_window_profile;
173 profile_t fgets_profile;
174 profile_t read_line_profile;
175 profile_t read_trace_profile;
176
177 int PLAY_SCALE = 1;
178 int skip_sec = 0;
179 int trace_timestamp1=0, trace_timestamp2=0;
180
181 int disk_io_status = TRACE_BUF_FULL;
182 int WARMUP_TIME = 0;    /* other values that has been used: 100 */
183 int disk_index = -1;
184
185 int TRACE_COMMAND_REPLY_FLAG_POS=36;
186 int TRACE_VERSION_POS=37;
187 int TRACE_MSGID_POS=39;
188 int TRACE_FH_SIZE=64;