[PATCH] File close fix
authorJens Axboe <jens.axboe@oracle.com>
Thu, 23 Nov 2006 11:23:12 +0000 (12:23 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 23 Nov 2006 11:23:12 +0000 (12:23 +0100)
We should unlink and invalidate a closed file, to less impact on
other threads or pending jobs.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index fd50b6f..705eb4a 100644 (file)
@@ -408,22 +408,22 @@ void close_files(struct thread_data *td)
 
        for_each_file(td, f, i) {
                if (f->fd != -1) {
-                       if (td->unlink && td->filetype == FIO_TYPE_FILE &&
-                           td->filename) {
-                               unlink(f->file_name);
-                               td->filename = NULL;
-                       }
-                       free(f->file_name);
-                       f->file_name = NULL;
+                       file_invalidate_cache(td, f);
                        close(f->fd);
                        f->fd = -1;
                }
+               if (td->unlink && td->filetype == FIO_TYPE_FILE) {
+                       unlink(f->file_name);
+                       free(f->file_name);
+                       f->file_name = NULL;
+               }
                if (f->mmap) {
                        munmap(f->mmap, f->file_size);
                        f->mmap = NULL;
                }
        }
 
+       td->filename = NULL;
        free(td->files);
        td->files = NULL;
        td->nr_files = 0;