From f11bd94d50d5995a64682f74b5f0f7509bf2c550 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 13 Mar 2007 10:16:34 +0100 Subject: [PATCH] Turn file ->open and ->unlink into flags We'll need more flags in the next commits, so do this as a preparatory patch. Signed-off-by: Jens Axboe --- filesetup.c | 8 +++++--- fio.h | 8 ++++++-- io_u.c | 6 +++--- ioengines.c | 6 +++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/filesetup.c b/filesetup.c index 948cecda..f6e99743 100644 --- a/filesetup.c +++ b/filesetup.c @@ -148,9 +148,11 @@ static int create_files(struct thread_data *td) /* * Only unlink files that we created. */ - f->unlink = 0; + f->flags &= ~FIO_FILE_UNLINK; if (file_ok(td, f)) { - f->unlink = td->unlink; + if (td->unlink) + f->flags |= FIO_FILE_UNLINK; + err = create_file(td, f); if (err) break; @@ -394,7 +396,7 @@ void close_files(struct thread_data *td) unsigned int i; for_each_file(td, f, i) { - if (!td->filename && f->unlink && + if (!td->filename && (f->flags & FIO_FILE_UNLINK) && f->filetype == FIO_TYPE_FILE) { unlink(f->file_name); f->file_name = NULL; diff --git a/fio.h b/fio.h index 3b902a8d..e451f955 100644 --- a/fio.h +++ b/fio.h @@ -218,6 +218,11 @@ enum fio_ioengine_flags { FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ }; +enum fio_file_flags { + FIO_FILE_OPEN = 1 << 0, + FIO_FILE_UNLINK = 1 << 1, +}; + /* * Each thread_data structure has a number of files associated with it, * this structure holds state information for a single file. @@ -247,8 +252,7 @@ struct fio_file { unsigned int num_maps; unsigned int last_free_lookup; - unsigned int unlink; - unsigned int open; + enum fio_file_flags flags; }; /* diff --git a/io_u.c b/io_u.c index 69f2f19d..c16128e9 100644 --- a/io_u.c +++ b/io_u.c @@ -340,7 +340,7 @@ static struct fio_file *get_next_file_rand(struct thread_data *td) fileno = (unsigned int) ((double) (td->open_files * r) / (RAND_MAX + 1.0)); f = &td->files[fileno]; - if (f->open) + if (f->flags & FIO_FILE_OPEN) return f; } while (1); } @@ -360,7 +360,7 @@ static struct fio_file *get_next_file_rr(struct thread_data *td) if (td->next_file >= td->open_files) td->next_file = 0; - if (f->open) + if (f->flags & FIO_FILE_OPEN) break; f = NULL; @@ -377,7 +377,7 @@ static struct fio_file *get_next_file(struct thread_data *td) return NULL; f = td->file_service_file; - if (f && f->open && td->file_service_left--) + if (f && (f->flags & FIO_FILE_OPEN) && td->file_service_left--) return f; if (td->file_service_type == FIO_FSERVICE_RR) diff --git a/ioengines.c b/ioengines.c index 88e91ccb..02455b85 100644 --- a/ioengines.c +++ b/ioengines.c @@ -259,7 +259,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) f->last_free_lookup = 0; f->last_completed_pos = 0; f->last_pos = 0; - f->open = 1; + f->flags |= FIO_FILE_OPEN; if (f->file_map) memset(f->file_map, 0, f->num_maps * sizeof(long)); @@ -270,10 +270,10 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) void td_io_close_file(struct thread_data *td, struct fio_file *f) { - if (f->open) { + if (f->flags & FIO_FILE_OPEN) { if (td->io_ops->close_file) td->io_ops->close_file(td, f); td->nr_open_files--; - f->open = 0; + f->flags &= ~FIO_FILE_OPEN; } } -- 2.25.1