remove an invalid comment
[amitay/dbench.git] / dbench.h
1 /* 
2    dbench version 2
3    Copyright (C) Andrew Tridgell 1999
4    
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9    
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14    
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18 #define _FILE_OFFSET_BITS 64
19
20 #include "config.h"
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <stddef.h>
24 #include <signal.h>
25 #include <unistd.h>
26 #include <string.h>
27 #include <ctype.h>
28 #include <dirent.h>
29 #include <sys/stat.h>
30 #include <sys/time.h>
31 #include <sys/wait.h>
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <fcntl.h>
35 #include <time.h>
36 #include <sys/ipc.h>
37 #include <sys/shm.h>
38 #include <sys/mman.h>
39
40 #ifdef HAVE_SYS_VFS_H
41 #include <sys/vfs.h>
42 #endif
43
44 #ifdef HAVE_SYS_STATVFS_H
45 #include <sys/statvfs.h>
46 #endif
47
48 #include <sys/param.h>
49 #ifdef HAVE_SYS_MOUNT_H
50 #include <sys/mount.h>
51 #endif
52 #include <utime.h>
53 #include <errno.h>
54 #include <strings.h>
55 #ifdef HAVE_STDINT_H
56 #include <stdint.h>
57 #endif
58 #include <netinet/in.h>
59 #include <netinet/tcp.h>
60 #include <netdb.h>
61
62 #if HAVE_ATTR_XATTR_H
63 #include <attr/xattr.h>
64 #elif HAVE_SYS_XATTR_H
65 #include <sys/xattr.h>
66 #elif HAVE_SYS_ATTRIBUTES_H
67 #include <sys/attributes.h>
68 #endif
69
70 #ifdef HAVE_SYS_EXTATTR_H
71 #include <sys/extattr.h>
72 #endif
73
74 #ifdef HAVE_SYS_UIO_H
75 #include <sys/uio.h>
76 #endif
77
78 #ifndef MSG_WAITALL
79 #define MSG_WAITALL 0x100
80 #endif
81
82 #define PRINT_FREQ 1
83
84 #ifndef MIN
85 #define MIN(x,y) ((x)<(y)?(x):(y))
86 #endif
87
88 #define TCP_PORT 7003
89 #define TCP_OPTIONS "TCP_NODELAY SO_REUSEADDR"
90
91 #define BOOL int
92 #define True 1
93 #define False 0
94 #define uint32 unsigned
95
96 struct op {
97         unsigned count;
98         double total_time;
99         double max_latency;
100 };
101
102 #define ZERO_STRUCT(x) memset(&(x), 0, sizeof(x))
103
104 #define MAX_OPS 100
105
106 struct child_struct {
107         int id;
108         int failed;
109         int line;
110         int done;
111         int cleanup;
112         int cleanup_finished;
113         const char *directory;
114         double bytes;
115         double bytes_done_warmup;
116         double max_latency;
117         double worst_latency;
118         struct timeval starttime;
119         struct timeval lasttime;
120         off_t bytes_since_fsync;
121         char *cname;
122         struct {
123                 double last_bytes;
124                 struct timeval last_time;
125         } rate;
126         struct op ops[MAX_OPS];
127         void *private;
128 };
129
130 struct options {
131         const char *backend;
132         int nprocs;
133         int sync_open;
134         int sync_dirs;
135         int do_fsync;
136         int no_resolve;
137         int fsync_frequency;
138         char *tcp_options;
139         int timelimit;
140         int warmup;
141         const char *directory;
142         char *loadfile;
143         double targetrate;
144         int ea_enable;
145         const char *server;
146         int clients_per_process;
147         int one_byte_write_fix;
148         int stat_check;
149         int fake_io;
150         int skip_cleanup;
151         int per_client_results;
152         const char *export;
153         const char *protocol;
154         int run_once;
155         int allow_scsi_writes;
156         int trunc_io;
157         const char *scsi_dev;
158         const char *iscsi_portal;
159         const char *iscsi_target;
160         int iscsi_lun;
161         int iscsi_port;
162         int machine_readable;
163         const char *smb_share;
164         const char *smb_user;
165 };
166
167
168 struct dbench_op {
169         struct child_struct *child;
170         const char *op;
171         const char *fname;
172         const char *fname2;
173         const char *status;
174         int64_t params[10];
175 };
176
177 struct backend_op {
178         const char *name;
179         void (*fn)(struct dbench_op *);
180 };
181
182 struct nb_operations {
183         const char *backend_name;       
184         struct backend_op *ops;
185         int (*init)(void);
186         void (*setup)(struct child_struct *child);
187         void (*cleanup)(struct child_struct *child);
188 };
189 extern struct nb_operations *nb_ops;
190
191 /* CreateDisposition field. */
192 #define FILE_SUPERSEDE 0
193 #define FILE_OPEN 1
194 #define FILE_CREATE 2
195 #define FILE_OPEN_IF 3
196 #define FILE_OVERWRITE 4
197 #define FILE_OVERWRITE_IF 5
198
199 /* CreateOptions field. */
200 #define FILE_DIRECTORY_FILE       0x0001
201 #define FILE_WRITE_THROUGH        0x0002
202 #define FILE_SEQUENTIAL_ONLY      0x0004
203 #define FILE_NON_DIRECTORY_FILE   0x0040
204 #define FILE_NO_EA_KNOWLEDGE      0x0200
205 #define FILE_EIGHT_DOT_THREE_ONLY 0x0400
206 #define FILE_RANDOM_ACCESS        0x0800
207 #define FILE_DELETE_ON_CLOSE      0x1000
208
209 #ifndef O_DIRECTORY
210 #define O_DIRECTORY    0200000
211 #endif
212
213 struct nfsio;
214
215 #include "proto.h"
216
217 extern struct options options;