From 7b5c648f6a5c05716e2f345c9d640965abda8761 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 18 May 2017 11:59:09 -0600 Subject: [PATCH 1/1] Fix wrap issue with 64-bit pwritev2/preadv2 Apparently I missed that Linux does a clever trick to optimize how we pass in lo/hi offsets for 64-bit, and it encodes the full offset in just the low part. This caused corruption when writing with pwritev2 for laver sizes, and bad data for preadv2 for larger sizes. Signed-off-by: Jens Axboe --- os/os-linux.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/os/os-linux.h b/os/os-linux.h index 911f7e7c..695e9dad 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -314,9 +314,15 @@ static inline int fio_set_sched_idle(void) static inline void make_pos_h_l(unsigned long *pos_h, unsigned long *pos_l, off_t offset) { +#if BITS_PER_LONG == 64 +#warning 64 + *pos_l = offset; + *pos_h = 0; +#else +#warning 32 *pos_l = offset & 0xffffffff; *pos_h = ((uint64_t) offset) >> 32; - +#endif } static inline ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, unsigned int flags) -- 2.25.1