From 496b1f9ee8b6e18991b2dce0bd20a6fd19d6dd2c Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Wed, 30 Aug 2017 00:12:16 +0300 Subject: [PATCH] change os_trim() prototype not to use int fd This is the same as the previous commit. The offset and length are universal regardless of platforms, but int fd is not, thus it should take struct fio_file*. In fact, other fd related functions under os/ don't take int fd for portability even if some of them work fine with int fd at the moment. (OS headers basically (should)have no dependencies on fio functions and structures, but struct fio_file is the only exception.) Signed-off-by: Tomohiro Kusumi Signed-off-by: Jens Axboe --- io_u.c | 2 +- os/os-android.h | 4 ++-- os/os-dragonfly.h | 4 ++-- os/os-freebsd.h | 4 ++-- os/os-linux.h | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/io_u.c b/io_u.c index ed8e84ab..db043e4a 100644 --- a/io_u.c +++ b/io_u.c @@ -2188,7 +2188,7 @@ int do_io_u_trim(const struct thread_data *td, struct io_u *io_u) struct fio_file *f = io_u->file; int ret; - ret = os_trim(f->fd, io_u->offset, io_u->xfer_buflen); + ret = os_trim(f, io_u->offset, io_u->xfer_buflen); if (!ret) return io_u->xfer_buflen; diff --git a/os/os-android.h b/os/os-android.h index b217daa9..bb590e47 100644 --- a/os/os-android.h +++ b/os/os-android.h @@ -274,7 +274,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]; @@ -282,7 +282,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; diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h index 8d158335..423b2369 100644 --- a/os/os-dragonfly.h +++ b/os/os-dragonfly.h @@ -216,7 +216,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) { off_t range[2]; @@ -224,7 +224,7 @@ static inline int os_trim(int fd, unsigned long long start, range[0] = start; range[1] = len; - if (!ioctl(fd, IOCTLTRIM, range)) + if (!ioctl(f->fd, IOCTLTRIM, range)) return 0; return errno; diff --git a/os/os-freebsd.h b/os/os-freebsd.h index e6da286e..4a7cdeb7 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -117,7 +117,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) { off_t range[2]; @@ -125,7 +125,7 @@ static inline int os_trim(int fd, unsigned long long start, range[0] = start; range[1] = len; - if (!ioctl(fd, DIOCGDELETE, range)) + if (!ioctl(f->fd, DIOCGDELETE, range)) return 0; return errno; diff --git a/os/os-linux.h b/os/os-linux.h index e7d600dd..1ad6ebd2 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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; -- 2.25.1