projects
/
fio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6aa5650
)
respond to get file size
author
chenh
<hchen@redhat.com>
Fri, 28 Mar 2014 19:07:51 +0000
(15:07 -0400)
committer
chenh
<hchen@redhat.com>
Fri, 28 Mar 2014 19:07:51 +0000
(15:07 -0400)
engines/glusterfs.c
patch
|
blob
|
blame
|
history
diff --git
a/engines/glusterfs.c
b/engines/glusterfs.c
index b5c2d690d2a7b72f2098318bb400c9a672c29ea6..62893af9c3d5b05cb33a83e67cc23d8d282c7ca1 100644
(file)
--- a/
engines/glusterfs.c
+++ b/
engines/glusterfs.c
@@
-6,7
+6,7
@@
*/
#include <glusterfs/api/glfs.h>
*/
#include <glusterfs/api/glfs.h>
-#include <glusterfs/api/glfs-handles.h>
+
#include "../fio.h"
struct gf_options {
#include "../fio.h"
struct gf_options {
@@
-19,7
+19,6
@@
struct gf_data {
glfs_t *fs;
glfs_fd_t *fd;
};
glfs_t *fs;
glfs_fd_t *fd;
};
-
static struct fio_option options[] = {
{
.name = "volume",
static struct fio_option options[] = {
{
.name = "volume",
@@
-49,9
+48,6
@@
static int fio_gf_setup(struct thread_data *td)
int r = 0;
struct gf_data *g = NULL;
struct gf_options *opt = td->eo;
int r = 0;
struct gf_data *g = NULL;
struct gf_options *opt = td->eo;
- struct stat sb = {0, };
-
- dprint(FD_IO, "fio setup\n");
if (td->io_ops->data)
return 0;
if (td->io_ops->data)
return 0;
@@
-68,40
+64,41
@@
static int fio_gf_setup(struct thread_data *td)
log_err("glfs_new failed.\n");
goto cleanup;
}
log_err("glfs_new failed.\n");
goto cleanup;
}
- glfs_set_logging (g->fs, "/tmp/fio_gfapi.log", 7);
+
/* default to tcp */
/* default to tcp */
- r = glfs_set_volfile_server(g->fs, "tcp", opt->gf_brick,
0
);
+ r = glfs_set_volfile_server(g->fs, "tcp", opt->gf_brick,
24007
);
if (r){
log_err("glfs_set_volfile_server failed.\n");
goto cleanup;
}
r = glfs_init(g->fs);
if (r){
if (r){
log_err("glfs_set_volfile_server failed.\n");
goto cleanup;
}
r = glfs_init(g->fs);
if (r){
- log_err("glfs_init failed. Is glusterd running on brick?\n");
- goto cleanup;
- }
- sleep(2);
- r = glfs_lstat (g->fs, ".", &sb);
- if (r){
- log_err("glfs_lstat failed.\n");
+ log_err("glfs_init failed.\n");
goto cleanup;
}
goto cleanup;
}
- dprint(FD_FILE, "fio setup %p\n", g->fs);
+ glfs_set_logging (g->fs, "/dev/stderr", 7);
+
td->io_ops->data = g;
cleanup:
td->io_ops->data = g;
cleanup:
- if (r){
- if (g){
- if (g->fs){
- glfs_fini(g->fs);
- }
- free(g);
+ if (g){
+ if (g->fs){
+ glfs_fini(g->fs);
}
}
+ free(g);
}
return r;
}
static void fio_gf_cleanup(struct thread_data *td)
{
}
return r;
}
static void fio_gf_cleanup(struct thread_data *td)
{
+ struct gf_data *g = td->io_ops->data;
+
+ if (g){
+ if (g->fs){
+ glfs_fini(g->fs);
+ }
+ free(g);
+ }
}
static int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f)
}
static int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f)
@@
-110,21
+107,21
@@
static int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f)
int ret;
struct gf_data *g = td->io_ops->data;
int ret;
struct gf_data *g = td->io_ops->data;
+<<<<<<< HEAD
dprint(FD_FILE, "get file size %s\n", f->file_name);
if (!g || !g->fs)
{
dprint(FD_FILE, "get file size %s\n", f->file_name);
if (!g || !g->fs)
{
- f->real_file_size = 0;
- fio_file_set_size_known(f);
+ return 0;
}
}
+=======
+>>>>>>> parent of 6aa5650... make glfs call per thread based
if (fio_file_size_known(f))
return 0;
ret = glfs_lstat (g->fs, f->file_name, &buf);
if (fio_file_size_known(f))
return 0;
ret = glfs_lstat (g->fs, f->file_name, &buf);
- if (ret < 0){
- log_err("glfs_lstat failed.\n");
+ if (ret < 0)
return ret;
return ret;
- }
f->real_file_size = buf.st_size;
fio_file_set_size_known(f);
f->real_file_size = buf.st_size;
fio_file_set_size_known(f);
@@
-135,12
+132,11
@@
static int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f)
static int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
{
static int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
{
-
- int flags = 0;
- int ret = 0;
struct gf_data *g = td->io_ops->data;
struct gf_data *g = td->io_ops->data;
+ int flags = 0;
+
+ dprint(FD_FILE, "fd open %s\n", f->file_name);
- dprint(FD_FILE, "fio open %s\n", f->file_name);
if (td_write(td)) {
if (!read_only)
flags = O_RDWR;
if (td_write(td)) {
if (!read_only)
flags = O_RDWR;
@@
-150,16
+146,12
@@
static int fio_gf_open_file(struct thread_data *td, struct fio_file *f)
else
flags = O_RDONLY;
}
else
flags = O_RDONLY;
}
- g->fd = glfs_creat(g->fs, f->file_name, flags, 0644);
- if (!g->fd){
- log_err("glfs_creat failed.\n");
- ret = errno;
- }
- dprint(FD_FILE, "fio %p created %s\n", g->fs, f->file_name);
- f->fd = -1;
- f->shadow_fd = -1;
+ if (td->o.create_on_open)
+ flags |= O_CREAT;
- return ret;
+ g->fd = glfs_open(g->fs, f->file_name, flags);
+ f->fd = -1;
+ return 0;
}
static int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
}
static int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
@@
-169,15
+161,10
@@
static int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
dprint(FD_FILE, "fd close %s\n", f->file_name);
dprint(FD_FILE, "fd close %s\n", f->file_name);
- if (g->fd && glfs_close(g->fd) < 0)
- ret = errno;
-
- if (g->fs)
- glfs_fini(g->fs);
+ if (!g->fd && glfs_close(g->fd) < 0)
+ ret = errno;
g->fd = NULL;
g->fd = NULL;
- free(g);
- td->io_ops->data = NULL;
f->engine_data = 0;
return ret;
f->engine_data = 0;
return ret;
@@
-189,8
+176,6
@@
static int fio_gf_prep(struct thread_data *td, struct io_u *io_u)
struct fio_file *f = io_u->file;
struct gf_data *g = td->io_ops->data;
struct fio_file *f = io_u->file;
struct gf_data *g = td->io_ops->data;
- dprint(FD_FILE, "fio prep\n");
-
if (!ddir_rw(io_u->ddir))
return 0;
if (!ddir_rw(io_u->ddir))
return 0;
@@
-210,7
+195,6
@@
static int fio_gf_queue(struct thread_data *td, struct io_u *io_u)
struct gf_data *g = td->io_ops->data;
int ret = 0;
struct gf_data *g = td->io_ops->data;
int ret = 0;
- dprint(FD_FILE, "fio queue len %lu\n", io_u->xfer_buflen);
fio_ro_check(td, io_u);
if (io_u->ddir == DDIR_READ)
fio_ro_check(td, io_u);
if (io_u->ddir == DDIR_READ)
@@
-221,7
+205,6
@@
static int fio_gf_queue(struct thread_data *td, struct io_u *io_u)
log_err("unsupported operation.\n");
return -EINVAL;
}
log_err("unsupported operation.\n");
return -EINVAL;
}
-
if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir))
LAST_POS(io_u->file) = io_u->offset + ret;
if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir))
LAST_POS(io_u->file) = io_u->offset + ret;
@@
-234,10
+217,8
@@
static int fio_gf_queue(struct thread_data *td, struct io_u *io_u)
io_u->error = errno;
}
io_u->error = errno;
}
- if (io_u->error){
- log_err("IO failed.\n");
+ if (io_u->error)
td_verror(td, io_u->error, "xfer");
td_verror(td, io_u->error, "xfer");
- }
return FIO_Q_COMPLETED;
return FIO_Q_COMPLETED;
@@
-246,7
+227,7
@@
static int fio_gf_queue(struct thread_data *td, struct io_u *io_u)
static struct ioengine_ops ioengine = {
.name = "gfapi",
.version = FIO_IOOPS_VERSION,
static struct ioengine_ops ioengine = {
.name = "gfapi",
.version = FIO_IOOPS_VERSION,
- .
init
= fio_gf_setup,
+ .
setup
= fio_gf_setup,
.cleanup = fio_gf_cleanup,
.prep = fio_gf_prep,
.queue = fio_gf_queue,
.cleanup = fio_gf_cleanup,
.prep = fio_gf_prep,
.queue = fio_gf_queue,
@@
-255,7
+236,7
@@
static struct ioengine_ops ioengine = {
.get_file_size = fio_gf_get_file_size,
.options = options,
.option_struct_size = sizeof(struct gf_options),
.get_file_size = fio_gf_get_file_size,
.options = options,
.option_struct_size = sizeof(struct gf_options),
- .flags = FIO_SYNCIO
| FIO_DISKLESSIO
,
+ .flags = FIO_SYNCIO,
};
static void fio_init fio_gf_register(void)
};
static void fio_init fio_gf_register(void)