[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 d063df9fc184f4a8f804253bbbf521bd03ccda6d..2a245dce1850bd7bc7e265d35d4616a828c65d3a 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 e1afeb9a4bf552ff3b8fad4060f22ffdb6a9e696..04052bf368e6a0ebd2fb17e9af1e1c57fcf13f4b 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 4be037e933ce9b490810f3a9be21df6e8fe2043b..c778206b4097c03d4224d6aff62f76fe68c9b3fc 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 20dd625dfe3bb1a77b1209916f7b7dc754a19a37..91a1d507892e80f82dca9647c7be8eb0e266a7b6 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