[LTP] syscalls/statx13: Add basic test for STATX_WRITE_ATOMIC on regular file

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Oct 14 09:52:53 CEST 2026


Hi Gaurav,

On 13 Oct 2026, Gaurav Pathak wrote:
> syscalls/statx13: Add basic test for STATX_WRITE_ATOMIC on regular file

> +	struct ltp_statx buff;
> +
> +	TST_EXP_PASS(statx(AT_FDCWD, TESTFILE, 0, STATX_BASIC_STATS | STATX_WRITE_ATOMIC, &buff.buff),
> +			"statx(AT_FDCWD, %s, 0, STATX_BASIC_STATS | STATX_WRITE_ATOMIC, &buf)", TESTFILE);

TST_EXP_PASS reports failure but does not return, so a statx() error leaves
the following checks reading uninitialized output. Return immediately when
!TST_PASS before accessing buff. Allocate this syscall buffer through .bufs
rather than on the stack.

> +	.min_kver = "6.11",
> ...
> +			.type = "xfs",
> +			.mkfs_opts = (const char *const []){"-f", "-bsize=16K", NULL},

Linux 6.11 rejects XFS blocks larger than PAGE_SIZE, so this configuration
fails to mount on a 4 KiB-page system admitted by min_kver. The framework
reports TBROK before setup or feature detection, also preventing the ext4
case from running. Use a portable block size or separately gate this
large-block configuration.

> +	if (!(buff.data.stx_attributes & STATX_ATTR_WRITE_ATOMIC))
> +		tst_brk(TCONF, "STATX_WRITE_ATOMIC unsupported by block dev or filesystem: STATX_ATTR_WRITE_ATOMIC missing from stx_attributes");

A response with nonzero atomic limits but a missing support attribute is
inconsistent, not simply unsupported. This branch hides that regression as
TCONF despite the stated goal of validating the attribute. Check
attribute/limit consistency first and reserve TCONF for unsupported results
with zero limits.

> +	uint32_t	stx_atomic_write_segments_max; \

verify_statx() never checks this returned limit. A response advertising
atomic writes with segments_max = 0 passes every assertion, although it
cannot describe a nonempty atomic write. Require
stx_atomic_write_segments_max > 0 when support is advertised.

> +	if (buff.data.stx_atomic_write_unit_min <= buff.data.stx_atomic_write_unit_max)
> +		tst_res(TPASS, "stx_atomic_write_unit_min(%u) <= stx_atomic_write_unit_max(%u)",
> +				buff.data.stx_atomic_write_unit_min, buff.data.stx_atomic_write_unit_max);
> +	else
> +		tst_res(TFAIL, "stx_atomic_write_unit_min(%u) > stx_atomic_write_unit_max(%u)",
> +				buff.data.stx_atomic_write_unit_min, buff.data.stx_atomic_write_unit_max);

Use TST_EXP_EXPR for this comparison and the repeated power-of-two
assertions instead of manual TPASS/TFAIL branches.

> + * It ensures that supported filesystems (xfs and nfs) correctly report their
> + * atomic write limits to user space when queried via statx().

The filesystem list tests XFS and ext4, not NFS. Describe the actual
regular-file checks using :manpage:`statx(2)` and document that root is
required to format and mount the test filesystems.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list