16 #ifdef FIO_HAVE_LINUX_FALLOCATE
17 #include <linux/falloc.h>
22 static inline void clear_error(struct thread_data *td)
29 * Leaves f->fd open on success, caller must close
31 static int extend_file(struct thread_data *td, struct fio_file *f)
33 int r, new_layout = 0, unlink_file = 0, flags;
34 unsigned long long left;
39 log_err("fio: refusing extend of file due to read-only\n");
44 * check if we need to lay the file out complete again. fio
45 * does that for operations involving reads, or for writes
46 * where overwrite is set
48 if (td_read(td) || (td_write(td) && td->o.overwrite) ||
49 (td_write(td) && td->io_ops->flags & FIO_NOEXTEND))
51 if (td_write(td) && !td->o.overwrite)
54 if (unlink_file || new_layout) {
55 dprint(FD_FILE, "layout unlink %s\n", f->file_name);
56 if ((unlink(f->file_name) < 0) && (errno != ENOENT)) {
57 td_verror(td, errno, "unlink");
62 flags = O_WRONLY | O_CREAT;
66 dprint(FD_FILE, "open file %s, flags %x\n", f->file_name, flags);
67 f->fd = open(f->file_name, flags, 0644);
69 td_verror(td, errno, "open");
73 #ifdef FIO_HAVE_FALLOCATE
74 if (!td->o.fill_device) {
75 switch (td->o.fallocate_mode) {
76 case FIO_FALLOCATE_NONE:
78 case FIO_FALLOCATE_POSIX:
79 dprint(FD_FILE, "posix_fallocate file %s size %llu\n",
80 f->file_name, f->real_file_size);
82 r = posix_fallocate(f->fd, 0, f->real_file_size);
84 log_err("fio: posix_fallocate fails: %s\n",
88 #ifdef FIO_HAVE_LINUX_FALLOCATE
89 case FIO_FALLOCATE_KEEP_SIZE:
91 "fallocate(FALLOC_FL_KEEP_SIZE) "
92 "file %s size %llu\n",
93 f->file_name, f->real_file_size);
95 r = fallocate(f->fd, FALLOC_FL_KEEP_SIZE, 0,
98 td_verror(td, errno, "fallocate");
101 #endif /* FIO_HAVE_LINUX_FALLOCATE */
103 log_err("fio: unknown fallocate mode: %d\n",
104 td->o.fallocate_mode);
108 #endif /* FIO_HAVE_FALLOCATE */
114 * The size will be -1ULL when fill_device is used, so don't truncate
115 * or fallocate this file, just write it
117 if (!td->o.fill_device) {
118 dprint(FD_FILE, "truncate file %s, size %llu\n", f->file_name,
120 if (ftruncate(f->fd, f->real_file_size) == -1) {
121 td_verror(td, errno, "ftruncate");
126 b = malloc(td->o.max_bs[DDIR_WRITE]);
127 memset(b, 0, td->o.max_bs[DDIR_WRITE]);
129 left = f->real_file_size;
130 while (left && !td->terminate) {
131 bs = td->o.max_bs[DDIR_WRITE];
135 r = write(f->fd, b, bs);
145 if (td->o.fill_device)
147 log_info("fio: ENOSPC on laying out "
151 td_verror(td, errno, "write");
153 td_verror(td, EIO, "write");
160 dprint(FD_FILE, "terminate unlink %s\n", f->file_name);
161 unlink(f->file_name);
162 } else if (td->o.create_fsync) {
163 if (fsync(f->fd) < 0) {
164 td_verror(td, errno, "fsync");
168 if (td->o.fill_device && !td_write(td)) {
169 fio_file_clear_size_known(f);
170 if (td_io_get_file_size(td, f))
172 if (f->io_size > f->real_file_size)
173 f->io_size = f->real_file_size;
185 static int pre_read_file(struct thread_data *td, struct fio_file *f)
187 int r, did_open = 0, old_runstate;
188 unsigned long long left;
192 if (td->io_ops->flags & FIO_PIPEIO)
195 if (!fio_file_open(f)) {
196 if (td->io_ops->open_file(td, f)) {
197 log_err("fio: cannot pre-read, failed to open file\n");
203 old_runstate = td->runstate;
204 td_set_runstate(td, TD_PRE_READING);
206 bs = td->o.max_bs[DDIR_READ];
210 lseek(f->fd, f->file_offset, SEEK_SET);
213 while (left && !td->terminate) {
217 r = read(f->fd, b, bs);
223 td_verror(td, EIO, "pre_read");
228 td_set_runstate(td, old_runstate);
231 td->io_ops->close_file(td, f);
236 static unsigned long long get_rand_file_size(struct thread_data *td)
238 unsigned long long ret, sized;
241 if (td->o.use_os_rand) {
242 r = os_random_long(&td->file_size_state);
243 sized = td->o.file_size_high - td->o.file_size_low;
244 ret = (unsigned long long) ((double) sized * (r / (OS_RAND_MAX + 1.0)));
246 r = __rand(&td->__file_size_state);
247 sized = td->o.file_size_high - td->o.file_size_low;
248 ret = (unsigned long long) ((double) sized * (r / (FRAND_MAX + 1.0)));
251 ret += td->o.file_size_low;
252 ret -= (ret % td->o.rw_min_bs);
256 static int file_size(struct thread_data *td, struct fio_file *f)
260 if (stat(f->file_name, &st) == -1) {
261 td_verror(td, errno, "fstat");
265 f->real_file_size = st.st_size;
269 static int bdev_size(struct thread_data *td, struct fio_file *f)
271 unsigned long long bytes = 0;
274 if (td->io_ops->open_file(td, f)) {
275 log_err("fio: failed opening blockdev %s for size check\n",
280 r = blockdev_size(f, &bytes);
282 td_verror(td, r, "blockdev_size");
287 log_err("%s: zero sized block device?\n", f->file_name);
291 f->real_file_size = bytes;
292 td->io_ops->close_file(td, f);
295 td->io_ops->close_file(td, f);
299 static int char_size(struct thread_data *td, struct fio_file *f)
301 #ifdef FIO_HAVE_CHARDEV_SIZE
302 unsigned long long bytes = 0;
305 if (td->io_ops->open_file(td, f)) {
306 log_err("fio: failed opening blockdev %s for size check\n",
311 r = chardev_size(f, &bytes);
313 td_verror(td, r, "chardev_size");
318 log_err("%s: zero sized char device?\n", f->file_name);
322 f->real_file_size = bytes;
323 td->io_ops->close_file(td, f);
326 td->io_ops->close_file(td, f);
329 f->real_file_size = -1ULL;
334 static int get_file_size(struct thread_data *td, struct fio_file *f)
338 if (fio_file_size_known(f))
341 if (f->filetype == FIO_TYPE_FILE)
342 ret = file_size(td, f);
343 else if (f->filetype == FIO_TYPE_BD)
344 ret = bdev_size(td, f);
345 else if (f->filetype == FIO_TYPE_CHAR)
346 ret = char_size(td, f);
348 f->real_file_size = -1;
353 if (f->file_offset > f->real_file_size) {
354 log_err("%s: offset extends end (%llu > %llu)\n", td->o.name,
355 f->file_offset, f->real_file_size);
359 fio_file_set_size_known(f);
363 static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
364 unsigned long long off,
365 unsigned long long len)
372 off = f->file_offset;
374 if (len == -1ULL || off == -1ULL)
377 dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
381 * FIXME: add blockdev flushing too
384 ret = posix_madvise(f->mmap_ptr, f->mmap_sz, POSIX_MADV_DONTNEED);
386 (void) posix_madvise(f->mmap_ptr, f->mmap_sz, FIO_MADV_FREE);
388 } else if (f->filetype == FIO_TYPE_FILE) {
389 ret = posix_fadvise(f->fd, off, len, POSIX_FADV_DONTNEED);
390 } else if (f->filetype == FIO_TYPE_BD) {
391 ret = blockdev_invalidate_cache(f);
392 if (ret < 0 && errno == EACCES && geteuid()) {
394 log_err("fio: only root may flush block "
395 "devices. Cache flush bypassed!\n");
400 } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE)
404 td_verror(td, errno, "invalidate_cache");
406 } else if (ret > 0) {
407 td_verror(td, ret, "invalidate_cache");
415 int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
417 if (!fio_file_open(f))
420 return __file_invalidate_cache(td, f, -1ULL, -1ULL);
423 int generic_close_file(struct thread_data fio_unused *td, struct fio_file *f)
427 dprint(FD_FILE, "fd close %s\n", f->file_name);
431 if (close(f->fd) < 0)
438 static int file_lookup_open(struct fio_file *f, int flags)
440 struct fio_file *__f;
443 __f = lookup_file_hash(f->file_name);
445 dprint(FD_FILE, "found file in hash %s\n", f->file_name);
447 * racy, need the __f->lock locked
450 f->lock_owner = __f->lock_owner;
451 f->lock_batch = __f->lock_batch;
452 f->lock_ddir = __f->lock_ddir;
455 dprint(FD_FILE, "file not found in hash %s\n", f->file_name);
459 f->fd = open(f->file_name, flags, 0600);
463 int generic_open_file(struct thread_data *td, struct fio_file *f)
469 dprint(FD_FILE, "fd open %s\n", f->file_name);
471 if (!strcmp(f->file_name, "-")) {
473 log_err("fio: can't read/write to stdin/out\n");
479 * move output logging to stderr, if we are writing to stdout
486 flags |= OS_O_DIRECT;
489 if (f->filetype != FIO_TYPE_FILE)
490 flags |= FIO_O_NOATIME;
491 if (td->o.create_on_open)
499 if (f->filetype == FIO_TYPE_FILE)
503 f->fd = dup(STDOUT_FILENO);
505 from_hash = file_lookup_open(f, flags);
507 if (f->filetype == FIO_TYPE_CHAR && !read_only)
513 f->fd = dup(STDIN_FILENO);
515 from_hash = file_lookup_open(f, flags);
519 char buf[FIO_VERROR_SIZE];
522 if (__e == EPERM && (flags & FIO_O_NOATIME)) {
523 flags &= ~FIO_O_NOATIME;
527 snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name);
529 if (__e == EINVAL && (flags & OS_O_DIRECT)) {
530 log_err("fio: looks like your file system does not " \
531 "support direct=1/buffered=0\n");
534 td_verror(td, __e, buf);
537 if (!from_hash && f->fd != -1) {
538 if (add_file_hash(f)) {
542 * OK to ignore, we haven't done anything with it
544 ret = generic_close_file(td, f);
552 int generic_get_file_size(struct thread_data *td, struct fio_file *f)
554 return get_file_size(td, f);
558 * open/close all files, so that ->real_file_size gets set
560 static int get_file_sizes(struct thread_data *td)
566 for_each_file(td, f, i) {
567 dprint(FD_FILE, "get file size for %p/%d/%p\n", f, i,
570 if (td_io_get_file_size(td, f)) {
571 if (td->error != ENOENT) {
572 log_err("%s\n", td->verror);
578 if (f->real_file_size == -1ULL && td->o.size)
579 f->real_file_size = td->o.size / td->o.nr_files;
586 struct flist_head list;
593 * Get free number of bytes for each file on each unique mount.
595 static unsigned long long get_fs_free_counts(struct thread_data *td)
597 struct flist_head *n, *tmp;
598 unsigned long long ret = 0;
599 struct fio_mount *fm;
604 for_each_file(td, f, i) {
608 if (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_CHAR) {
609 if (f->real_file_size != -1ULL)
610 ret += f->real_file_size;
612 } else if (f->filetype != FIO_TYPE_FILE)
615 strcpy(buf, f->file_name);
617 if (stat(buf, &sb) < 0) {
621 if (stat(buf, &sb) < 0)
626 flist_for_each(n, &list) {
627 fm = flist_entry(n, struct fio_mount, list);
628 if (fm->key == sb.st_dev)
637 fm = malloc(sizeof(*fm));
638 strcpy(fm->__base, buf);
639 fm->base = basename(fm->__base);
641 flist_add(&fm->list, &list);
644 flist_for_each_safe(n, tmp, &list) {
645 unsigned long long sz;
647 fm = flist_entry(n, struct fio_mount, list);
648 flist_del(&fm->list);
650 sz = get_fs_size(fm->base);
651 if (sz && sz != -1ULL)
660 unsigned long long get_start_offset(struct thread_data *td)
662 return td->o.start_offset +
663 (td->thread_number - 1) * td->o.offset_increment;
667 * Open the files and setup files sizes, creating files if necessary.
669 int setup_files(struct thread_data *td)
671 unsigned long long total_size, extend_size;
674 int err = 0, need_extend;
676 dprint(FD_FILE, "setup files\n");
678 if (td->o.read_iolog_file)
682 * if ioengine defines a setup() method, it's responsible for
683 * opening the files and setting f->real_file_size to indicate
684 * the valid range for that file.
686 if (td->io_ops->setup)
687 err = td->io_ops->setup(td);
689 err = get_file_sizes(td);
695 * check sizes. if the files/devices do not exist and the size
696 * isn't passed to fio, abort.
699 for_each_file(td, f, i) {
700 if (f->real_file_size == -1ULL)
703 total_size += f->real_file_size;
706 if (td->o.fill_device)
707 td->fill_device_size = get_fs_free_counts(td);
710 * device/file sizes are zero and no size given, punt
712 if ((!total_size || total_size == -1ULL) && !td->o.size &&
713 !(td->io_ops->flags & FIO_NOIO) && !td->o.fill_device) {
714 log_err("%s: you need to specify size=\n", td->o.name);
715 td_verror(td, EINVAL, "total_file_size");
720 * now file sizes are known, so we can set ->io_size. if size= is
721 * not given, ->io_size is just equal to ->real_file_size. if size
722 * is given, ->io_size is size / nr_files.
724 extend_size = total_size = 0;
726 for_each_file(td, f, i) {
727 f->file_offset = get_start_offset(td);
729 if (!td->o.file_size_low) {
731 * no file size range given, file size is equal to
732 * total size divided by number of files. if that is
733 * zero, set it to the real file size.
735 f->io_size = td->o.size / td->o.nr_files;
737 f->io_size = f->real_file_size - f->file_offset;
738 } else if (f->real_file_size < td->o.file_size_low ||
739 f->real_file_size > td->o.file_size_high) {
740 if (f->file_offset > td->o.file_size_low)
743 * file size given. if it's fixed, use that. if it's a
744 * range, generate a random size in-between.
746 if (td->o.file_size_low == td->o.file_size_high) {
747 f->io_size = td->o.file_size_low
750 f->io_size = get_rand_file_size(td)
754 f->io_size = f->real_file_size - f->file_offset;
756 if (f->io_size == -1ULL)
759 total_size += f->io_size;
761 if (f->filetype == FIO_TYPE_FILE &&
762 (f->io_size + f->file_offset) > f->real_file_size &&
763 !(td->io_ops->flags & FIO_DISKLESSIO)) {
764 if (!td->o.create_on_open) {
766 extend_size += (f->io_size + f->file_offset);
768 f->real_file_size = f->io_size + f->file_offset;
769 fio_file_set_extend(f);
773 if (td->o.size_percent)
774 total_size = (total_size * td->o.size_percent) / 100;
776 if (!td->o.size || td->o.size > total_size)
777 td->o.size = total_size;
780 * See if we need to extend some files
785 log_info("%s: Laying out IO file(s) (%u file(s) /"
786 " %lluMB)\n", td->o.name, need_extend,
789 for_each_file(td, f, i) {
790 unsigned long long old_len = -1ULL, extend_len = -1ULL;
792 if (!fio_file_extend(f))
795 assert(f->filetype == FIO_TYPE_FILE);
796 fio_file_clear_extend(f);
797 if (!td->o.fill_device) {
798 old_len = f->real_file_size;
799 extend_len = f->io_size + f->file_offset -
802 f->real_file_size = (f->io_size + f->file_offset);
803 err = extend_file(td, f);
807 err = __file_invalidate_cache(td, f, old_len,
820 if (!td->o.zone_size)
821 td->o.zone_size = td->o.size;
824 * iolog already set the total io size, if we read back
827 if (!td->o.read_iolog_file)
828 td->total_io_size = td->o.size * td->o.loops;
831 if (td->o.create_only)
836 log_err("%s: you need to specify valid offset=\n", td->o.name);
840 int pre_read_files(struct thread_data *td)
845 dprint(FD_FILE, "pre_read files\n");
847 for_each_file(td, f, i) {
848 pre_read_file(td, f);
854 int init_random_map(struct thread_data *td)
856 unsigned long long blocks, num_maps;
860 if (td->o.norandommap || !td_random(td))
863 for_each_file(td, f, i) {
864 blocks = (f->real_file_size + td->o.rw_min_bs - 1) /
865 (unsigned long long) td->o.rw_min_bs;
866 num_maps = (blocks + BLOCKS_PER_MAP - 1) /
867 (unsigned long long) BLOCKS_PER_MAP;
868 if (num_maps == (unsigned long) num_maps) {
869 f->file_map = smalloc(num_maps * sizeof(unsigned long));
871 f->num_maps = num_maps;
877 if (!td->o.softrandommap) {
878 log_err("fio: failed allocating random map. If running"
879 " a large number of jobs, try the 'norandommap'"
880 " option or set 'softrandommap'. Or give"
881 " a larger --alloc-size to fio.\n");
885 log_info("fio: file %s failed allocating random map. Running "
886 "job without.\n", f->file_name);
893 void close_files(struct thread_data *td)
898 for_each_file(td, f, i) {
899 if (fio_file_open(f))
900 td_io_close_file(td, f);
904 void close_and_free_files(struct thread_data *td)
909 dprint(FD_FILE, "close files\n");
911 for_each_file(td, f, i) {
912 if (td->o.unlink && f->filetype == FIO_TYPE_FILE) {
913 dprint(FD_FILE, "free unlink %s\n", f->file_name);
914 unlink(f->file_name);
917 if (fio_file_open(f))
918 td_io_close_file(td, f);
929 td->o.filename = NULL;
936 static void get_file_type(struct fio_file *f)
940 if (!strcmp(f->file_name, "-"))
941 f->filetype = FIO_TYPE_PIPE;
943 f->filetype = FIO_TYPE_FILE;
945 /* \\.\ is the device namespace in Windows, where every file is
947 if (strncmp(f->file_name, "\\\\.\\", 4) == 0)
948 f->filetype = FIO_TYPE_BD;
950 if (!stat(f->file_name, &sb)) {
951 if (S_ISBLK(sb.st_mode))
952 f->filetype = FIO_TYPE_BD;
953 else if (S_ISCHR(sb.st_mode))
954 f->filetype = FIO_TYPE_CHAR;
955 else if (S_ISFIFO(sb.st_mode))
956 f->filetype = FIO_TYPE_PIPE;
960 int add_file(struct thread_data *td, const char *fname)
962 int cur_files = td->files_index;
963 char file_name[PATH_MAX];
967 dprint(FD_FILE, "add file %s\n", fname);
969 f = smalloc(sizeof(*f));
971 log_err("fio: smalloc OOM\n");
978 if (td->files_size <= td->files_index) {
979 int new_size = td->o.nr_files + 1;
981 dprint(FD_FILE, "resize file array to %d files\n", new_size);
983 td->files = realloc(td->files, new_size * sizeof(f));
984 td->files_size = new_size;
986 td->files[cur_files] = f;
987 f->fileno = cur_files;
990 * init function, io engine may not be loaded yet
992 if (td->io_ops && (td->io_ops->flags & FIO_DISKLESSIO))
993 f->real_file_size = -1ULL;
996 len = sprintf(file_name, "%s/", td->o.directory);
998 sprintf(file_name + len, "%s", fname);
999 f->file_name = smalloc_strdup(file_name);
1000 if (!f->file_name) {
1001 log_err("fio: smalloc OOM\n");
1007 switch (td->o.file_lock_mode) {
1008 case FILE_LOCK_NONE:
1010 case FILE_LOCK_READWRITE:
1011 f->lock = fio_mutex_rw_init();
1013 case FILE_LOCK_EXCLUSIVE:
1014 f->lock = fio_mutex_init(FIO_MUTEX_UNLOCKED);
1017 log_err("fio: unknown lock mode: %d\n", td->o.file_lock_mode);
1022 if (f->filetype == FIO_TYPE_FILE)
1023 td->nr_normal_files++;
1025 dprint(FD_FILE, "file %p \"%s\" added at %d\n", f, f->file_name,
1031 int add_file_exclusive(struct thread_data *td, const char *fname)
1036 for_each_file(td, f, i) {
1037 if (!strcmp(f->file_name, fname))
1041 return add_file(td, fname);
1044 void get_file(struct fio_file *f)
1046 dprint(FD_FILE, "get file %s, ref=%d\n", f->file_name, f->references);
1047 assert(fio_file_open(f));
1051 int put_file(struct thread_data *td, struct fio_file *f)
1053 int f_ret = 0, ret = 0;
1055 dprint(FD_FILE, "put file %s, ref=%d\n", f->file_name, f->references);
1057 if (!fio_file_open(f)) {
1058 assert(f->fd == -1);
1062 assert(f->references);
1063 if (--f->references)
1066 if (should_fsync(td) && td->o.fsync_on_close)
1067 f_ret = fsync(f->fd);
1069 if (td->io_ops->close_file)
1070 ret = td->io_ops->close_file(td, f);
1075 td->nr_open_files--;
1076 fio_file_clear_open(f);
1077 assert(f->fd == -1);
1081 void lock_file(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir)
1083 if (!f->lock || td->o.file_lock_mode == FILE_LOCK_NONE)
1086 if (f->lock_owner == td && f->lock_batch--)
1089 if (td->o.file_lock_mode == FILE_LOCK_READWRITE) {
1090 if (ddir == DDIR_READ)
1091 fio_mutex_down_read(f->lock);
1093 fio_mutex_down_write(f->lock);
1094 } else if (td->o.file_lock_mode == FILE_LOCK_EXCLUSIVE)
1095 fio_mutex_down(f->lock);
1098 f->lock_batch = td->o.lockfile_batch;
1099 f->lock_ddir = ddir;
1102 void unlock_file(struct thread_data *td, struct fio_file *f)
1104 if (!f->lock || td->o.file_lock_mode == FILE_LOCK_NONE)
1109 if (td->o.file_lock_mode == FILE_LOCK_READWRITE) {
1110 const int is_read = f->lock_ddir == DDIR_READ;
1111 int val = fio_mutex_getval(f->lock);
1113 if ((is_read && val == 1) || (!is_read && val == -1))
1114 f->lock_owner = NULL;
1117 fio_mutex_up_read(f->lock);
1119 fio_mutex_up_write(f->lock);
1120 } else if (td->o.file_lock_mode == FILE_LOCK_EXCLUSIVE) {
1121 int val = fio_mutex_getval(f->lock);
1124 f->lock_owner = NULL;
1126 fio_mutex_up(f->lock);
1130 void unlock_file_all(struct thread_data *td, struct fio_file *f)
1132 if (f->lock_owner != td)
1139 static int recurse_dir(struct thread_data *td, const char *dirname)
1145 D = opendir(dirname);
1147 char buf[FIO_VERROR_SIZE];
1149 snprintf(buf, FIO_VERROR_SIZE - 1, "opendir(%s)", dirname);
1150 td_verror(td, errno, buf);
1154 while ((dir = readdir(D)) != NULL) {
1155 char full_path[PATH_MAX];
1158 if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
1161 sprintf(full_path, "%s%s%s", dirname, FIO_OS_PATH_SEPARATOR, dir->d_name);
1163 if (lstat(full_path, &sb) == -1) {
1164 if (errno != ENOENT) {
1165 td_verror(td, errno, "stat");
1170 if (S_ISREG(sb.st_mode)) {
1171 add_file(td, full_path);
1175 if (!S_ISDIR(sb.st_mode))
1178 ret = recurse_dir(td, full_path);
1187 int add_dir_files(struct thread_data *td, const char *path)
1189 int ret = recurse_dir(td, path);
1192 log_info("fio: opendir added %d files\n", td->o.nr_files);
1197 void dup_files(struct thread_data *td, struct thread_data *org)
1202 dprint(FD_FILE, "dup files: %d\n", org->files_index);
1207 td->files = malloc(org->files_index * sizeof(f));
1209 for_each_file(org, f, i) {
1210 struct fio_file *__f;
1212 __f = smalloc(sizeof(*__f));
1214 log_err("fio: smalloc OOM\n");
1218 fio_file_reset(__f);
1221 __f->file_name = smalloc_strdup(f->file_name);
1222 if (!__f->file_name) {
1223 log_err("fio: smalloc OOM\n");
1227 __f->filetype = f->filetype;
1235 * Returns the index that matches the filename, or -1 if not there
1237 int get_fileno(struct thread_data *td, const char *fname)
1242 for_each_file(td, f, i)
1243 if (!strcmp(f->file_name, fname))
1250 * For log usage, where we add/open/close files automatically
1252 void free_release_files(struct thread_data *td)
1255 td->files_index = 0;
1256 td->nr_normal_files = 0;