[PATCH] fio: ioprio compatability
authorJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 19:43:22 +0000 (20:43 +0100)
committerJens Axboe <axboe@suse.de>
Mon, 5 Dec 2005 19:43:22 +0000 (20:43 +0100)
arch.h
fio-ini.c
fio.c
os-linux.h
os.h

diff --git a/arch.h b/arch.h
index c503e51bdcb306d8185dabdbbde384a24496c4d9..da4a6a8e5ba3a4f064f18f961fd3a700fcce2b42 100644 (file)
--- a/arch.h
+++ b/arch.h
@@ -43,17 +43,4 @@ static inline unsigned long generic_ffz(unsigned long word)
 #define BLKGETSIZE64   _IOR(0x12,114,size_t)
 #endif
 
-static inline int ioprio_set(int which, int who, int ioprio)
-{
-       return syscall(__NR_ioprio_set, which, who, ioprio);
-}
-
-enum {
-       IOPRIO_WHO_PROCESS = 1,
-       IOPRIO_WHO_PGRP,
-       IOPRIO_WHO_USER,
-};
-
-#define IOPRIO_CLASS_SHIFT     13
-
 #endif
index 15cc1d890786404171791878b680e503bf5e62c6..1b1e464614e7134ec63b87b9e31c1603f1fd889f 100644 (file)
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -175,6 +175,9 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
                return 1;
        }
 #endif
+#ifdef FIO_HAVE_IOPRIO
+       td->ioprio = (prioclass << IOPRIO_CLASS_SHIFT) | prio;
+#endif
 
        td->filetype = FIO_TYPE_FILE;
        if (!stat(jobname, &sb) && S_ISBLK(sb.st_mode))
@@ -189,7 +192,6 @@ static int add_job(struct thread_data *td, const char *jobname, int prioclass,
                strcpy(td->file_name, jobname);
 
        sem_init(&td->mutex, 1, 0);
-       td->ioprio = (prioclass << IOPRIO_CLASS_SHIFT) | prio;
 
        td->clat_stat.min_val = ULONG_MAX;
        td->slat_stat.min_val = ULONG_MAX;
@@ -589,10 +591,18 @@ int parse_jobs_ini(char *file)
                        if (strstr(p, "["))
                                break;
                        if (!check_int(p, "prio", &prio)) {
+#ifndef FIO_HAVE_IOPRIO
+                               fprintf(stderr, "io priorities not available\n");
+                               return 1;
+#endif
                                fgetpos(f, &off);
                                continue;
                        }
                        if (!check_int(p, "prioclass", &prioclass)) {
+#ifndef FIO_HAVE_IOPRIO
+                               fprintf(stderr, "io priorities not available\n");
+                               return 1;
+#endif
                                fgetpos(f, &off);
                                continue;
                        }
diff --git a/fio.c b/fio.c
index ca79cb63756bccbf09ffdedaad419463a4ce8fca..afe63ab978d28d3169240feb9184673dac4a4719 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1861,7 +1861,6 @@ static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
 static void show_thread_status(struct thread_data *td,
                               struct group_run_stats *rs)
 {
-       int prio, prio_class;
        unsigned long min, max, bw = 0;
        double mean, dev, usr_cpu, sys_cpu;
 
@@ -1871,9 +1870,6 @@ static void show_thread_status(struct thread_data *td,
        if (td->runtime)
                bw = td->io_bytes / td->runtime;
 
-       prio = td->ioprio & 0xff;
-       prio_class = td->ioprio >> IOPRIO_CLASS_SHIFT;
-
        printf("Client%d (g=%d): err=%2d, io=%6luMiB, bw=%6luKiB/s, runt=%6lumsec\n", td->thread_number, td->groupid, td->error, td->io_bytes >> 20, bw, td->runtime);
 
        if (calc_lat(&td->slat_stat, &min, &max, &mean, &dev))
index fb06edfd9c2ce429e04a0d504ba1e9350b6bfcfd..8d9ad1a08029208024ff01d5385809a405b5ec1b 100644 (file)
@@ -22,4 +22,17 @@ typedef cpu_set_t os_cpu_mask_t;
 #define fio_getaffinity(pid, ptr)      \
        sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
 
+static inline int ioprio_set(int which, int who, int ioprio)
+{
+       return syscall(__NR_ioprio_set, which, who, ioprio);
+}
+
+enum {
+       IOPRIO_WHO_PROCESS = 1,
+       IOPRIO_WHO_PGRP,
+       IOPRIO_WHO_USER,
+};
+
+#define IOPRIO_CLASS_SHIFT     13
+
 #endif
diff --git a/os.h b/os.h
index a6de35c0fead30728d9e6e01a3cea5b50d09a6e8..adae4fe4f45c82602f44dc446d9947086b62c77d 100644 (file)
--- a/os.h
+++ b/os.h
 #define fio_getaffinity(pid, mask)     (0)
 #endif
 
+#ifndef FIO_HAVE_IOPRIO
+#define ioprio_set(which, who, prio)   (0)
+#endif
+
 struct thread_data;
 extern int fio_libaio_init(struct thread_data *);
 extern void fio_libaio_cleanup(struct thread_data *);