Add 64-bit length variants of {f,m}advise
The existing versions only take a 32-bit length, and hence cannot advise
in ranges bigger than 4GB.
Add *64 variants that take a full 64-bit length. This needs support
on the kernel side. If the kernel does not support the 64-bit variants,
the request will be errored with -EINVAL.
Link: https://lore.kernel.org/io-uring/bc92a2fa-4400-4c3a-8766-c2e346113ea7@s.muenzel.net/
Reported-by: Stefan <source@s.muenzel.net>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/man/io_uring_prep_fadvise.3 b/man/io_uring_prep_fadvise.3
index a53ab25..7b508b5 100644
--- a/man/io_uring_prep_fadvise.3
+++ b/man/io_uring_prep_fadvise.3
@@ -13,8 +13,14 @@
.BI "void io_uring_prep_fadvise(struct io_uring_sqe *" sqe ","
.BI " int " fd ","
.BI " __u64 " offset ","
-.BI " off_t " len ","
+.BI " __u32 " len ","
.BI " int " advice ");"
+.BI "
+.BI "void io_uring_prep_fadvise64(struct io_uring_sqe *" sqe ","
+.BI " int " fd ","
+.BI " __u64 " offset ","
+.BI " __u64 " len ","
+.BI " int " advice ");"
.fi
.SH DESCRIPTION
.PP
@@ -31,6 +37,17 @@
length in bytes, giving it the advise located in
.IR advice .
+The
+.BR io_uring_prep_fadvise64 (3)
+function works like
+.BR io_uring_prep_fadvise (3)
+except that it takes a 64-bit length rather than just a 32-bit one. Older
+kernels may not support the 64-bit length variant. If this variant is attempted
+used on a kernel that doesn't support 64-bit lengths, then the request will get
+errored with
+.B -EINVAL
+in the results field of the CQE.
+
This function prepares an async
.BR posix_fadvise (2)
request. See that man page for details.
diff --git a/man/io_uring_prep_fadvise64.3 b/man/io_uring_prep_fadvise64.3
new file mode 120000
index 0000000..cfd6828
--- /dev/null
+++ b/man/io_uring_prep_fadvise64.3
@@ -0,0 +1 @@
+io_uring_prep_fadvise.3
\ No newline at end of file
diff --git a/man/io_uring_prep_madvise.3 b/man/io_uring_prep_madvise.3
index 6c5f16b..664a020 100644
--- a/man/io_uring_prep_madvise.3
+++ b/man/io_uring_prep_madvise.3
@@ -12,8 +12,13 @@
.PP
.BI "void io_uring_prep_madvise(struct io_uring_sqe *" sqe ","
.BI " void *" addr ","
-.BI " off_t " len ","
+.BI " __u32 " len ","
.BI " int " advice ");"
+.BI "
+.BI "void io_uring_prep_madvise64(struct io_uring_sqe *" sqe ","
+.BI " void *" addr ","
+.BI " __u64 " len ","
+.BI " int " advice ");"
.fi
.SH DESCRIPTION
.PP
@@ -28,6 +33,17 @@
length in bytes, giving it the advise located in
.IR advice .
+The
+.BR io_uring_prep_madvise64 (3)
+function works like
+.BR io_uring_prep_madvise (3)
+except that it takes a 64-bit length rather than just a 32-bit one. Older
+kernels may not support the 64-bit length variant. If this variant is attempted
+used on a kernel that doesn't support 64-bit lengths, then the request will get
+errored with
+.B -EINVAL
+in the results field of the CQE.
+
This function prepares an async
.BR madvise (2)
request. See that man page for details.
diff --git a/man/io_uring_prep_madvise64.3 b/man/io_uring_prep_madvise64.3
new file mode 120000
index 0000000..1a368ee
--- /dev/null
+++ b/man/io_uring_prep_madvise64.3
@@ -0,0 +1 @@
+io_uring_prep_madvise.3
\ No newline at end of file
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 0a02364..e8626f0 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -751,19 +751,34 @@
}
IOURINGINLINE void io_uring_prep_fadvise(struct io_uring_sqe *sqe, int fd,
- __u64 offset, off_t len, int advice)
+ __u64 offset, __u32 len, int advice)
{
io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, (__u32) len, offset);
sqe->fadvise_advice = (__u32) advice;
}
IOURINGINLINE void io_uring_prep_madvise(struct io_uring_sqe *sqe, void *addr,
- off_t length, int advice)
+ __u32 length, int advice)
{
io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, (__u32) length, 0);
sqe->fadvise_advice = (__u32) advice;
}
+IOURINGINLINE void io_uring_prep_fadvise64(struct io_uring_sqe *sqe, int fd,
+ __u64 offset, off_t len, int advice)
+{
+ io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, 0, offset);
+ sqe->addr = len;
+ sqe->fadvise_advice = (__u32) advice;
+}
+
+IOURINGINLINE void io_uring_prep_madvise64(struct io_uring_sqe *sqe, void *addr,
+ off_t length, int advice)
+{
+ io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, 0, length);
+ sqe->fadvise_advice = (__u32) advice;
+}
+
IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
const void *buf, size_t len, int flags)
{
diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map
index 3be48d0..0e4bd9d 100644
--- a/src/liburing-ffi.map
+++ b/src/liburing-ffi.map
@@ -199,4 +199,6 @@
} LIBURING_2.5;
LIBURING_2.7 {
+ io_uring_prep_fadvise64;
+ io_uring_prep_madvise64;
} LIBURING_2.6;