From: Jens Axboe Date: Mon, 5 Dec 2005 19:43:22 +0000 (+0100) Subject: [PATCH] fio: ioprio compatability X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=4811f429cc8f7db68850579ac14bb1b95e0016ee;p=disktools.git [PATCH] fio: ioprio compatability --- diff --git a/arch.h b/arch.h index c503e51..da4a6a8 100644 --- 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 diff --git a/fio-ini.c b/fio-ini.c index 15cc1d8..1b1e464 100644 --- 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 ca79cb6..afe63ab 100644 --- 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)) diff --git a/os-linux.h b/os-linux.h index fb06edf..8d9ad1a 100644 --- a/os-linux.h +++ b/os-linux.h @@ -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 a6de35c..adae4fe 100644 --- a/os.h +++ b/os.h @@ -30,6 +30,10 @@ #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 *);