Merge branch 'master' into gfio
[fio.git] / filesetup.c
index c2170aae2ad44401d04231d1fdceefc8b81dabb2..4e828542e97535b6606d966cd9c08711f88f4639 100644 (file)
@@ -15,7 +15,7 @@
 #include "hash.h"
 #include "lib/axmap.h"
 
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
 #include <linux/falloc.h>
 #endif
 
@@ -72,7 +72,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
-#ifdef FIO_HAVE_FALLOCATE
+#ifdef CONFIG_POSIX_FALLOCATE
        if (!td->o.fill_device) {
                switch (td->o.fallocate_mode) {
                case FIO_FALLOCATE_NONE:
@@ -87,7 +87,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                                                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) "
@@ -100,14 +100,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                                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;
@@ -563,7 +563,7 @@ open_again:
                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 " \
@@ -958,8 +958,8 @@ int init_random_map(struct thread_data *td)
        for_each_file(td, f, i) {
                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;
+               blocks = file_size / (unsigned long long) td->o.rw_min_bs;
+
                if (td->o.random_generator == FIO_RAND_GEN_LFSR) {
                        unsigned long seed;
 
@@ -1250,7 +1250,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
        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;
        }