#include "hash.h"
#include "lib/axmap.h"
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
#include <linux/falloc.h>
#endif
return 1;
}
-#ifdef FIO_HAVE_FALLOCATE
+#ifdef CONFIG_POSIX_FALLOCATE
if (!td->o.fill_device) {
switch (td->o.fallocate_mode) {
case FIO_FALLOCATE_NONE:
strerror(r));
}
break;
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
case FIO_FALLOCATE_KEEP_SIZE:
dprint(FD_FILE,
"fallocate(FALLOC_FL_KEEP_SIZE) "
td_verror(td, errno, "fallocate");
break;
-#endif /* FIO_HAVE_LINUX_FALLOCATE */
+#endif /* CONFIG_LINUX_FALLOCATE */
default:
log_err("fio: unknown fallocate mode: %d\n",
td->o.fallocate_mode);
assert(0);
}
}
-#endif /* FIO_HAVE_FALLOCATE */
+#endif /* CONFIG_POSIX_FALLOCATE */
if (!new_layout)
goto done;
if (__e == EMFILE && file_close_shadow_fds(td))
goto open_again;
- snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name);
+ snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
if (__e == EINVAL && (flags & OS_O_DIRECT)) {
log_err("fio: looks like your file system does not " \
return 0;
for_each_file(td, f, i) {
- blocks = (f->real_file_size + td->o.rw_min_bs - 1) /
+ uint64_t file_size = min(f->real_file_size, f->io_size);
+
+ blocks = (file_size + td->o.rw_min_bs - 1) /
(unsigned long long) td->o.rw_min_bs;
if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
unsigned long seed;
f->fd = -1;
f->shadow_fd = -1;
- fio_file_reset(f);
+ fio_file_reset(td, f);
if (td->files_size <= td->files_index) {
- int new_size = td->o.nr_files + 1;
+ unsigned int new_size = td->o.nr_files + 1;
dprint(FD_FILE, "resize file array to %d files\n", new_size);
td->files = realloc(td->files, new_size * sizeof(f));
+ if (td->files == NULL) {
+ log_err("fio: realloc OOM\n");
+ assert(0);
+ }
td->files_size = new_size;
}
td->files[cur_files] = f;
if (!D) {
char buf[FIO_VERROR_SIZE];
- snprintf(buf, FIO_VERROR_SIZE - 1, "opendir(%s)", dirname);
+ snprintf(buf, FIO_VERROR_SIZE, "opendir(%s)", dirname);
td_verror(td, errno, buf);
return 1;
}
assert(0);
}
__f->fd = -1;
- fio_file_reset(__f);
+ fio_file_reset(td, __f);
if (f->file_name) {
__f->file_name = smalloc_strdup(f->file_name);
td->files_index = 0;
td->nr_normal_files = 0;
}
+
+void fio_file_reset(struct thread_data *td, struct fio_file *f)
+{
+ f->last_pos = f->file_offset;
+ f->last_start = -1ULL;
+ if (f->io_axmap)
+ axmap_reset(f->io_axmap);
+ if (td->o.random_generator == FIO_RAND_GEN_LFSR)
+ lfsr_reset(&f->lfsr, td->rand_seeds[FIO_RAND_BLOCK_OFF]);
+}