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