*/
#include "gfapi.h"
+#include "../optgroup.h"
struct fio_option gfapi_options[] = {
{
dprint(FD_IO, "fio setup\n");
- if (td->io_ops->data)
+ if (td->io_ops_data)
return 0;
g = malloc(sizeof(struct gf_data));
goto cleanup;
}
dprint(FD_FILE, "fio setup %p\n", g->fs);
- td->io_ops->data = g;
+ td->io_ops_data = g;
return 0;
cleanup:
if (g->fs)
glfs_fini(g->fs);
free(g);
- td->io_ops->data = NULL;
+ td->io_ops_data = NULL;
return r;
}
void fio_gf_cleanup(struct thread_data *td)
{
- struct gf_data *g = td->io_ops->data;
+ struct gf_data *g = td->io_ops_data;
if (g) {
if (g->aio_events)
if (g->fs)
glfs_fini(g->fs);
free(g);
- td->io_ops->data = NULL;
+ td->io_ops_data = NULL;
}
}
{
struct stat buf;
int ret;
- struct gf_data *g = td->io_ops->data;
+ struct gf_data *g = td->io_ops_data;
dprint(FD_FILE, "get file size %s\n", f->file_name);
int flags = 0;
int ret = 0;
- struct gf_data *g = td->io_ops->data;
+ struct gf_data *g = td->io_ops_data;
struct stat sb = { 0, };
if (td_write(td)) {
if (td_read(td)) {
if (glfs_lstat(g->fs, f->file_name, &sb)
|| sb.st_size < f->real_file_size) {
- dprint(FD_FILE, "fio extend file %s from %ld to %ld\n",
- f->file_name, sb.st_size, f->real_file_size);
+ dprint(FD_FILE, "fio extend file %s from %jd to %" PRIu64 "\n",
+ f->file_name, (intmax_t) sb.st_size, f->real_file_size);
ret = glfs_ftruncate(g->fd, f->real_file_size);
if (ret) {
- log_err("failed fio extend file %s to %ld\n",
+ log_err("failed fio extend file %s to %" PRIu64 "\n",
f->file_name, f->real_file_size);
} else {
unsigned long long left;
r = glfs_write(g->fd, b, bs, 0);
dprint(FD_IO,
- "fio write %d of %ld file %s\n",
+ "fio write %d of %" PRIu64 " file %s\n",
r, f->real_file_size,
f->file_name);
free(b);
glfs_lseek(g->fd, 0, SEEK_SET);
- if (td->terminate) {
+ if (td->terminate && td->o.unlink) {
dprint(FD_FILE, "terminate unlink %s\n",
f->file_name);
- unlink(f->file_name);
+ glfs_unlink(g->fs, f->file_name);
} else if (td->o.create_fsync) {
if (glfs_fsync(g->fd) < 0) {
dprint(FD_FILE,
int fio_gf_close_file(struct thread_data *td, struct fio_file *f)
{
int ret = 0;
- struct gf_data *g = td->io_ops->data;
+ struct gf_data *g = td->io_ops_data;
dprint(FD_FILE, "fd close %s\n", f->file_name);
if (g) {
if (g->fd && glfs_close(g->fd) < 0)
ret = errno;
+ g->fd = NULL;
+ }
+
+ return ret;
+}
+
+int fio_gf_unlink_file(struct thread_data *td, struct fio_file *f)
+{
+ int ret = 0;
+ struct gf_data *g = td->io_ops_data;
+
+ dprint(FD_FILE, "fd unlink %s\n", f->file_name);
+
+ if (g) {
+ if (g->fd && glfs_close(g->fd) < 0)
+ ret = errno;
+
+ glfs_unlink(g->fs, f->file_name);
if (g->fs)
glfs_fini(g->fs);
g->fd = NULL;
free(g);
}
- td->io_ops->data = NULL;
- f->engine_data = 0;
+ td->io_ops_data = NULL;
return ret;
}