Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 1 | #ifndef FIO_OS_SOLARIS_H |
| 2 | #define FIO_OS_SOLARIS_H |
| 3 | |
Jens Axboe | 690dec6 | 2009-01-06 14:22:30 +0100 | [diff] [blame] | 4 | #include <errno.h> |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 5 | #include <sys/types.h> |
| 6 | #include <sys/fcntl.h> |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 7 | #include <sys/pset.h> |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 8 | |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 9 | #define FIO_HAVE_POSIXAIO |
Jens Axboe | 417f006 | 2008-06-02 11:59:30 +0200 | [diff] [blame] | 10 | #define FIO_HAVE_SOLARISAIO |
Jens Axboe | fffca02 | 2008-06-02 12:23:40 +0200 | [diff] [blame] | 11 | #define FIO_HAVE_FALLOCATE |
Jens Axboe | 207cb0f | 2008-06-02 12:28:02 +0200 | [diff] [blame] | 12 | #define FIO_HAVE_POSIXAIO_FSYNC |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 13 | #define FIO_HAVE_CPU_AFFINITY |
Jens Axboe | f356d01 | 2009-01-05 09:56:29 +0100 | [diff] [blame] | 14 | #define FIO_HAVE_PSHARED_MUTEX |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 15 | |
Jens Axboe | dc873b6 | 2008-06-04 20:13:04 +0200 | [diff] [blame] | 16 | #define OS_MAP_ANON MAP_ANON |
| 17 | #define OS_RAND_MAX 2147483648UL |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 18 | |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 19 | struct solaris_rand_seed { |
| 20 | unsigned short r[3]; |
| 21 | }; |
| 22 | |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 23 | typedef psetid_t os_cpu_mask_t; |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 24 | typedef struct solaris_rand_seed os_random_state_t; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * FIXME |
| 28 | */ |
| 29 | static inline int blockdev_size(int fd, unsigned long long *bytes) |
| 30 | { |
Jens Axboe | e5b401d | 2006-10-18 16:03:40 +0200 | [diff] [blame] | 31 | return EINVAL; |
| 32 | } |
| 33 | |
| 34 | static inline int blockdev_invalidate_cache(int fd) |
| 35 | { |
| 36 | return EINVAL; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static inline unsigned long long os_phys_mem(void) |
| 40 | { |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 41 | return 0; |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) |
| 45 | { |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 46 | rs->r[0] = seed & 0xffff; |
| 47 | seed >>= 16; |
| 48 | rs->r[1] = seed & 0xffff; |
| 49 | seed >>= 16; |
| 50 | rs->r[2] = seed & 0xffff; |
| 51 | seed48(rs->r); |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static inline long os_random_long(os_random_state_t *rs) |
| 55 | { |
Jens Axboe | f022ddb | 2008-06-04 19:55:58 +0200 | [diff] [blame] | 56 | return nrand48(rs->r); |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Jens Axboe | e116f2b | 2008-06-04 15:14:24 +0200 | [diff] [blame] | 59 | #define FIO_OS_DIRECTIO |
| 60 | extern int directio(int, int); |
| 61 | static inline int fio_set_odirect(int fd) |
| 62 | { |
| 63 | if (directio(fd, DIRECTIO_ON) < 0) |
| 64 | return errno; |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 69 | /* |
| 70 | * pset binding hooks for fio |
| 71 | */ |
Jens Axboe | e8462bd | 2009-07-06 12:59:04 +0200 | [diff] [blame^] | 72 | #define fio_setaffinity(pid, cpumask) \ |
| 73 | pset_bind(&(cpumask), P_PID, (pid), NULL) |
Jens Axboe | 39555d0 | 2008-12-22 11:28:26 +0100 | [diff] [blame] | 74 | #define fio_getaffinity(pid, ptr) ({ 0; }) |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 75 | |
Jens Axboe | 39555d0 | 2008-12-22 11:28:26 +0100 | [diff] [blame] | 76 | #define fio_cpu_clear(mask, cpu) pset_assign(PS_NONE, (cpu), NULL) |
| 77 | #define fio_cpu_set(mask, cpu) pset_assign(*(mask), (cpu), NULL) |
Jens Axboe | d2ce18b | 2008-12-12 20:51:40 +0100 | [diff] [blame] | 78 | |
| 79 | static inline int fio_cpuset_init(os_cpu_mask_t *mask) |
| 80 | { |
| 81 | int ret; |
| 82 | |
| 83 | if (pset_create(mask) < 0) { |
| 84 | ret = errno; |
| 85 | return -1; |
| 86 | } |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static inline int fio_cpuset_exit(os_cpu_mask_t *mask) |
| 92 | { |
| 93 | int ret; |
| 94 | |
| 95 | if (pset_destroy(*mask) < 0) { |
| 96 | ret = errno; |
| 97 | return -1; |
| 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | } |
Jens Axboe | 6f7024e | 2008-12-12 20:42:26 +0100 | [diff] [blame] | 102 | |
| 103 | /* |
| 104 | * Should be enough, not aware of what (if any) restrictions Solaris has |
| 105 | */ |
| 106 | #define FIO_MAX_CPUS 16384 |
| 107 | |
Jens Axboe | 2c0ecd2 | 2006-06-08 13:25:41 +0200 | [diff] [blame] | 108 | #endif |