[PATCH] Add support for unlinking io files
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/README b/README
index d063df9..2a245dc 100644
--- a/README
+++ b/README
@@ -115,6 +115,7 @@
bwavgtime=x Average bandwidth stats over an x msec window.
create_serialize=x If 'x', serialize file creation.
create_fsync=x If 'x', run fsync() after file creation.
+ unlink If set, unlink files when done.
end_fsync=x If 'x', run fsync() after end-of-job.
loops=x Run the job 'x' number of times.
verify=x If 'x' == md5, use md5 for verifies. If 'x' == crc32,
diff --git a/filesetup.c b/filesetup.c
index e1afeb9..04052bf 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -364,6 +364,8 @@
struct fio_file *f = &td->files[i];
if (f->fd != -1) {
+ if (td->unlink && td->filetype == FIO_TYPE_FILE)
+ unlink(f->file_name);
close(f->fd);
f->fd = -1;
}
diff --git a/fio.h b/fio.h
index 4be037e..c778206 100644
--- a/fio.h
+++ b/fio.h
@@ -189,6 +189,7 @@
unsigned char sync_io;
unsigned char verify;
unsigned char use_thread;
+ unsigned char unlink;
unsigned char do_disk_util;
unsigned char override_sync;
unsigned char rand_repeatable;
diff --git a/init.c b/init.c
index 20dd625..91a1d50 100644
--- a/init.c
+++ b/init.c
@@ -47,6 +47,7 @@
#define DEF_RWMIX_READ (50)
#define DEF_NICE (0)
#define DEF_NR_FILES (1)
+#define DEF_UNLINK (0)
static int def_timeout = DEF_TIMEOUT;
@@ -937,6 +938,11 @@
fgetpos(f, &off);
continue;
}
+ if (!check_strset(p, "unlink")) {
+ td->unlink = 1;
+ fgetpos(f, &off);
+ continue;
+ }
if (!check_strstore(p, "iolog", tmpbuf)) {
if (td->write_iolog) {
log_err("fio: read iolog overrides given write_iolog\n");
@@ -1042,6 +1048,7 @@
def_thread.nice = DEF_NICE;
def_thread.rand_repeatable = DEF_RAND_REPEAT;
def_thread.nr_files = DEF_NR_FILES;
+ def_thread.unlink = DEF_UNLINK;
#ifdef FIO_HAVE_DISK_UTIL
def_thread.do_disk_util = 1;
#endif