X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=os%2Fos-linux.h;h=894dc850904f0717d745ac61ce2805e349aff210;hb=a6ab5391edbc87bdf1e5c0d218ccf7d8325a8c55;hp=008ce2d0af1c15e78d0bcf19574f5d0ba0a0df02;hpb=2293bf6886095fc180a77a958511bd6385840874;p=fio.git diff --git a/os/os-linux.h b/os/os-linux.h index 008ce2d0..894dc850 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -71,7 +71,7 @@ typedef struct drand48_data os_random_state_t; #define fio_cpu_clear(mask, cpu) (void) CPU_CLR((cpu), (mask)) #define fio_cpu_set(mask, cpu) (void) CPU_SET((cpu), (mask)) -#define fio_cpu_isset(mask, cpu) CPU_ISSET((cpu), (mask)) +#define fio_cpu_isset(mask, cpu) (CPU_ISSET((cpu), (mask)) != 0) #define fio_cpu_count(mask) CPU_COUNT((mask)) static inline int fio_cpuset_init(os_cpu_mask_t *mask) @@ -281,7 +281,7 @@ static inline unsigned long long get_fs_free_size(const char *path) return ret; } -static inline int os_trim(int fd, unsigned long long start, +static inline int os_trim(struct fio_file *f, unsigned long long start, unsigned long long len) { uint64_t range[2]; @@ -289,7 +289,7 @@ static inline int os_trim(int fd, unsigned long long start, range[0] = start; range[1] = len; - if (!ioctl(fd, BLKDISCARD, range)) + if (!ioctl(f->fd, BLKDISCARD, range)) return 0; return errno; @@ -303,11 +303,26 @@ static inline int fio_set_sched_idle(void) } #endif -#ifndef POSIX_FADV_STREAMID -#define POSIX_FADV_STREAMID 8 +#ifndef F_GET_RW_HINT +#ifndef F_LINUX_SPECIFIC_BASE +#define F_LINUX_SPECIFIC_BASE 1024 +#endif +#define F_GET_RW_HINT (F_LINUX_SPECIFIC_BASE + 11) +#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12) +#define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13) +#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14) +#endif + +#ifndef RWH_WRITE_LIFE_NONE +#define RWH_WRITE_LIFE_NOT_SET 0 +#define RWH_WRITE_LIFE_NONE 1 +#define RWH_WRITE_LIFE_SHORT 2 +#define RWH_WRITE_LIFE_MEDIUM 3 +#define RWH_WRITE_LIFE_LONG 4 +#define RWH_WRITE_LIFE_EXTREME 5 #endif -#define FIO_HAVE_STREAMID +#define FIO_HAVE_WRITE_HINT #ifndef RWF_HIPRI #define RWF_HIPRI 0x00000001 @@ -319,6 +334,14 @@ static inline int fio_set_sched_idle(void) #define RWF_SYNC 0x00000004 #endif +#ifndef RWF_WRITE_LIFE_SHIFT +#define RWF_WRITE_LIFE_SHIFT 4 +#define RWF_WRITE_LIFE_SHORT (1 << RWF_WRITE_LIFE_SHIFT) +#define RWF_WRITE_LIFE_MEDIUM (2 << RWF_WRITE_LIFE_SHIFT) +#define RWF_WRITE_LIFE_LONG (3 << RWF_WRITE_LIFE_SHIFT) +#define RWF_WRITE_LIFE_EXTREME (4 << RWF_WRITE_LIFE_SHIFT) +#endif + #ifndef CONFIG_PWRITEV2 #ifdef __NR_preadv2 static inline void make_pos_h_l(unsigned long *pos_h, unsigned long *pos_l, @@ -369,4 +392,22 @@ static inline int shm_attach_to_open_removed(void) return 1; } +#ifdef CONFIG_LINUX_FALLOCATE +#define FIO_HAVE_NATIVE_FALLOCATE +static inline bool fio_fallocate(struct fio_file *f, uint64_t offset, + uint64_t len) +{ + int ret; + ret = fallocate(f->fd, 0, 0, len); + if (ret == 0) + return true; + + /* Work around buggy old glibc versions... */ + if (ret > 0) + errno = ret; + + return false; +} +#endif + #endif