From: bxue@redhat.com
To: fstests@vger.kernel.org
Cc: lczerner@redhat.com, Boyang Xue <bxue@redhat.com>
Subject: [PATCH v1] src/stat_test.c: add STATX_DIOALIGN support
Date: Wed, 4 Jan 2023 12:28:01 +0800 [thread overview]
Message-ID: <20230104042801.217898-1-bxue@redhat.com> (raw)
From: Boyang Xue <bxue@redhat.com>
Signed-off-by: Boyang Xue <bxue@redhat.com>
---
Hi,
The latest kernel has support for exposing direct I/O alignment
information via statx() by
825cf206ed51 statx: add direct I/O alignment information
I'm trying to enhance xfstests/src/stat_test.c to support this
functionality, and the final goal is enhancing generic/423 to test it.
I think I have made all the necessary change here, but it always prints
stx_dio_mem_align and stx_dio_offset_align as 0 (should be 512)
[root@localhost repo_xfstests-dev]# src/stat_test -v
../testfile stx_dio_offset_align=222
- call statx ../testfile
- call stat ../testfile
- compare statx and stat
- begin time 0.000000000
- btime 1672804449.041990601
- atime 1672804449.041990601
- mtime 1672804449.127990601
- ctime 1672804449.127990601
- check stx_dio_offset_align=222
[!] stx_dio_offset_align differs, 0 != 222
Failed
src/stat_test.c | 10 ++++++++++
src/statx.h | 10 ++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
The kernel version in test is kernel-6.2.0-0.rc1.
Could you suggest how to fix it please?
Thanks,
Boyang
diff --git a/src/stat_test.c b/src/stat_test.c
index 95cfdc4f..cd38a54a 100644
--- a/src/stat_test.c
+++ b/src/stat_test.c
@@ -42,6 +42,8 @@ enum fields {
stx_ctime_tv_sec,
stx_dev_major,
stx_dev_minor,
+ stx_dio_mem_align,
+ stx_dio_offset_align,
stx_gid,
stx_ino,
stx_mask,
@@ -77,6 +79,8 @@ static const struct field field_list[nr__fields] = {
[stx_ctime_tv_sec] = { "stx_ctime.tv_sec", STATX_CTIME },
[stx_dev_major] = { "stx_dev_major", 0 },
[stx_dev_minor] = { "stx_dev_minor", 0 },
+ [stx_dio_mem_align] = { "stx_dio_mem_align", STATX_DIOALIGN },
+ [stx_dio_offset_align] = { "stx_dio_offset_align", STATX_DIOALIGN },
[stx_gid] = { "stx_gid", STATX_GID },
[stx_ino] = { "stx_ino", STATX_INO },
[stx_mask] = { "stx_mask", 0 },
@@ -460,6 +464,8 @@ static void cmp_ref(const struct statx *stx, unsigned int mask)
cmp("%llu", stx_rdev_minor);
cmp("%llu", stx_dev_major);
cmp("%llu", stx_dev_minor);
+ cmp("%llu", stx_dio_mem_align);
+ cmp("%llu", stx_dio_offset_align);
}
/*
@@ -506,6 +512,8 @@ static void check_field(const struct statx *stx, char *arg)
case stx_rdev_minor: uval = stx->stx_rdev_minor; break;
case stx_dev_major: uval = stx->stx_dev_major; break;
case stx_dev_minor: uval = stx->stx_dev_minor; break;
+ case stx_dio_mem_align: uval = stx->stx_dio_mem_align; break;
+ case stx_dio_offset_align: uval = stx->stx_dio_offset_align; break;
case stx_atime_tv_sec: sval = stx->stx_atime.tv_sec; break;
case stx_atime_tv_nsec: sval = stx->stx_atime.tv_nsec; break;
@@ -569,6 +577,8 @@ static void check_field(const struct statx *stx, char *arg)
"%s differs, %llu != %llu\n", key, uval, ucheck);
break;
+ case stx_dio_mem_align:
+ case stx_dio_offset_align:
case stx_atime_tv_sec:
case stx_atime_tv_nsec:
case stx_btime_tv_sec:
diff --git a/src/statx.h b/src/statx.h
index 3f239d79..116d1f43 100644
--- a/src/statx.h
+++ b/src/statx.h
@@ -114,7 +114,11 @@ struct statx {
__u32 stx_dev_major; /* ID of device containing file [uncond] */
__u32 stx_dev_minor;
/* 0x90 */
- __u64 __spare2[14]; /* Spare space for future expansion */
+ __u64 stx_mnt_id;
+ __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */
+ __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */
+ /* 0xa0 */
+ __u64 __spare3[12]; /* Spare space for future expansion */
/* 0x100 */
};
@@ -139,7 +143,9 @@ struct statx {
#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
-#define STATX_ALL 0x00000fffU /* All currently supported flags */
+#define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */
+#define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */
+#define STATX_ALL 0x00003fffU /* All currently supported flags */
/*
* Attributes to be found in stx_attributes
--
2.27.0
next reply other threads:[~2023-01-04 4:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 4:28 bxue [this message]
2023-01-06 7:59 ` [PATCH v1] src/stat_test.c: add STATX_DIOALIGN support Eric Biggers
2023-01-06 11:10 ` Boyang Xue
2023-01-06 19:02 ` Eric Biggers
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=20230104042801.217898-1-bxue@redhat.com \
--to=bxue@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=lczerner@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.