configure: use pkg-config to find liburing
PATCH v4 1/2 configure: use pkg-config to find liburing
Change our autoconf macros so that instead of checking for the presence of liburing.h, we use pkg-config.
The benefit of this is that we can then check the version of liburing, and do conditional compilation based on this. There's a macro IO_URING_CHECK_VERSION already, but it's only in relatively recent versions of liburing.h.
This replaces HAVE_URING_H, defined by AC_CHECK_HEADERS, with HAVE_URING. I also had to rename PKG_{MAJOR,MINOR,REVISION,BUILD} to start with PACKAGE_, to avoid "possibly undefined macro" errors; it looks like pkg-config assumes that anything called PKG_* is for its own use.
---
(This patch is unchanged from version 3.)
VERSION | 8 ++++---- m4/package_globals.m4 | 4 ++-- m4/package_liburing.m4 | 6 +++++- release.sh | 2 +- src/feature.c | 4 ++-- src/vfs/idmapped-mounts.c | 6 +++--- src/vfs/idmapped-mounts.h | 2 +- src/vfs/tmpfs-idmapped-mounts.c | 6 +++--- src/vfs/utils.c | 4 ++-- src/vfs/utils.h | 6 +++--- src/vfs/vfstest.c | 6 +++--- 11 files changed, 29 insertions(+), 25 deletions(-)
VERSION +4 -4
@@ -1,7 +1,7 @@ # # This file is used by configure to get version information # -PKG_MAJOR=1 -PKG_MINOR=1 -PKG_REVISION=1 -PKG_BUILD=1 +PACKAGE_MAJOR=1 +PACKAGE_MINOR=1 +PACKAGE_REVISION=1 +PACKAGE_BUILD=1
m4/package_globals.m4 +2 -2
@@ -9,9 +9,9 @@ AC_DEFUN([AC_PACKAGE_GLOBALS], AC_SUBST(pkg_name) . ./VERSION - pkg_version=${PKG_MAJOR}.${PKG_MINOR}.${PKG_REVISION} + pkg_version=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION} AC_SUBST(pkg_version) - pkg_release=$PKG_BUILD + pkg_release=$PACKAGE_BUILD test -z "$BUILD_VERSION" || pkg_release="$BUILD_VERSION" AC_SUBST(pkg_release)
m4/package_liburing.m4 +5 -1
@@ -1,4 +1,8 @@ AC_DEFUN([AC_PACKAGE_WANT_URING], - [ AC_CHECK_HEADERS(liburing.h, [ have_uring=true ], [ have_uring=false ]) + [ PKG_CHECK_MODULES([LIBURING], [liburing], + [ AC_DEFINE([HAVE_LIBURING], [1], [Use liburing]) + have_uring=true + ], + [ have_uring=false ]) AC_SUBST(have_uring) ])
release.sh +1 -1
@@ -5,7 +5,7 @@ . ./VERSION -version=${PKG_MAJOR}.${PKG_MINOR}.${PKG_REVISION} +version=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION} date=`date +"%-d %B %Y"` echo "Cleaning up"
src/feature.c +2 -2
@@ -42,7 +42,7 @@#include <libaio.h> #endif -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING #include <liburing.h> #endif
@@ -227,7 +227,7 @@ check_aio_support(void)static int check_uring_support (void ) { -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING struct io_uring ring;int err;
src/vfs/idmapped-mounts.c +3 -3
@@ -2206,7 +2206,7 @@ out: } -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING int tcore_io_uring_idmapped (const struct vfstest_info *info) {int fret =-1 ;
@@ -2743,7 +2743,7 @@ out_unmap: return fret; } -#endif /* HAVE_LIBURING_H */ +#endif /* HAVE_LIBURING */ /* Validate that protected symlinks work correctly on idmapped mounts. */ int tcore_protected_symlinks_idmapped_mounts (const struct vfstest_info *info)
@@ -8859,7 +8859,7 @@ static const struct test_struct t_idmapped_mounts[] = { { tcore_hardlink_crossing_idmapped_mounts, true, "cross idmapped mount hardlink", }, { tcore_hardlink_from_idmapped_mount, true, "hardlinks from idmapped mounts", }, { tcore_hardlink_from_idmapped_mount_in_userns, true, "hardlinks from idmapped mounts in user namespace", }, -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING { tcore_io_uring_idmapped, true, "io_uring from idmapped mounts", }, { tcore_io_uring_idmapped_userns, true, "io_uring from idmapped mounts in user namespace", }, { tcore_io_uring_idmapped_unmapped, true, "io_uring from idmapped mounts with unmapped ids", },
src/vfs/idmapped-mounts.h +1 -1
@@ -30,7 +30,7 @@ int tcore_fscaps_idmapped_mounts_in_userns_separate_userns(const struct vfstest_int tcore_hardlink_crossing_idmapped_mounts (const struct vfstest_info *info);int tcore_hardlink_from_idmapped_mount (const struct vfstest_info *info);int tcore_hardlink_from_idmapped_mount_in_userns (const struct vfstest_info *info); -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING int tcore_io_uring_idmapped (const struct vfstest_info *info);int tcore_io_uring_idmapped_userns (const struct vfstest_info *info);int tcore_io_uring_idmapped_unmapped (const struct vfstest_info *info);
src/vfs/tmpfs-idmapped-mounts.c +3 -3
@@ -167,7 +167,7 @@ static int tmpfs_hardlink_from_idmapped_mount_in_userns(const struct vfstest_infreturn tmpfs_nested_mount_setup (info, tcore_hardlink_from_idmapped_mount_in_userns); } -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING static int tmpfs_io_uring_idmapped (const struct vfstest_info *info) {return tmpfs_nested_mount_setup (info, tcore_io_uring_idmapped);
@@ -184,7 +184,7 @@ static int tmpfs_io_uring_idmapped_unmapped_userns(const struct vfstest_info *in {return tmpfs_nested_mount_setup (info, tcore_io_uring_idmapped_unmapped_userns); } -#endif /* HAVE_LIBURING_H */ +#endif /* HAVE_LIBURING */ static int tmpfs_protected_symlinks_idmapped_mounts (const struct vfstest_info *info) {
@@ -272,7 +272,7 @@ static const struct test_struct t_tmpfs[] = { { tmpfs_hardlink_crossing_idmapped_mounts, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs cross idmapped mount hardlink", }, { tmpfs_hardlink_from_idmapped_mount, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs hardlinks from idmapped mounts", }, { tmpfs_hardlink_from_idmapped_mount_in_userns, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs hardlinks from idmapped mounts in user namespace", }, -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING { tmpfs_io_uring_idmapped, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs io_uring from idmapped mounts", }, { tmpfs_io_uring_idmapped_userns, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs io_uring from idmapped mounts in user namespace", }, { tmpfs_io_uring_idmapped_unmapped, T_REQUIRE_USERNS | T_REQUIRE_IDMAPPED_MOUNTS, "tmpfs io_uring from idmapped mounts with unmapped ids", },
src/vfs/utils.c +2 -2
@@ -502,7 +502,7 @@ out:return fret; } -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING int io_uring_openat_with_creds (struct io_uring *ring,int dfd,const char *path,int cred_id,bool with_link,int *ret_cqe) {
@@ -555,7 +555,7 @@ int io_uring_openat_with_creds(struct io_uring *ring, int dfd, const char *path, out: return ret; } -#endif /* HAVE_LIBURING_H */ +#endif /* HAVE_LIBURING */ /* caps_up - raise all permitted caps */ int caps_up (void )
src/vfs/utils.h +3 -3
@@ -25,7 +25,7 @@#include <sys/capability.h> #endif -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING #include <liburing.h> #endif
@@ -349,11 +349,11 @@ static inline bool switch_fsids(uid_t fsuid, gid_t fsgid)return true; } -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING extern int io_uring_openat_with_creds (struct io_uring *ring,int dfd,const char *path,int cred_id,bool with_link,int *ret_cqe); -#endif /* HAVE_LIBURING_H */ +#endif /* HAVE_LIBURING */ extern int chown_r (int fd,const char *path,uid_t uid,gid_t gid);extern int rm_r (int fd,const char *path);
src/vfs/vfstest.c +3 -3
@@ -1222,7 +1222,7 @@ out:return fret; } -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING static int io_uring (const struct vfstest_info *info) {int fret =-1 ;
@@ -1495,7 +1495,7 @@ out_unmap: return fret; } -#endif /* HAVE_LIBURING_H */ +#endif /* HAVE_LIBURING */ /* The following tests are concerned with setgid inheritance. These can be * filesystem type specific. For xfs, if a new file or directory or node is
@@ -2349,7 +2349,7 @@ static const struct option longopts[] = {static const struct test_struct t_basic[] = { { fscaps,T_REQUIRE_USERNS ,"fscaps on regular mounts" , }, { hardlink_crossing_mounts,0 ,"cross mount hardlink" , }, -#ifdef HAVE_LIBURING_H +#ifdef HAVE_LIBURING { io_uring,0 ,"io_uring" , }, { io_uring_userns,T_REQUIRE_USERNS ,"io_uring in user namespace" , }, #endif
Signature · 1 line
2.45.2
PATCH v4 2/2 btrfs: add test for encoded reads
Add btrfs/333 and its helper programs btrfs_encoded_read and btrfs_encoded_write, in order to test encoded reads.
We use the BTRFS_IOC_ENCODED_WRITE ioctl to write random data into a compressed extent, then use the BTRFS_IOC_ENCODED_READ ioctl to check that it matches what we've written. If the new io_uring interface for encoded reads is supported, we also check that that matches the ioctl.
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
---
This patch includes the miscellaneous fixes and formatting changes suggested by Josef and Anand for version 3.
.gitignore | 2 + common/btrfs | 32 ++++++ m4/package_liburing.m4 | 2 + src/Makefile | 1 + src/btrfs_encoded_read.c | 195 +++++++++++++++++++++++++++++++ src/btrfs_encoded_write.c | 226 ++++++++++++++++++++++++++++++++++++ tests/btrfs/333 | 233 ++++++++++++++++++++++++++++++++++++++ tests/btrfs/333.out | 2 + 8 files changed, 693 insertions(+) create mode 100644 src/btrfs_encoded_read.c create mode 100644 src/btrfs_encoded_write.c create mode 100755 tests/btrfs/333 create mode 100644 tests/btrfs/333.out
.gitignore +2 -0
@@ -62,6 +62,8 @@ tags /src/attr_replace_test /src/attr-list-by-handle-cursor-test /src/bstat +/src/btrfs_encoded_read +/src/btrfs_encoded_write /src/bulkstat_null_ocount /src/bulkstat_unlink_test /src/bulkstat_unlink_test_modified
common/btrfs +32 -0
@@ -1009,3 +1009,35 @@ _require_btrfs_raid_type() _check_btrfs_raid_type $1 || \ _notrun "$1 isn't supported by the profile config or scratch device" } + +_require_btrfs_iouring_encoded_read() +{ + local fn + local tmpfile + local ret + + _require_command src/btrfs_encoded_read + + _scratch_mkfs &> /dev/null + _scratch_mount + + fn=`mktemp -p $SCRATCH_MNT` + tmpfile=`mktemp` + + src/btrfs_encoded_read io_uring $fn 0 > $tmpfile + ret=$? + + _scratch_unmount + + if [[ $ret -ne 0 ]]; then + rm $tmpfile + _fail "btrfs_encoded_read failed" >>$seqres.full + fi + + read ret < $tmpfile + rm $tmpfile + + if [[ $ret == -95 ]]; then + _notrun "btrfs io_uring encoded read failed with -EOPNOTSUPP" + fi +}
m4/package_liburing.m4 +2 -0
@@ -1,6 +1,8 @@ AC_DEFUN([AC_PACKAGE_WANT_URING], [ PKG_CHECK_MODULES([LIBURING], [liburing], [ AC_DEFINE([HAVE_LIBURING], [1], [Use liburing]) + AC_DEFINE_UNQUOTED([LIBURING_MAJOR_VERSION], [`$PKG_CONFIG --modversion liburing | cut -d. -f1`], [liburing major version]) + AC_DEFINE_UNQUOTED([LIBURING_MINOR_VERSION], [`$PKG_CONFIG --modversion liburing | cut -d. -f2`], [liburing minor version]) have_uring=true ], [ have_uring=false ])
src/Makefile +1 -0
@@ -76,6 +76,7 @@ LLDLIBS += -laio endif ifeq ($(HAVE_URING), true) +LINUX_TARGETS += btrfs_encoded_read btrfs_encoded_write TARGETS += uring_read_fault LLDLIBS += -luring endif
src/btrfs_encoded_read.c new file +195 -0
195 lines not on this page · raw message
src/btrfs_encoded_write.c new file +226 -0
226 lines not on this page · raw message
tests/btrfs/333 new file +233 -0
233 lines not on this page · raw message
tests/btrfs/333.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 333 +Silence is golden
Signature · 1 line
2.45.2
Re: [PATCH v4 2/2] btrfs: add test for encoded reads
Quoted 8 lines · Mark Harmstone
Add btrfs/333 and its helper programs
btrfs_encoded_readandbtrfs_encoded_write, in order to test encoded reads.We use the
BTRFS_IOC_ENCODED_WRITEioctl to write random data into a compressed extent, then use theBTRFS_IOC_ENCODED_READioctl to check that it matches what we've written. If the newio_uringinterface for encoded reads is supported, we also check that that matches the ioctl.
Quoted 5 lines
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
Signed-off-by Mark Harmstone <[email protected]>---
Looks good. Add to the group io_uring and ioctl.
Thx.
Re: [PATCH v4 2/2] btrfs: add test for encoded reads
Quoted 17 lines · Anand Jain
Quoted 1 line
Quoted 8 lines · Mark Harmstone
Add btrfs/333 and its helper programs
btrfs_encoded_readandbtrfs_encoded_write, in order to test encoded reads.We use the
BTRFS_IOC_ENCODED_WRITEioctl to write random data into a compressed extent, then use theBTRFS_IOC_ENCODED_READioctl to check that it matches what we've written. If the newio_uringinterface for encoded reads is supported, we also check that that matches the ioctl.Quoted 5 lines
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
Signed-off-by Mark Harmstone <[email protected]>---
Quoted 5 lines
Looks good. Add to the group
io_uringand ioctl.Reviewed-by Anand Jain <[email protected]>Thx.
Thanks Anand.
Zorro, can you please add io_uring and ioctl to the _begin_fstest line? Or do you want me to resubmit?
Thanks
Mark
Re: [PATCH v4 2/2] btrfs: add test for encoded reads
Quoted 20 lines · Mark Harmstone
Quoted 19 lines · Anand Jain
Quoted 1 line
Quoted 8 lines · Mark Harmstone
Add btrfs/333 and its helper programs
btrfs_encoded_readandbtrfs_encoded_write, in order to test encoded reads.We use the
BTRFS_IOC_ENCODED_WRITEioctl to write random data into a compressed extent, then use theBTRFS_IOC_ENCODED_READioctl to check that it matches what we've written. If the newio_uringinterface for encoded reads is supported, we also check that that matches the ioctl.Quoted 5 lines
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
Signed-off-by Mark Harmstone <[email protected]>---
Looks good. Add to the group
io_uringand ioctl.
Quoted 9 lines
Quoted 3 lines
Reviewed-by Anand Jain <[email protected]>Thx.
Thanks Anand.
Zorro, can you please add
io_uringand ioctl to the_begin_fstestline? Or do you want me to resubmit?
It has already been added to the local testing fstests repo, and the PR has been submitted.
https://github.com/asj/fstests.git staged-20250109
Thx.
Quoted 3 lines
Thanks
Mark
Re: [PATCH v4 2/2] btrfs: add test for encoded reads
In reply to Mark HarmstoneQuoted 20 lines · Mark Harmstone
Quoted 19 lines · Anand Jain
Quoted 1 line
Quoted 8 lines · Mark Harmstone
Add btrfs/333 and its helper programs
btrfs_encoded_readandbtrfs_encoded_write, in order to test encoded reads.We use the
BTRFS_IOC_ENCODED_WRITEioctl to write random data into a compressed extent, then use theBTRFS_IOC_ENCODED_READioctl to check that it matches what we've written. If the newio_uringinterface for encoded reads is supported, we also check that that matches the ioctl.Quoted 5 lines
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
Signed-off-by Mark Harmstone <[email protected]>---
Looks good. Add to the group
io_uringand ioctl.
Quoted 8 lines
Quoted 3 lines
Reviewed-by Anand Jain <[email protected]>Thx.
Thanks Anand.
Zorro, can you please add
io_uringand ioctl to the_begin_fstestline? Or do you want me to resubmit?
It's been added by Anand, I've merged it. Also I'd like to remove below lines:
. ./common/filter
. ./common/btrfs
_supported_fs btrfs
Thanks,
Zorro
Quoted 5 lines
Thanks
Mark
Re: [PATCH v4 2/2] btrfs: add test for encoded reads
Quoted 31 lines · Zorro Lang
Quoted 1 line
Quoted 20 lines · Mark Harmstone
Quoted 19 lines · Anand Jain
Quoted 1 line
Quoted 8 lines · Mark Harmstone
Add btrfs/333 and its helper programs
btrfs_encoded_readandbtrfs_encoded_write, in order to test encoded reads.We use the
BTRFS_IOC_ENCODED_WRITEioctl to write random data into a compressed extent, then use theBTRFS_IOC_ENCODED_READioctl to check that it matches what we've written. If the newio_uringinterface for encoded reads is supported, we also check that that matches the ioctl.Quoted 5 lines
Note that what we write isn't valid compressed data, so any non-encoded reads on these files will fail.
Signed-off-by Mark Harmstone <[email protected]>---
Looks good. Add to the group
io_uringand ioctl.Quoted 8 lines
Quoted 3 lines
Reviewed-by Anand Jain <[email protected]>Thx.
Thanks Anand.
Zorro, can you please add
io_uringand ioctl to the_begin_fstestline? Or do you want me to resubmit?
Quoted 7 lines
It's been added by Anand, I've merged it. Also I'd like to remove below lines:
. ./common/filter
. ./common/btrfs
_supported_fsbtrfs
Thanks Zorro. If it still works with them removed, sure.
Mark
Quoted 9 lines
Thanks,
ZorroQuoted 5 lines
Thanks
Mark