Fix bug in $mb_memory keyword
[fio.git] / options.c
index 28a17cf4a20870f6e86c44b68d591e576cbc967e..b4456a42bca3b53c9fe41896bd8ac65990ca060e 100644 (file)
--- a/options.c
+++ b/options.c
@@ -329,7 +329,7 @@ static int str_cpumask_cb(void *data, unsigned long long *val)
                return 1;
        }
 
-       max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+       max_cpu = cpus_online();
 
        for (i = 0; i < sizeof(int) * 8; i++) {
                if ((1 << i) & *val) {
@@ -366,7 +366,7 @@ static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
        strip_blank_front(&str);
        strip_blank_end(str);
 
-       max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+       max_cpu = cpus_online();
 
        while ((cpu = strsep(&str, ",")) != NULL) {
                char *str2, *cpu2;
@@ -482,6 +482,7 @@ static int str_sfr_cb(void *data, const char *str)
 
 static int check_dir(struct thread_data *td, char *fname)
 {
+#if 0
        char file[PATH_MAX], *dir;
        int elen = 0;
 
@@ -494,7 +495,6 @@ static int check_dir(struct thread_data *td, char *fname)
        sprintf(file + elen, "%s", fname);
        dir = dirname(file);
 
-#if 0
        {
        struct stat sb;
        /*
@@ -1178,12 +1178,37 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 #ifdef FIO_HAVE_FALLOCATE
        {
                .name   = "fallocate",
-               .type   = FIO_OPT_BOOL,
-               .off1   = td_var_offset(fallocate),
-               .help   = "Use fallocate() when laying out files",
-               .def    = "1",
-       },
+               .type   = FIO_OPT_STR,
+               .off1   = td_var_offset(fallocate_mode),
+               .help   = "Whether pre-allocation is performed when laying out files",
+               .def    = "posix",
+               .posval = {
+                         { .ival = "none",
+                           .oval = FIO_FALLOCATE_NONE,
+                           .help = "Do not pre-allocate space",
+                         },
+                         { .ival = "posix",
+                           .oval = FIO_FALLOCATE_POSIX,
+                           .help = "Use posix_fallocate()",
+                         },
+#ifdef FIO_HAVE_LINUX_FALLOCATE
+                         { .ival = "keep",
+                           .oval = FIO_FALLOCATE_KEEP_SIZE,
+                           .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
+                         },
 #endif
+                         /* Compatibility with former boolean values */
+                         { .ival = "0",
+                           .oval = FIO_FALLOCATE_NONE,
+                           .help = "Alias for 'none'",
+                         },
+                         { .ival = "1",
+                           .oval = FIO_FALLOCATE_POSIX,
+                           .help = "Alias for 'posix'",
+                         },
+               },
+       },
+#endif /* FIO_HAVE_FALLOCATE */
        {
                .name   = "fadvise_hint",
                .type   = FIO_OPT_BOOL,
@@ -2066,11 +2091,11 @@ void fio_keywords_init(void)
        sprintf(buf, "%lu", page_size);
        fio_keywords[0].replace = strdup(buf);
 
-       mb_memory = os_phys_mem() / page_size;
+       mb_memory = os_phys_mem() / (1024 * 1024);
        sprintf(buf, "%llu", mb_memory);
        fio_keywords[1].replace = strdup(buf);
 
-       l = sysconf(_SC_NPROCESSORS_ONLN);
+       l = cpus_online();
        sprintf(buf, "%lu", l);
        fio_keywords[2].replace = strdup(buf);
 }