[PATCH] Add support for read/write mixed io
[fio.git] / os-linux.h
CommitLineData
ebac4655
JA
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
ba4f8923 12#define FIO_HAVE_IOPRIO
ebac4655
JA
13
14#define OS_MAP_ANON (MAP_ANONYMOUS)
15
16typedef 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
29static inline int ioprio_set(int which, int who, int ioprio)
30{
31 return syscall(__NR_ioprio_set, which, who, ioprio);
32}
33
34enum {
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
9104f874 46static inline int blockdev_size(int fd, unsigned long long *bytes)
ebac4655
JA
47{
48 if (!ioctl(fd, BLKGETSIZE64, bytes))
49 return 0;
50
51 return errno;
52}
53
54#endif