X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=793b08d07549c895944f406e7afcdb7d7765e840;hp=3217e4f3080cad0e782fc22e302304e49ae6531e;hb=79591fa9555024aa9564656bbbb9d4c828a3e189;hpb=957c81b9d0d090162366dcf0bec308afb2400464 diff --git a/filesetup.c b/filesetup.c index 3217e4f3..793b08d0 100644 --- a/filesetup.c +++ b/filesetup.c @@ -130,6 +130,9 @@ static int extend_file(struct thread_data *td, struct fio_file *f) } #endif /* CONFIG_POSIX_FALLOCATE */ + /* + * If our jobs don't require regular files initially, we're done. + */ if (!new_layout) goto done; @@ -381,6 +384,10 @@ static int get_file_size(struct thread_data *td, struct fio_file *f) return 1; /* avoid offset extends end error message */ } + /* + * Leave ->real_file_size with 0 since it could be expectation + * of initial setup for regular files. + */ if (ret) return ret; @@ -659,6 +666,10 @@ open_again: return 0; } +/* + * This function i.e. get_file_size() is the default .get_file_size + * implementation of majority of I/O engines. + */ int generic_get_file_size(struct thread_data *td, struct fio_file *f) { return get_file_size(td, f); @@ -686,6 +697,13 @@ static int get_file_sizes(struct thread_data *td) clear_error(td); } + /* + * There are corner cases where we end up with -1 for + * ->real_file_size due to unsupported file type, etc. + * We then just set to size option value divided by number + * of files, similar to the way file ->io_size is set. + * stat(2) failure doesn't set ->real_file_size to -1. + */ if (f->real_file_size == -1ULL && td->o.size) f->real_file_size = td->o.size / td->o.nr_files; } @@ -802,7 +820,9 @@ int setup_files(struct thread_data *td) goto done; /* - * if ioengine defines a setup() method, it's responsible for + * Find out physical size of files or devices for this thread, + * before we determine I/O size and range of our targets. + * If ioengine defines a setup() method, it's responsible for * opening the files and setting f->real_file_size to indicate * the valid range for that file. */ @@ -843,7 +863,7 @@ int setup_files(struct thread_data *td) /* * Calculate per-file size and potential extra size for the - * first files, if needed. + * first files, if needed (i.e. if we don't have a fixed size). */ if (!o->file_size_low && o->nr_files) { uint64_t all_fs; @@ -865,9 +885,17 @@ int setup_files(struct thread_data *td) for_each_file(td, f, i) { f->file_offset = get_start_offset(td, f); + /* + * Update ->io_size depending on options specified. + * ->file_size_low being 0 means filesize option isn't set. + * Non zero ->file_size_low equals ->file_size_high means + * filesize option is set in a fixed size format. + * Non zero ->file_size_low not equals ->file_size_high means + * filesize option is set in a range format. + */ if (!o->file_size_low) { /* - * no file size range given, file size is equal to + * no file size or range given, file size is equal to * total size divided by number of files. If that is * zero, set it to the real file size. If the size * doesn't divide nicely with the min blocksize, @@ -950,7 +978,9 @@ int setup_files(struct thread_data *td) } /* - * See if we need to extend some files + * See if we need to extend some files, typically needed when our + * target regular files don't exist yet, but our jobs require them + * initially due to read I/Os. */ if (need_extend) { temp_stall_ts = 1;