X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=10fc4150804b8fadce1a4af7cb856828796ca1f8;hp=09e877f639809689e9c95c86112d945ba954c7bc;hb=26e616d054f238bf6b7ada351e17b72fdfbbb8e0;hpb=f88cd2226c594876ae58f36ca94cddb4fc1b719f diff --git a/filesetup.c b/filesetup.c index 09e877f6..10fc4150 100644 --- a/filesetup.c +++ b/filesetup.c @@ -512,11 +512,6 @@ int generic_open_file(struct thread_data *td, struct fio_file *f) dprint(FD_FILE, "fd open %s\n", f->file_name); - if (td_trim(td) && f->filetype != FIO_TYPE_BD) { - log_err("fio: trim only applies to block device\n"); - return 1; - } - if (!strcmp(f->file_name, "-")) { if (td_rw(td)) { log_err("fio: can't read/write to stdin/out\n"); @@ -885,6 +880,27 @@ int setup_files(struct thread_data *td) } } + if (td->o.block_error_hist) { + int len; + + assert(td->o.nr_files == 1); /* checked in fixup_options */ + f = td->files[0]; + len = f->io_size / td->o.bs[DDIR_TRIM]; + if (len > MAX_NR_BLOCK_INFOS || len <= 0) { + log_err("fio: cannot calculate block histogram with " + "%d trim blocks, maximum %d\n", + len, MAX_NR_BLOCK_INFOS); + td_verror(td, EINVAL, "block_error_hist"); + goto err_out; + } + + td->ts.nr_block_infos = len; + for (int i = 0; i < len; i++) + td->ts.block_infos[i] = + BLOCK_INFO(0, BLOCK_STATE_UNINIT); + } else + td->ts.nr_block_infos = 0; + if (!o->size || (total_size && o->size > total_size)) o->size = total_size;