extern int fio_gf_get_file_size(struct thread_data *td, struct fio_file *f);
extern int fio_gf_open_file(struct thread_data *td, struct fio_file *f);
extern int fio_gf_close_file(struct thread_data *td, struct fio_file *f);
+extern int fio_gf_unlink_file(struct thread_data *td, struct fio_file *f);
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,
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);
free(g);
}
td->io_ops->data = NULL;
- f->engine_data = 0;
return ret;
}
.queue = fio_gf_async_queue,
.open_file = fio_gf_open_file,
.close_file = fio_gf_close_file,
+ .unlink_file = fio_gf_unlink_file,
.get_file_size = fio_gf_get_file_size,
.getevents = fio_gf_getevents,
.event = fio_gf_event,
.queue = fio_gf_queue,
.open_file = fio_gf_open_file,
.close_file = fio_gf_close_file,
+ .unlink_file = fio_gf_unlink_file,
.get_file_size = fio_gf_get_file_size,
.options = gfapi_options,
.option_struct_size = sizeof(struct gf_options),
if (unlink_file || new_layout) {
dprint(FD_FILE, "layout unlink %s\n", f->file_name);
- if ((unlink(f->file_name) < 0) && (errno != ENOENT)) {
+ if ((td_io_unlink_file(td, f) < 0) && (errno != ENOENT)) {
td_verror(td, errno, "unlink");
return 1;
}
if (td->terminate) {
dprint(FD_FILE, "terminate unlink %s\n", f->file_name);
- unlink(f->file_name);
+ td_io_unlink_file(td, f);
} else if (td->o.create_fsync) {
if (fsync(f->fd) < 0) {
td_verror(td, errno, "fsync");
dprint(FD_FILE, "close files\n");
for_each_file(td, f, i) {
+ if (td->o.unlink && f->filetype == FIO_TYPE_FILE) {
+ dprint(FD_FILE, "free unlink %s\n", f->file_name);
+ td_io_unlink_file(td, f);
+ }
+
if (fio_file_open(f))
td_io_close_file(td, f);
if (td->o.unlink && f->filetype == FIO_TYPE_FILE) {
dprint(FD_FILE, "free unlink %s\n", f->file_name);
- unlink(f->file_name);
+ td_io_unlink_file(td, f);
}
sfree(f->file_name);
int (*open_file)(struct thread_data *, struct fio_file *);
int (*close_file)(struct thread_data *, struct fio_file *);
int (*invalidate)(struct thread_data *, struct fio_file *);
+ int (*unlink_file)(struct thread_data *, struct fio_file *);
int (*get_file_size)(struct thread_data *, struct fio_file *);
void (*terminate)(struct thread_data *);
int (*io_u_init)(struct thread_data *, struct io_u *);
extern int __must_check td_io_commit(struct thread_data *);
extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
extern int td_io_close_file(struct thread_data *, struct fio_file *);
+extern int td_io_unlink_file(struct thread_data *, struct fio_file *);
extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *);
extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *);
return put_file(td, f);
}
+int td_io_unlink_file(struct thread_data *td, struct fio_file *f)
+{
+ if (td->io_ops->unlink_file)
+ return td->io_ops->unlink_file(td, f);
+ else
+ return unlink(f->file_name);
+}
+
int td_io_get_file_size(struct thread_data *td, struct fio_file *f)
{
if (!td->io_ops->get_file_size)
td_io_close_file(td, f);
break;
case FIO_LOG_UNLINK_FILE:
- unlink(f->file_name);
+ td_io_unlink_file(td, f);
break;
default:
log_err("fio: bad file action %d\n", ipo->file_action);