X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=6277f0f40cd33d24f7ddd566f142ebb81f291d2e;hp=6d8aa7a7087bdc67c8e72d0f5a8a4aa9fe22b8ef;hb=521da527743088a9bd2ab882f8b64799d49d5848;hpb=a596f047e2b3d447ccca76bd075f05473a1f8d1c diff --git a/filesetup.c b/filesetup.c index 6d8aa7a7..6277f0f4 100644 --- a/filesetup.c +++ b/filesetup.c @@ -280,7 +280,6 @@ static int bdev_size(struct thread_data *td, struct fio_file *f) r = blockdev_size(f, &bytes); if (r) { td_verror(td, r, "blockdev_size"); - printf("fd is %d\n", f->fd); goto err; } @@ -527,6 +526,11 @@ open_again: snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name); + if (__e == EINVAL && (flags & OS_O_DIRECT)) { + log_err("fio: looks like your file system does not " \ + "support direct=1/buffered=0\n"); + } + td_verror(td, __e, buf); } @@ -666,7 +670,7 @@ int setup_files(struct thread_data *td) dprint(FD_FILE, "setup files\n"); if (td->o.read_iolog_file) - return 0; + goto done; /* * if ioengine defines a setup() method, it's responsible for @@ -714,7 +718,8 @@ int setup_files(struct thread_data *td) extend_size = total_size = 0; need_extend = 0; for_each_file(td, f, i) { - f->file_offset = td->o.start_offset; + f->file_offset = td->o.start_offset + + (td->thread_number - 1) * td->o.offset_increment; if (!td->o.file_size_low) { /* @@ -760,6 +765,9 @@ int setup_files(struct thread_data *td) } } + if (td->o.size_percent) + total_size = (total_size * td->o.size_percent) / 100; + if (!td->o.size || td->o.size > total_size) td->o.size = total_size; @@ -813,6 +821,11 @@ int setup_files(struct thread_data *td) */ if (!td->o.read_iolog_file) td->total_io_size = td->o.size * td->o.loops; + +done: + if (td->o.create_only) + td->done = 1; + return 0; err_offset: log_err("%s: you need to specify valid offset=\n", td->o.name); @@ -847,11 +860,15 @@ int init_random_map(struct thread_data *td) (unsigned long long) td->o.rw_min_bs; num_maps = (blocks + BLOCKS_PER_MAP - 1) / (unsigned long long) BLOCKS_PER_MAP; - f->file_map = smalloc(num_maps * sizeof(unsigned long)); - if (f->file_map) { - f->num_maps = num_maps; - continue; - } + if (num_maps == (unsigned long) num_maps) { + f->file_map = smalloc(num_maps * sizeof(unsigned long)); + if (f->file_map) { + f->num_maps = num_maps; + continue; + } + } else + f->file_map = NULL; + if (!td->o.softrandommap) { log_err("fio: failed allocating random map. If running" " a large number of jobs, try the 'norandommap'" @@ -920,10 +937,13 @@ static void get_file_type(struct fio_file *f) else f->filetype = FIO_TYPE_FILE; + /* \\.\ is the device namespace in Windows, where every file is + * a block device */ + if (strncmp(f->file_name, "\\\\.\\", 4) == 0) + f->filetype = FIO_TYPE_BD; + if (!stat(f->file_name, &sb)) { - /* \\.\ is the device namespace in Windows, where every file is - * a block device */ - if (S_ISBLK(sb.st_mode) || strncmp(f->file_name, "\\\\.\\", 4) == 0) + if (S_ISBLK(sb.st_mode)) f->filetype = FIO_TYPE_BD; else if (S_ISCHR(sb.st_mode)) f->filetype = FIO_TYPE_CHAR; @@ -959,6 +979,7 @@ int add_file(struct thread_data *td, const char *fname) td->files_size = new_size; } td->files[cur_files] = f; + f->fileno = cur_files; /* * init function, io engine may not be loaded yet @@ -985,7 +1006,7 @@ int add_file(struct thread_data *td, const char *fname) f->lock = fio_mutex_rw_init(); break; case FILE_LOCK_EXCLUSIVE: - f->lock = fio_mutex_init(1); + f->lock = fio_mutex_init(FIO_MUTEX_UNLOCKED); break; default: log_err("fio: unknown lock mode: %d\n", td->o.file_lock_mode); @@ -1132,7 +1153,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname) if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) continue; - sprintf(full_path, "%s/%s", dirname, dir->d_name); + sprintf(full_path, "%s%s%s", dirname, FIO_OS_PATH_SEPARATOR, dir->d_name); if (lstat(full_path, &sb) == -1) { if (errno != ENOENT) {