aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/unix/fs.c3
-rw-r--r--src/unix/internal.h2
-rw-r--r--src/unix/linux.c44
-rw-r--r--src/uv-common.h1
4 files changed, 32 insertions, 18 deletions
diff --git a/src/unix/fs.c b/src/unix/fs.c
index 6d810deb..d555491a 100644
--- a/src/unix/fs.c
+++ b/src/unix/fs.c
@@ -1910,6 +1910,9 @@ int uv_fs_ftruncate(uv_loop_t* loop,
INIT(FTRUNCATE);
req->file = file;
req->off = off;
+ if (cb != NULL)
+ if (uv__iou_fs_ftruncate(loop, req))
+ return 0;
POST;
}
diff --git a/src/unix/internal.h b/src/unix/internal.h
index 529c783e..138685c9 100644
--- a/src/unix/internal.h
+++ b/src/unix/internal.h
@@ -344,6 +344,7 @@ int uv__random_sysctl(void* buf, size_t buflen);
/* io_uring */
#ifdef __linux__
int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req);
+int uv__iou_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req);
int uv__iou_fs_fsync_or_fdatasync(uv_loop_t* loop,
uv_fs_t* req,
uint32_t fsync_flags);
@@ -362,6 +363,7 @@ int uv__iou_fs_symlink(uv_loop_t* loop, uv_fs_t* req);
int uv__iou_fs_unlink(uv_loop_t* loop, uv_fs_t* req);
#else
#define uv__iou_fs_close(loop, req) 0
+#define uv__iou_fs_ftruncate(loop, req) 0
#define uv__iou_fs_fsync_or_fdatasync(loop, req, fsync_flags) 0
#define uv__iou_fs_link(loop, req) 0
#define uv__iou_fs_mkdir(loop, req) 0
diff --git a/src/unix/linux.c b/src/unix/linux.c
index 2f726294..803a9a9d 100644
--- a/src/unix/linux.c
+++ b/src/unix/linux.c
@@ -148,6 +148,7 @@ enum {
UV__IORING_OP_MKDIRAT = 37,
UV__IORING_OP_SYMLINKAT = 38,
UV__IORING_OP_LINKAT = 39,
+ UV__IORING_OP_FTRUNCATE = 55,
};
enum {
@@ -160,10 +161,6 @@ enum {
UV__IORING_SQ_CQ_OVERFLOW = 2u,
};
-enum {
- UV__MKDIRAT_SYMLINKAT_LINKAT = 1u,
-};
-
struct uv__io_cqring_offsets {
uint32_t head;
uint32_t tail;
@@ -607,10 +604,6 @@ static void uv__iou_init(int epollfd,
iou->sqelen = sqelen;
iou->ringfd = ringfd;
iou->in_flight = 0;
- iou->flags = 0;
-
- if (kernel_version >= /* 5.15.0 */ 0x050F00)
- iou->flags |= UV__MKDIRAT_SYMLINKAT_LINKAT;
if (no_sqarray)
return;
@@ -871,6 +864,26 @@ int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req) {
}
+int uv__iou_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req) {
+ struct uv__io_uring_sqe* sqe;
+ struct uv__iou* iou;
+
+ if (uv__kernel_version() < /* 6.9 */0x060900)
+ return 0;
+
+ iou = &uv__get_internal_fields(loop)->iou;
+ sqe = uv__iou_get_sqe(iou, loop, req);
+ if (sqe == NULL)
+ return 0;
+
+ sqe->fd = req->file;
+ sqe->len = req->off;
+ sqe->opcode = UV__IORING_OP_FTRUNCATE;
+ uv__iou_submit(iou);
+
+ return 1;
+}
+
int uv__iou_fs_fsync_or_fdatasync(uv_loop_t* loop,
uv_fs_t* req,
uint32_t fsync_flags) {
@@ -900,11 +913,10 @@ int uv__iou_fs_link(uv_loop_t* loop, uv_fs_t* req) {
struct uv__io_uring_sqe* sqe;
struct uv__iou* iou;
- iou = &uv__get_internal_fields(loop)->iou;
-
- if (!(iou->flags & UV__MKDIRAT_SYMLINKAT_LINKAT))
+ if (uv__kernel_version() < /* 5.15.0 */0x050F00)
return 0;
+ iou = &uv__get_internal_fields(loop)->iou;
sqe = uv__iou_get_sqe(iou, loop, req);
if (sqe == NULL)
return 0;
@@ -925,11 +937,10 @@ int uv__iou_fs_mkdir(uv_loop_t* loop, uv_fs_t* req) {
struct uv__io_uring_sqe* sqe;
struct uv__iou* iou;
- iou = &uv__get_internal_fields(loop)->iou;
-
- if (!(iou->flags & UV__MKDIRAT_SYMLINKAT_LINKAT))
+ if (uv__kernel_version() < /* 5.15.0 */0x050F00)
return 0;
+ iou = &uv__get_internal_fields(loop)->iou;
sqe = uv__iou_get_sqe(iou, loop, req);
if (sqe == NULL)
return 0;
@@ -993,11 +1004,10 @@ int uv__iou_fs_symlink(uv_loop_t* loop, uv_fs_t* req) {
struct uv__io_uring_sqe* sqe;
struct uv__iou* iou;
- iou = &uv__get_internal_fields(loop)->iou;
-
- if (!(iou->flags & UV__MKDIRAT_SYMLINKAT_LINKAT))
+ if (uv__kernel_version() < /* 5.15.0 */0x050F00)
return 0;
+ iou = &uv__get_internal_fields(loop)->iou;
sqe = uv__iou_get_sqe(iou, loop, req);
if (sqe == NULL)
return 0;
diff --git a/src/uv-common.h b/src/uv-common.h
index 60bd0087..4baede2e 100644
--- a/src/uv-common.h
+++ b/src/uv-common.h
@@ -414,7 +414,6 @@ struct uv__iou {
size_t sqelen;
int ringfd;
uint32_t in_flight;
- uint32_t flags;
};
#endif /* __linux__ */