#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/syscall.h>
+#include <sys/vfs.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/major.h>
#include "indirect.h"
+#include "binject.h"
#define FIO_HAVE_LIBAIO
#define FIO_HAVE_POSIXAIO
#define FIO_HAVE_CL_SIZE
#define FIO_HAVE_CGROUPS
#define FIO_HAVE_FDATASYNC
+#define FIO_HAVE_FS_STAT
+#define FIO_HAVE_TRIM
+#define FIO_HAVE_BINJECT
+
+#ifdef SYNC_FILE_RANGE_WAIT_BEFORE
#define FIO_HAVE_SYNC_FILE_RANGE
+#endif
#define OS_MAP_ANON MAP_ANONYMOUS
#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);
return atoi(size);
}
+static inline unsigned long long get_fs_size(const char *path)
+{
+ unsigned long long ret;
+ struct statfs s;
+
+ if (statfs(path, &s) < 0)
+ return -1ULL;
+
+ ret = s.f_bsize;
+ ret *= (unsigned long long) s.f_bfree;
+ 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