[PATCH] Add support for unlinking io files
authorJens Axboe <jens.axboe@oracle.com>
Wed, 18 Oct 2006 12:16:42 +0000 (14:16 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 18 Oct 2006 12:16:42 +0000 (14:16 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
README
filesetup.c
fio.h
init.c

diff --git a/README b/README
index d063df9..2a245dc 100644 (file)
--- a/README
+++ b/README
@@ -115,6 +115,7 @@ The job file parameters are:
        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,
index e1afeb9..04052bf 100644 (file)
@@ -364,6 +364,8 @@ void close_files(struct thread_data *td)
                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 (file)
--- a/fio.h
+++ b/fio.h
@@ -189,6 +189,7 @@ struct thread_data {
        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 (file)
--- 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 @@ int parse_jobs_ini(char *file, int stonewall_flag)
                                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 @@ static int fill_def_thread(void)
        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