LIBNFS_OBJ = libnfs.o mount_client.o nfs_client.o mount_xdr.o nfs_xdr.o
-DB_OBJS = fileio.o util.o dbench.o child.o system.o snprintf.o
-TB_OBJS = sockio.o util.o dbench.o child.o socklib.o snprintf.o
-NFS_OBJS = nfsio.o util.o dbench.o child.o socklib.o snprintf.o libnfs.a
+DB_OBJS = fileio.o util.o dbench.o child.o system.o snprintf.o sockio.o nfsio.o libnfs.a socklib.o
SRV_OBJS = util.o tbench_srv.o socklib.o
-all: dbench tbench tbench_srv nfsbench
+all: dbench tbench_srv
dbench: $(DB_OBJS)
$(CC) -o $@ $(DB_OBJS) $(LIBS)
-tbench: $(TB_OBJS)
- $(CC) -o $@ $(TB_OBJS) $(LIBS)
-
tbench_srv: $(SRV_OBJS)
$(CC) -o $@ $(SRV_OBJS) $(LIBS)
-nfsbench: $(NFS_OBJS)
- $(CC) -o $@ $(NFS_OBJS) $(LIBS)
-
-
libnfs.a: $(LIBNFS_OBJ)
@echo Creating library $@
ar r libnfs.a $(LIBNFS_OBJ)
# Careful here: don't install client.txt over itself.
install: all
${INSTALLCMD} -d $(bindir) $(datadir) $(mandir)
- ${INSTALLCMD} dbench tbench tbench_srv $(bindir)
+ ${INSTALLCMD} dbench tbench_srv $(bindir)
${INSTALLCMD} loadfiles/client.txt $(datadir)
${INSTALLCMD} loadfiles/nfs.txt $(datadir)
${INSTALLCMD} -m644 dbench.1 $(mandir)
ln -sf dbench.1 $(mandir)/tbench.1
ln -sf dbench.1 $(mandir)/tbench_srv.1
+ ln -sf $(bindir)/dbench $(bindir)/tbench
+ ln -sf $(bindir)/dbench $(bindir)/nfsbench
clean:
- rm -f *.o *~ dbench tbench tbench_srv libnfs.a
+ rm -f *.[ao] *~ dbench tbench_srv
rm -f mount.h mount_xdr.c mount_client.c
rm -f nfs.h nfs_xdr.c nfs_client.c
#include <sys/sem.h>
struct options options = {
+ .backend = "fileio",
.timelimit = 600,
.loadfile = DATADIR "/client.txt",
.directory = ".",
static struct timeval tv_end;
static int barrier=-1;
static double throughput;
+struct nb_operations *nb_ops;
static FILE *open_loadfile(void)
{
int i;
printf(" Operation Count AvgLat MaxLat\n");
printf(" --------------------------------------------------\n");
- for (i=0;nb_ops.ops[i].name;i++) {
+ for (i=0;nb_ops->ops[i].name;i++) {
struct op *op1, *op_all;
op1 = &ops[i];
op_all = &ops_all[i];
if (op_all->count == 0) continue;
printf(" %-22s %7u %9.03f %9.03f\n",
- nb_ops.ops[i].name, op1->count,
+ nb_ops->ops[i].name, op1->count,
1000*op1->total_time/op1->count,
op1->max_latency*1000);
}
struct child_struct *child;
memset(sum, 0, sizeof(sum));
- for (i=0;nb_ops.ops[i].name;i++) {
+ for (i=0;nb_ops->ops[i].name;i++) {
op1 = &sum[i];
for (j=0;j<options.nprocs * options.clients_per_process;j++) {
child = &children[j];
setlinebuf(stdout);
for (j=0;j<options.clients_per_process;j++) {
- nb_ops.setup(&children[i*options.clients_per_process + j]);
+ nb_ops->setup(&children[i*options.clients_per_process + j]);
}
sbuf.sem_op = 0;
}
-static void show_usage(void)
-{
- printf("usage: dbench [OPTIONS] nprocs\n" \
- "usage: tbench [OPTIONS] nprocs <server>\n" \
- "options:\n" \
- " -v show version\n" \
- " -t timelimit run time in seconds (default 600)\n" \
- " -D directory base directory to run in\n" \
- " -c loadfile set location of the loadfile\n" \
- " -R target rate (MByte/sec)\n" \
- " -s synchronous file IO\n" \
- " -F fsync on write\n" \
- " -S synchronous directories (mkdir, unlink...)\n" \
- " -x enable EA support\n" \
- " -T options set socket options for tbench\n");
- exit(1);
-}
-
-
-static int process_opts(int argc, const char **argv)
+static void process_opts(int argc, const char **argv)
{
const char **extra_argv;
int extra_argc = 0;
struct poptOption popt_options[] = {
POPT_AUTOHELP
+ { "backend", 'B', POPT_ARG_STRING, &options.backend, 0,
+ "dbench backend (fileio, sockio, nfs)", "string" },
{ "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0,
"timelimit", "integer" },
{ "loadfile", 'c', POPT_ARG_STRING, &options.loadfile, 0,
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
while ((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- default:
- fprintf(stderr, "Invalid option %s: %s\n",
- poptBadOption(pc, 0), poptStrerror(opt));
+ if (strcmp(poptBadOption(pc, 0), "-h") == 0) {
+ poptPrintHelp(pc, stdout, 0);
exit(1);
}
+ fprintf(stderr, "Invalid option %s: %s\n",
+ poptBadOption(pc, 0), poptStrerror(opt));
+ exit(1);
}
/* setup the remaining options for the main program to use */
if (extra_argc >= 2) {
options.server = extra_argv[1];
}
-
- return 1;
}
printf("dbench version %s - Copyright Andrew Tridgell 1999-2004\n\n", VERSION);
- if (!process_opts(argc, argv))
- show_usage();
+ if (strstr(argv[0], "dbench")) {
+ options.backend = "fileio";
+ } else if (strstr(argv[0], "tbench")) {
+ options.backend = "sockio";
+ } else if (strstr(argv[0], "nfsbench")) {
+ options.backend = "nfs";
+ }
+
+ process_opts(argc, argv);
+
+ if (strcmp(options.backend, "fileio") == 0) {
+ extern struct nb_operations fileio_ops;
+ nb_ops = &fileio_ops;
+ } else if (strcmp(options.backend, "sockio") == 0) {
+ extern struct nb_operations sockio_ops;
+ nb_ops = &sockio_ops;
+ } else if (strcmp(options.backend, "nfs") == 0) {
+ extern struct nb_operations nfs_ops;
+ nb_ops = &nfs_ops;
+ } else {
+ printf("Unknown backend '%s'\n", options.backend);
+ exit(1);
+ }
if (options.warmup == -1) {
options.warmup = options.timelimit / 5;