add a mechanism to use random LBA in scsi read/write
[tridge/dbench.git] / dbench.c
index c5f5688c7f1a5d27f1d1ea73798c890204715260..857fc3db6f0b31a302f4fadd59106b8adf36a401 100644 (file)
--- a/dbench.c
+++ b/dbench.c
@@ -45,6 +45,8 @@ struct options options = {
        .export              = "/tmp",
        .protocol            = "tcp",
        .run_once            = 0,
+       .allow_scsi_writes   = 0,
+       .trunc_io            = 0,
 };
 
 static struct timeval tv_start;
@@ -274,6 +276,7 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const cha
                        int j;
 
                        setlinebuf(stdout);
+                       srandom(getpid() ^ time(NULL));
 
                        for (j=0;j<options.clients_per_process;j++) {
                                nb_ops->setup(&children[i*options.clients_per_process + j]);
@@ -370,6 +373,8 @@ static void process_opts(int argc, const char **argv)
                  "disable name resolution simulation", NULL },
                { "clients-per-process", 0, POPT_ARG_INT, &options.clients_per_process, 0, 
                  "number of clients per process", NULL },
+               { "trunc-io", 0, POPT_ARG_INT, &options.trunc_io, 0, 
+                 "truncate all io to this size", NULL },
                { "one-byte-write-fix", 0, POPT_ARG_NONE, &options.one_byte_write_fix, 0, 
                  "try to fix 1 byte writes", NULL },
                { "stat-check", 0, POPT_ARG_NONE, &options.stat_check, 0, 
@@ -388,6 +393,12 @@ static void process_opts(int argc, const char **argv)
                  "protocol", NULL },
                { "run-once", 0, POPT_ARG_NONE, &options.run_once, 0,
                  "Stop once reaching the end of the loadfile", NULL},
+               { "scsi",  0, POPT_ARG_STRING, &options.scsi_dev, 0, 
+                 "scsi device", NULL },
+               { "allow-scsi-writes", 0, POPT_ARG_NONE, &options.allow_scsi_writes, 0,
+                 "Allow SCSI write command to the device", NULL},
+               { "warmup", 0, POPT_ARG_INT, &options.warmup, 0, 
+                 "How meny seconds of warmup to run", NULL },
                POPT_TABLEEND
        };
        poptContext pc;
@@ -450,6 +461,8 @@ static void process_opts(int argc, const char **argv)
                options.backend = "sockio";
        } else if (strstr(argv[0], "nfsbench")) {
                options.backend = "nfs";
+       } else if (strstr(argv[0], "scsibench")) {
+               options.backend = "scsi";
        }
 
        process_opts(argc, argv);
@@ -463,6 +476,11 @@ static void process_opts(int argc, const char **argv)
        } else if (strcmp(options.backend, "nfs") == 0) {
                extern struct nb_operations nfs_ops;
                nb_ops = &nfs_ops;
+#ifdef HAVE_LINUX_SCSI_SG
+       } else if (strcmp(options.backend, "scsi") == 0) {
+               extern struct nb_operations scsi_ops;
+               nb_ops = &scsi_ops;
+#endif /* HAVE_LINUX_SCSI_SG */
        } else {
                printf("Unknown backend '%s'\n", options.backend);
                exit(1);