Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1 | #ifndef FIO_OS_LINUX_H |
| 2 | #define FIO_OS_LINUX_H |
| 3 | |
| 4 | #include <sys/ioctl.h> |
| 5 | |
| 6 | #define FIO_HAVE_LIBAIO |
| 7 | #define FIO_HAVE_POSIXAIO |
| 8 | #define FIO_HAVE_FADVISE |
| 9 | #define FIO_HAVE_CPU_AFFINITY |
| 10 | #define FIO_HAVE_DISK_UTIL |
| 11 | #define FIO_HAVE_SGIO |
Jens Axboe | ba4f892 | 2006-01-26 13:45:54 -0800 | [diff] [blame^] | 12 | #define FIO_HAVE_IOPRIO |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 13 | |
| 14 | #define OS_MAP_ANON (MAP_ANONYMOUS) |
| 15 | |
| 16 | typedef cpu_set_t os_cpu_mask_t; |
| 17 | |
| 18 | /* |
| 19 | * we want fadvise64 really, but it's so tangled... later |
| 20 | */ |
| 21 | #define fadvise(fd, off, len, advice) \ |
| 22 | posix_fadvise((fd), (off_t)(off), (len), (advice)) |
| 23 | |
| 24 | #define fio_setaffinity(td) \ |
| 25 | sched_setaffinity((td)->pid, sizeof((td)->cpumask), &(td)->cpumask) |
| 26 | #define fio_getaffinity(pid, ptr) \ |
| 27 | sched_getaffinity((pid), sizeof(cpu_set_t), (ptr)) |
| 28 | |
| 29 | static inline int ioprio_set(int which, int who, int ioprio) |
| 30 | { |
| 31 | return syscall(__NR_ioprio_set, which, who, ioprio); |
| 32 | } |
| 33 | |
| 34 | enum { |
| 35 | IOPRIO_WHO_PROCESS = 1, |
| 36 | IOPRIO_WHO_PGRP, |
| 37 | IOPRIO_WHO_USER, |
| 38 | }; |
| 39 | |
| 40 | #define IOPRIO_CLASS_SHIFT 13 |
| 41 | |
| 42 | #ifndef BLKGETSIZE64 |
| 43 | #define BLKGETSIZE64 _IOR(0x12,114,size_t) |
| 44 | #endif |
| 45 | |
Jens Axboe | 9104f87 | 2005-12-28 23:50:45 +0100 | [diff] [blame] | 46 | static inline int blockdev_size(int fd, unsigned long long *bytes) |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 47 | { |
| 48 | if (!ioctl(fd, BLKGETSIZE64, bytes)) |
| 49 | return 0; |
| 50 | |
| 51 | return errno; |
| 52 | } |
| 53 | |
| 54 | #endif |