Skip to content

Commit

Permalink
engines/fileoperations: use local var for ioengine data
Browse files Browse the repository at this point in the history
Improve code readability by using a local variable for ioengine data.

Signed-off-by: Vincent Fu <[email protected]>
  • Loading branch information
vincentkfu committed Mar 22, 2024
1 parent 2dee6cc commit caa20ee
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions engines/fileoperations.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static int open_file(struct thread_data *td, struct fio_file *f)
{
struct timespec start;
int do_lat = !td->o.disable_lat;
struct fc_data *fcd = td->io_ops_data;

dprint(FD_FILE, "fd open %s\n", f->file_name);

Expand All @@ -105,9 +106,9 @@ static int open_file(struct thread_data *td, struct fio_file *f)
if (do_lat)
fio_gettime(&start, NULL);

if (((struct fc_data *)td->io_ops_data)->op_engine == FILE_OP_ENGINE)
if (fcd->op_engine == FILE_OP_ENGINE)
f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
else if (((struct fc_data *)td->io_ops_data)->op_engine == DIR_OP_ENGINE)
else if (fcd->op_engine == DIR_OP_ENGINE)
f->fd = fio_mkdir(f->file_name, S_IFDIR);
else {
log_err("fio: unknown file/directory operation engine\n");
Expand Down Expand Up @@ -209,6 +210,7 @@ static int delete_file(struct thread_data *td, struct fio_file *f)
{
struct timespec start;
int do_lat = !td->o.disable_lat;
struct fc_data *fcd = td->io_ops_data;
int ret;

dprint(FD_FILE, "fd delete %s\n", f->file_name);
Expand All @@ -225,9 +227,9 @@ static int delete_file(struct thread_data *td, struct fio_file *f)
if (do_lat)
fio_gettime(&start, NULL);

if (((struct fc_data *)td->io_ops_data)->op_engine == FILE_OP_ENGINE)
if (fcd->op_engine == FILE_OP_ENGINE)
ret = unlink(f->file_name);
else if (((struct fc_data *)td->io_ops_data)->op_engine == DIR_OP_ENGINE)
else if (fcd->op_engine == DIR_OP_ENGINE)
ret = rmdir(f->file_name);
else {
log_err("fio: unknown file/directory operation engine\n");
Expand Down

0 comments on commit caa20ee

Please sign in to comment.