io_uring_prep_fsync(3)
πΎ io_uring_prep_fsync β bestie, it's time to flush
okay so welcome to io_uring_prep_fsync(3), a lil liburing helper whose whole job is prepare an fsync request. yes, the manual page is literally called that. it's part of the liburing manual, and it lives in section 3, and it is genuinely so good at what it does. sit down, grab a strawberry π, let's go.
β¨ SYNOPSIS β¨
#include <liburing.h>
void io_uring_prep_fsync(struct io_uring_sqe *sqe,
int fd,
unsigned flags);
that's it. three args. no drama. π
πΈ DESCRIPTION πΈ
so the way that io_uring_prep_fsync(3) works is: it prepares an fsync request. that's the whole vibe. it takes your submission queue entry sqe and sets it up to use the file descriptor fd, which is the thing that's gonna get synced, and then it sprinkles on the modifier behavior you asked for via the flags argument. β¨
here's the tea though β this helper can act two different ways:
- by default, it behaves like an
fsync(2)operation. classic. iconic. π - if
IORING_FSYNC_DATASYNCis set in theflagsargument, then it behaves likefdatasync(2)instead. boom, different flavor.
and if you don't specify a range? no worries, the fd will be synced from 0 all the way to end-of-file. full sweep. no crumbs left. π§Ή
now β you can specify a range to sync if that's what you want, and this part is important so don't scroll past it:
- if the
offfield of the SQE is set to non-zero, that indicates the offset to start syncing at π - if
lenis set in the SQE, that indicates the size in bytes to sync from the offset π
β οΈ but listen β those fields are not accepted by this helper. it will not take them from you. you have to set them manually in the SQE after calling this prep helper. like, set it up first, then reach in and fix the fields yourself. iykyk. π
π RETURN VALUE π
None. literally nothing. it returns void, it says nothing, it gives nothing back. it's not about the return, bestie, it's about the prep. π
π ERRORS π
okay so where do errors even go if the function returns nothing? great question, obsessed that you asked. π
the CQE res field will contain the result of the operation. if you want details on the possible values, go read the related man page β that's where that info lives.
and here's the big one, the one that trips people up, so pay attention:
- where synchronous system calls will return
-1on failure and seterrnoto the actual error value⦠io_uringnever useserrno. never. not once. not ever.- instead, it returns the negated errno directly in the
CQEresfield. π₯
so like, no errno checking over here. the error is right there in res, negated. that's the whole system. periodt. π
π¦ SEE ALSO π¦
go read those too, they're all part of the same little friend group. π«Ά
and that's the page!! this whole thing is from liburing-2.2, dated March 12, 2022, and honestly it ate. πβ¨ sync responsibly, bestie. ππ
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian bookworm: liburing-dev 2.3-3
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu noble: liburing-dev 2.5-1build1
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms