diff options
Diffstat (limited to 'os/os-linux.h')
-rw-r--r-- | os/os-linux.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/os/os-linux.h b/os/os-linux.h index df0ec2db..f7154a4a 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -36,6 +36,7 @@ #define FIO_HAVE_CGROUPS #define FIO_HAVE_FDATASYNC #define FIO_HAVE_FS_STAT +#define FIO_HAVE_TRIM #ifdef SYNC_FILE_RANGE_WAIT_BEFORE #define FIO_HAVE_SYNC_FILE_RANGE @@ -185,6 +186,10 @@ enum { #define BLKFLSBUF _IO(0x12,97) #endif +#ifndef BLKDISCARD +#define BLKDISCARD _IO(0x12,119) +#endif + static inline int blockdev_invalidate_cache(int fd) { return ioctl(fd, BLKFLSBUF); @@ -298,4 +303,18 @@ static inline unsigned long long get_fs_size(const char *path) return ret; } +static inline int os_trim(int fd, unsigned long long start, + unsigned long long len) +{ + uint64_t range[2]; + + range[0] = start; + range[1] = len; + + if (!ioctl(fd, BLKDISCARD, range)) + return 0; + + return errno; +} + #endif |