engines/filestat: change "lstat" bool option to "stat_type" str option
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 4 Feb 2020 12:25:47 +0000 (21:25 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 4 Feb 2020 16:38:46 +0000 (01:38 +0900)
Per suggestion from Jens, change a bool option to str option
to better support stat(2) variants (at this point before 3.18).

https://github.com/axboe/fio/pull/912#issuecomment-577814885

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
HOWTO
engines/filestat.c
fio.1

diff --git a/HOWTO b/HOWTO
index f19f9226a93de504d04aad6c60c27856bf1b19cb..0831239ef5fcac1c1413eb148608808090306745 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -2261,9 +2261,10 @@ with the caveat that when used on the command line, they must come after the
        multiple paths exist between the client and the server or in certain loopback
        configurations.
 
        multiple paths exist between the client and the server or in certain loopback
        configurations.
 
-.. option:: lstat=bool : [filestat]
+.. option:: stat_type=str : [filestat]
 
 
-       Use lstat(2) to measure lookup/getattr performance. Default is 0.
+       Specify stat system call type to measure lookup/getattr performance.
+       Default is **stat** for :manpage:`stat(2)`.
 
 .. option:: readfua=bool : [sg]
 
 
 .. option:: readfua=bool : [sg]
 
index 6c87c4c2222b50282e4cd636c3698d7244214c3e..68a340bd0619907e7cca9f91373d808cb1bf4cef 100644 (file)
@@ -19,17 +19,39 @@ struct fc_data {
 
 struct filestat_options {
        void *pad;
 
 struct filestat_options {
        void *pad;
-       unsigned int lstat;
+       unsigned int stat_type;
+};
+
+enum {
+       FIO_FILESTAT_STAT       = 1,
+       FIO_FILESTAT_LSTAT      = 2,
+       /*FIO_FILESTAT_STATX    = 3,*/
 };
 
 static struct fio_option options[] = {
        {
 };
 
 static struct fio_option options[] = {
        {
-               .name   = "lstat",
-               .lname  = "lstat",
-               .type   = FIO_OPT_BOOL,
-               .off1   = offsetof(struct filestat_options, lstat),
-               .help   = "Use lstat(2) to measure lookup/getattr performance",
-               .def    = "0",
+               .name   = "stat_type",
+               .lname  = "stat_type",
+               .type   = FIO_OPT_STR,
+               .off1   = offsetof(struct filestat_options, stat_type),
+               .help   = "Specify stat system call type to measure lookup/getattr performance",
+               .def    = "stat",
+               .posval = {
+                         { .ival = "stat",
+                           .oval = FIO_FILESTAT_STAT,
+                           .help = "Use stat(2)",
+                         },
+                         { .ival = "lstat",
+                           .oval = FIO_FILESTAT_LSTAT,
+                           .help = "Use lstat(2)",
+                         },
+                         /*
+                         { .ival = "statx",
+                           .oval = FIO_FILESTAT_STATX,
+                           .help = "Use statx(2)",
+                         },
+                         */
+               },
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_FILESTAT,
        },
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_FILESTAT,
        },
@@ -60,17 +82,24 @@ static int stat_file(struct thread_data *td, struct fio_file *f)
        if (do_lat)
                fio_gettime(&start, NULL);
 
        if (do_lat)
                fio_gettime(&start, NULL);
 
-       if (o->lstat)
-               ret = lstat(f->file_name, &statbuf);
-       else
+       switch (o->stat_type){
+       case FIO_FILESTAT_STAT:
                ret = stat(f->file_name, &statbuf);
                ret = stat(f->file_name, &statbuf);
+               break;
+       case FIO_FILESTAT_LSTAT:
+               ret = lstat(f->file_name, &statbuf);
+               break;
+       default:
+               ret = -1;
+               break;
+       }
 
        if (ret == -1) {
                char buf[FIO_VERROR_SIZE];
                int e = errno;
 
 
        if (ret == -1) {
                char buf[FIO_VERROR_SIZE];
                int e = errno;
 
-               snprintf(buf, sizeof(buf), "%sstat(%s)",
-                       o->lstat ? "l" : "", f->file_name);
+               snprintf(buf, sizeof(buf), "stat(%s) type=%u", f->file_name,
+                       o->stat_type);
                td_verror(td, e, buf);
                return 1;
        }
                td_verror(td, e, buf);
                return 1;
        }
diff --git a/fio.1 b/fio.1
index a58632b407fc2c95856278fc03a22aef34838f75..a770e5d08f636f0489849fb15cb42d14d25d0ad5 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -2032,8 +2032,9 @@ on the client site it will be used in the rdma_resolve_add()
 function. This can be useful when multiple paths exist between the
 client and the server or in certain loopback configurations.
 .TP
 function. This can be useful when multiple paths exist between the
 client and the server or in certain loopback configurations.
 .TP
-.BI (filestat)lstat \fR=\fPbool
-Use \fBlstat\fR\|(2) to measure lookup/getattr performance. Default: 0.
+.BI (filestat)stat_type \fR=\fPstr
+Specify stat system call type to measure lookup/getattr performance.
+Default is \fBstat\fR for \fBstat\fR\|(2).
 .TP
 .BI (sg)readfua \fR=\fPbool
 With readfua option set to 1, read operations include the force
 .TP
 .BI (sg)readfua \fR=\fPbool
 With readfua option set to 1, read operations include the force