summaryrefslogtreecommitdiffstats
path: root/extras/benchmarking/glfs-bm.c
diff options
context:
space:
mode:
Diffstat (limited to 'extras/benchmarking/glfs-bm.c')
-rw-r--r--extras/benchmarking/glfs-bm.c254
1 files changed, 8 insertions, 246 deletions
diff --git a/extras/benchmarking/glfs-bm.c b/extras/benchmarking/glfs-bm.c
index 42e367d7f..dc717f33c 100644
--- a/extras/benchmarking/glfs-bm.c
+++ b/extras/benchmarking/glfs-bm.c
@@ -1,28 +1,18 @@
-/*
- Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
- GlusterFS 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.
-
- GlusterFS 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/>.
+/*
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
-
#define _GNU_SOURCE
#define __USE_FILE_OFFSET64
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <argp.h>
-#include <libglusterfsclient.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
@@ -42,7 +32,6 @@ struct state {
char need_iface_xattr:1;
char need_mode_posix:1;
- char need_mode_libglusterfsclient:1;
char prefix[512];
long int count;
@@ -50,7 +39,6 @@ struct state {
size_t block_size;
char *specfile;
- void *libglusterfsclient_context;
long int io_size;
};
@@ -132,21 +120,6 @@ parse_opts (int key, char *arg,
return -1;
}
break;
- case 'm':
- if (strcasecmp (arg, "posix") == 0) {
- state->need_mode_posix = 1;
- state->need_mode_libglusterfsclient = 0;
- } else if (strcasecmp (arg, "libglusterfsclient") == 0) {
- state->need_mode_posix = 0;
- state->need_mode_libglusterfsclient = 1;
- } else if (strcasecmp (arg, "both") == 0) {
- state->need_mode_posix = 1;
- state->need_mode_libglusterfsclient = 1;
- } else {
- fprintf (stderr, "unknown mode: %s\n", arg);
- return -1;
- }
- break;
case 'b':
{
size_t block_size = atoi (arg);
@@ -342,176 +315,6 @@ do_mode_posix_iface_xattr (struct state *state)
return 0;
}
-
-int
-do_mode_libglusterfsclient_iface_fileio_write (struct state *state)
-{
- long int i;
- int ret = -1;
- char block[state->block_size];
-
- for (i=0; i<state->count; i++) {
- glusterfs_file_t fd = 0;
- char filename[512];
-
- sprintf (filename, "/%s.%06ld", state->prefix, i);
-
- fd = glusterfs_glh_open (state->libglusterfsclient_context,
- filename, O_CREAT|O_WRONLY, 0);
-
- if (fd == 0) {
- fprintf (stderr, "open(%s) => %s\n", filename, strerror (errno));
- break;
- }
- ret = glusterfs_write (fd, block, state->block_size);
- if (ret == -1) {
- fprintf (stderr, "glusterfs_write(%s) => %s\n", filename, strerror (errno));
- glusterfs_close (fd);
- break;
- }
- glusterfs_close (fd);
- state->io_size += ret;
- }
-
- return i;
-}
-
-
-int
-do_mode_libglusterfsclient_iface_fileio_read (struct state *state)
-{
- long int i;
- int ret = -1;
- char block[state->block_size];
-
- for (i=0; i<state->count; i++) {
- glusterfs_file_t fd = 0;
- char filename[512];
-
- sprintf (filename, "/%s.%06ld", state->prefix, i);
-
- fd = glusterfs_glh_open (state->libglusterfsclient_context,
- filename, O_RDONLY, 0);
-
- if (fd == 0) {
- fprintf (stderr, "glusterfs_glh_open(%s) => %s\n",
- filename, strerror (errno));
- break;
- }
- ret = glusterfs_read (fd, block, state->block_size);
- if (ret == -1) {
- fprintf (stderr, "glusterfs_read(%s) => %s\n", filename,
- strerror (errno));
- glusterfs_close (fd);
- break;
- }
- glusterfs_close (fd);
- state->io_size += ret;
- }
-
- return i;
-}
-
-
-int
-do_mode_libglusterfsclient_iface_fileio (struct state *state)
-{
- if (state->need_op_write)
- MEASURE (do_mode_libglusterfsclient_iface_fileio_write, state);
-
- if (state->need_op_read)
- MEASURE (do_mode_libglusterfsclient_iface_fileio_read, state);
-
- return 0;
-}
-
-
-int
-do_mode_libglusterfsclient_iface_xattr_write (struct state *state)
-{
- long int i;
- int ret = -1;
- char block[state->block_size];
- char *dname = NULL, *dirc = NULL;
- char *bname = NULL, *basec = NULL;
-
- asprintf (&dirc, "/%s", state->prefix);
- asprintf (&basec, "/%s", state->prefix);
- dname = dirname (dirc);
- bname = basename (basec);
-
- for (i=0; i<state->count; i++) {
- char key[512];
-
- sprintf (key, "glusterfs.file.%s.%06ld", bname, i);
-
- ret = glusterfs_glh_setxattr (state->libglusterfsclient_context,
- dname, key, block,
- state->block_size, 0);
-
- if (ret < 0) {
- fprintf (stderr, "glusterfs_glh_setxattr (%s, %s, %p) "
- "=> %s\n", dname, key, block,
- strerror (errno));
- break;
- }
- state->io_size += state->block_size;
- }
-
- return i;
-
-}
-
-
-int
-do_mode_libglusterfsclient_iface_xattr_read (struct state *state)
-{
- long int i;
- int ret = -1;
- char block[state->block_size];
- char *dname = NULL, *dirc = NULL;
- char *bname = NULL, *basec = NULL;
-
- dirc = strdup (state->prefix);
- basec = strdup (state->prefix);
- dname = dirname (dirc);
- bname = basename (basec);
-
- for (i=0; i<state->count; i++) {
- char key[512];
-
- sprintf (key, "glusterfs.file.%s.%06ld", bname, i);
-
- ret = glusterfs_glh_getxattr (state->libglusterfsclient_context,
- dname, key, block,
- state->block_size);
-
- if (ret < 0) {
- fprintf (stderr, "glusterfs_glh_getxattr (%s, %s, %p) "
- "=> %s\n", dname, key, block,
- strerror (errno));
- break;
- }
- state->io_size += ret;
- }
-
- return i;
-}
-
-
-int
-do_mode_libglusterfsclient_iface_xattr (struct state *state)
-{
- if (state->need_op_write)
- MEASURE (do_mode_libglusterfsclient_iface_xattr_write, state);
-
- if (state->need_op_read)
- MEASURE (do_mode_libglusterfsclient_iface_xattr_read, state);
-
- return 0;
-}
-
-
int
do_mode_posix (struct state *state)
{
@@ -526,46 +329,8 @@ do_mode_posix (struct state *state)
int
-do_mode_libglusterfsclient (struct state *state)
-{
- glusterfs_init_params_t ctx = {
- .logfile = "/dev/stderr",
- .loglevel = "error",
- .lookup_timeout = 60,
- .stat_timeout = 60,
- };
-
- ctx.specfile = state->specfile;
- if (state->specfile) {
- state->libglusterfsclient_context = glusterfs_init (&ctx, 1);
-
- if (!state->libglusterfsclient_context) {
- fprintf (stdout, "Unable to initialize glusterfs "
- "context, skipping libglusterfsclient mode\n");
- return -1;
- }
- } else {
- fprintf (stdout, "glusterfs volume specification file not "
- "provided, skipping libglusterfsclient mode\n");
- return -1;
- }
-
- if (state->need_iface_fileio)
- do_mode_libglusterfsclient_iface_fileio (state);
-
- if (state->need_iface_xattr)
- do_mode_libglusterfsclient_iface_xattr (state);
-
- return 0;
-}
-
-
-int
do_actions (struct state *state)
{
- if (state->need_mode_libglusterfsclient)
- do_mode_libglusterfsclient (state);
-
if (state->need_mode_posix)
do_mode_posix (state);
@@ -577,8 +342,6 @@ static struct argp_option options[] = {
"WRITE|READ|BOTH - defaults to BOTH"},
{"iface", 'i', "INTERFACE", 0,
"FILEIO|XATTR|BOTH - defaults to FILEIO"},
- {"mode", 'm', "MODE", 0,
- "POSIX|LIBGLUSTERFSCLIENT|BOTH - defaults to POSIX"},
{"block", 'b', "BLOCKSIZE", 0,
"<NUM> - defaults to 4096"},
{"specfile", 's', "SPECFILE", 0,
@@ -609,7 +372,6 @@ main (int argc, char *argv[])
state.need_iface_xattr = 0;
state.need_mode_posix = 1;
- state.need_mode_libglusterfsclient = 0;
state.block_size = 4096;