From: Tomohiro Kusumi Date: Tue, 29 Aug 2017 21:12:16 +0000 (+0300) Subject: change os_trim() prototype not to use int fd X-Git-Tag: fio-3.1~32 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;ds=sidebyside;h=496b1f9ee8b6e18991b2dce0bd20a6fd19d6dd2c;p=fio.git 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 --- 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;