Skip to content

Commit 5a31024

Browse files
authored
pythongh-83714: Check for struct statx.stx_atomic_write_unit_max_opt in configure (python#140185)
stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled by the STATX_WRITE_ATOMIC mask bit added in Linux 6.11. That's safe at runtime because all kernels clear the reserved space in struct statx and zero is a valid value for stx_atomic_write_unit_max_opt, and it avoids allocating another mask bit, which are a limited resource. But it also means the kernel headers don't provide a way to check whether stx_atomic_write_unit_max_opt exists, so add a configure check.
1 parent ea4cc58 commit 5a31024

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ features:
34963496
Maximum optimized size for direct I/O with torn-write protection.
34973497

34983498
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3499-
userspace API headers >= 6.11.
3499+
userspace API headers >= 6.16.
35003500

35013501
.. attribute:: stx_atomic_write_segments_max
35023502

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,7 @@ static PyMemberDef pystatx_result_members[] = {
33693369
MM(stx_atomic_write_segments_max, Py_T_UINT, atomic_write_segments_max,
33703370
"maximum iovecs for direct I/O with torn-write protection"),
33713371
#endif
3372-
#if 0
3372+
#ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
33733373
MM(stx_atomic_write_unit_max_opt, Py_T_UINT, atomic_write_unit_max_opt,
33743374
"maximum optimized size for direct I/O with torn-write protection"),
33753375
#endif

configure

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5819,6 +5819,13 @@ AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
58195819
# Issue #21085: In Cygwin, siginfo_t does not have si_band field.
58205820
AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[@%:@include <signal.h>]])
58215821

5822+
if test "$ac_cv_func_statx" = yes; then
5823+
# stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled by
5824+
# the STATX_WRITE_ATOMIC mask bit added in Linux 6.11, so having the mask bit
5825+
# doesn't imply having the member.
5826+
AC_CHECK_MEMBERS([struct statx.stx_atomic_write_unit_max_opt])
5827+
fi
5828+
58225829
AC_CACHE_CHECK([for time.h that defines altzone], [ac_cv_header_time_altzone], [
58235830
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <time.h>]], [[return altzone;]])],
58245831
[ac_cv_header_time_altzone=yes],

pyconfig.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,10 @@
13301330
/* Define to 1 if 'pw_passwd' is a member of 'struct passwd'. */
13311331
#undef HAVE_STRUCT_PASSWD_PW_PASSWD
13321332

1333+
/* Define to 1 if 'stx_atomic_write_unit_max_opt' is a member of 'struct
1334+
statx'. */
1335+
#undef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
1336+
13331337
/* Define to 1 if 'st_birthtime' is a member of 'struct stat'. */
13341338
#undef HAVE_STRUCT_STAT_ST_BIRTHTIME
13351339

0 commit comments

Comments
 (0)