From: linuxtestproject.agent@gmail.com
To: Gaurav Pathak <gpathak@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] syscalls/statx13: Add basic test for STATX_WRITE_ATOMIC on regular file
Date: Thu, 17 Sep 2026 11:17:51 +0000 [thread overview]
Message-ID: <20260917111751.8642-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260917105304.9674-1-gpathak@suse.de>
Hi Gaurav,
On Thu, 17 Sep 2026 16:23:04 +0530, Gaurav Pathak wrote:
> syscalls/statx13: Add basic test for STATX_WRITE_ATOMIC on regular file
> Fixes: #1224
Fixes tags must reference a valid commit SHA in git history. Use
Closes: #1224 or a Link tag to reference an issue.
> -AC_CHECK_MEMBERS([struct statx.stx_mnt_id, struct statx.stx_dio_mem_align],,,[
> +AC_CHECK_MEMBERS([struct statx.stx_mnt_id, struct statx.stx_dio_mem_align, struct statx.stx_atomic_write_unit_max_opt],,,[
> #define _GNU_SOURCE
> #include <sys/stat.h>
> ])
Do not use configure.ac checks to conditionally compile test logic.
Instead, add fallback definitions for STATX_WRITE_ATOMIC,
STATX_ATTR_WRITE_ATOMIC, and stx_atomic_write_* members in
include/lapi/stat.h so the test builds unconditionally.
> /*\
> * This test validates the STATX_WRITE_ATOMIC feature (introduced in Linux 6.13).
> * It ensures that supported filesystems (xfs as of now) correctly report their
> * atomic write limits to user space when queried via statx().
> *
> * The test performs the following validations:
> * - Creates a test file using O_DIRECT (a prerequisite for atomic writes).
Add a blank line before the bulleted list to comply with reST syntax.
> #define _GNU_SOURCE
> #include <sys/param.h>
> #include "tst_test.h"
Include "lapi/stat.h" so statx() and atomic write definitions are
available on older C libraries. <sys/param.h> is unused and should be
removed.
> TST_EXP_PASS_SILENT(statx(AT_FDCWD, TESTFILE, 0, STATX_BASIC_STATS | STATX_WRITE_ATOMIC, &buff),
> "statx(AT_FDCWD, %s, 0, STATX_WRITE_ATOMIC, &buf)", TESTFILE);
>
> if (!(buff.stx_attributes & STATX_ATTR_WRITE_ATOMIC)) {
TST_EXP_PASS_SILENT() does not abort on error. If statx() fails, execution
proceeds to read uninitialized memory from buff. Add "if (!TST_PASS)
return;" after the call. Also drop the redundant, mismatched format string.
> if (buff.stx_atomic_write_unit_max > 0 &&
> __builtin_popcount(buff.stx_atomic_write_unit_max) == 1)
> tst_res(TPASS, "stx_atomic_write_unit_max(%u) is power of 2",
> buff.stx_atomic_write_unit_max);
> else
> tst_res(TFAIL, "stx_atomic_write_unit_max(%u) is not a power of 2",
> buff.stx_atomic_write_unit_max);
Assert that buff.stx_atomic_write_unit_min <=
buff.stx_atomic_write_unit_max. The ordering between min and max is never
checked when stx_atomic_write_unit_max_opt is 0.
> #ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
> if (buff.stx_atomic_write_unit_max_opt == 0) {
> tst_res(TINFO, "stx_atomic_write_unit_max_opt is 0 (no optimized max reported)");
> } else {
> if (buff.stx_atomic_write_unit_max_opt > buff.stx_atomic_write_unit_max)
> tst_res(TFAIL, "stx_atomic_write_unit_max_opt (%u) exceeds max (%u)",
> buff.stx_atomic_write_unit_max_opt,
> buff.stx_atomic_write_unit_max);
>
> else if (buff.stx_atomic_write_unit_max_opt < buff.stx_atomic_write_unit_min)
> tst_res(TFAIL, "stx_atomic_write_unit_max_opt (%u) is less than min (%u)",
> buff.stx_atomic_write_unit_max_opt,
> buff.stx_atomic_write_unit_min);
> else
> tst_res(TPASS, "stx_atomic_write_unit_max_opt (%u) is within valid range [%u, %u]",
> buff.stx_atomic_write_unit_max_opt,
> buff.stx_atomic_write_unit_min,
> buff.stx_atomic_write_unit_max);
>
> if (__builtin_popcount(buff.stx_atomic_write_unit_max_opt) != 1)
> tst_res(TFAIL, "stx_atomic_write_unit_max_opt (%u) is not a power of 2",
> buff.stx_atomic_write_unit_max_opt);
> }
> #else
> tst_res(TCONF, "stx_atomic_write_unit_max_opt is not defined in struct statx");
> #endif
Do not bury #ifdef feature checks inside test functions. Defining the
members in include/lapi/stat.h removes the need for this guard and TCONF
branch.
> static void setup(void)
> {
> char *data_buff = SAFE_MEMALIGN(ALIGNMENT, WRITE_SIZE);
>
> if (strcmp(tst_device->fs_type, "xfs") && strcmp(tst_device->fs_type, "ext4"))
> tst_brk(TCONF, "This test only supports ext4 and xfs");
>
> umask(0);
> memset(data_buff, '@', WRITE_SIZE);
>
> file_fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT | O_DIRECT, MODE);
> SAFE_WRITE(SAFE_WRITE_ALL, file_fd, data_buff, WRITE_SIZE);
> }
data_buff is allocated with SAFE_MEMALIGN() but never freed. Free
data_buff after SAFE_WRITE(), and move the allocation after the
filesystem check so it is not leaked on tst_brk(). Also remove the extra
space after the '=' assignment.
> static void cleanup(void)
> {
> if (file_fd > -1)
> SAFE_CLOSE(file_fd);
> }
Use if (file_fd != -1) per LTP conventions.
Also, add an entry for statx13 to runtest/syscalls.
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-17 11:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 2:56 [LTP] [PATCH] syscalls/statx13: Add basic test for STATX_WRITE_ATOMIC on regular file Gaurav Pathak
2026-09-17 10:53 ` Gaurav Pathak
2026-09-17 11:17 ` linuxtestproject.agent [this message]
2026-09-17 14:19 ` Petr Vorel
2026-09-18 11:04 ` gpathak
2026-09-17 14:23 ` Petr Vorel
2026-09-18 11:12 ` [LTP] [PATCH v3] " Gaurav Pathak
2026-09-18 12:51 ` [LTP] " linuxtestproject.agent
2026-10-05 13:18 ` Andrea Cervesato via ltp
2026-10-08 14:26 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-09-17 11:15 ` [LTP] " linuxtestproject.agent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917111751.8642-1-linuxtestproject.agent@gmail.com \
--to=linuxtestproject.agent@gmail.com \
--cc=gpathak@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox