From: Eric Biggers <ebiggers@kernel.org>
To: "Yang Xu (Fujitsu)" <xuyang2018.jy@fujitsu.com>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v4 2/4] syscalls/statx10: Add basic test for STATX_DIOALIGN on regular file
Date: Mon, 1 May 2023 10:44:42 -0700 [thread overview]
Message-ID: <20230501174442.GA1224@sol.localdomain> (raw)
In-Reply-To: <b1f3f7ee-6f90-172c-520a-fd6ddc23363f@fujitsu.com>
On Thu, Apr 27, 2023 at 03:03:23AM +0000, Yang Xu (Fujitsu) wrote:
> on 2023/04/27 6:06, Eric Biggers wrote:
> > On Thu, Apr 06, 2023 at 01:40:20PM +0800, Yang Xu wrote:
> >> + * On ext4, files that use certain filesystem features (data journaling,
> >> + * encryption, and verity) fall back to buffered I/O. But ltp doesn't use these
> >> + * features by default, So I think dio should not fall back to buffered I/O.
> >
> > Does LTP create and mount the filesystem itself?
>
> Yes, I have enabled mount_device in tst_test struct, mount_device usage
> you can see the following url.
> https://github.com/linux-test-project/ltp/wiki/C-Test-API#115-testing-with-a-block-device
>
> If we set block device to LTP_DEV environment, we use this block device
> to mount. Otherwise, use loop device to simuate it.
Great, can you update the comment to make it clear that this test creates its
own filesystem?
> >
> > If not, then it wouldn't have control over this.
> >
> >> + if (!(buf.stx_mask & STATX_DIOALIGN)) {
> >> + tst_res(TCONF, "STATX_DIOALIGN is not supported until linux 6.1");
> >> + return;
> >> + }
> >
> > "Filesystem does not support STATX_DIOALIGN"
>
> OK.
> >
> >> +
> >> +#ifdef HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN
> >
> > This looks wrong. If the system headers are missing this field, then the
> > definition in the LTP source tree should be used instead.
>
> Yes, usually, if system headers miss this field, we should use ltp
> definition ie some macro. But here it has a little difference, it is a
> member in a struct.
>
> see include/lapi/stat.h
>
> #if defined(HAVE_STRUCT_STATX)
> #include <sys/stat.h>
> #else
> struct statx {
> /* 0x00 */
> uint32_t stx_mask;
> uint32_t stx_blksize;
> uint64_t stx_attributes;
> /* 0x10 */
> uint32_t stx_nlink;
> uint32_t stx_uid;
> uint32_t stx_gid;
> uint16_t stx_mode;
> uint16_t __spare0[1];
> /* 0x20 */
> uint64_t stx_ino;
> uint64_t stx_size;
> uint64_t stx_blocks;
> uint64_t stx_attributes_mask;
> /* 0x40 */
> const struct statx_timestamp stx_atime;
> const struct statx_timestamp stx_btime;
> const struct statx_timestamp stx_ctime;
> const struct statx_timestamp stx_mtime;
> /* 0x80 */
> uint32_t stx_rdev_major;
> uint32_t stx_rdev_minor;
> uint32_t stx_dev_major;
> uint32_t stx_dev_minor;
> /* 0x90 */
> uint64_t __spare2[14];
> /* 0x100 */
> };
> #endif
>
> the ltp definition only can be used when <sys/stat.h> miss statx struct
> instead of statx struct member. It seems we don't have a better idea.
> Or do you have some idea?
>
> It seems we think this question more complex, if system header miss,
> then use ltp definition, then we can not figure out whether fail or we
> just on old kernel. Except we add a mininl kernel check in the beginning.
>
As I said, if the system headers are missing the needed fields, then LTP should
use its in-tree definition. I.e., the in-tree definition should only be used if
HAVE_STRUCT_STATX && HAVE_STRUCT_STATX_STX_MNT_ID && [all other tested fields].
> >> + SAFE_FILE_PRINTF(TESTFILE, "AAAA");
> >> + fd = open(TESTFILE, O_RDWR | O_DIRECT);
> >> + if (fd == -1 && errno == EINVAL) {
> >> + SAFE_CLOSE(fd);
> >> + tst_brk(TCONF, "The regular file is not on a filesystem that support DIO");
> >> + }
> >> + SAFE_CLOSE(fd);
> >
> > The open() is not checked for error in all cases.
>
> how about the following code:
>
>
> fd = open(TESTFILE, O_RDWR | O_DIRECT);
> if (fd == -1) {
> if (errno == EINVAL)
> tst_brk(TCONF, "The regular file is not on a filesystem that support
> DIO");
> else
> tst_brk(TBROK | TERRNO, "The regular file was open with O_RDWR |
> O_DIRECT failed");
> }
> SAFE_CLOSE(fd);
I think that's okay.
- Eric
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-05-01 17:45 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 8:22 [LTP] [PATCH 1/3] lapi/stat.h: Add STATX_DIOALIGN related definition Yang Xu
2023-03-30 8:22 ` [LTP] [PATCH 2/3] syscalls/statx10: Add basic test for STATX_DIOALIGN Yang Xu
2023-03-30 16:46 ` Eric Biggers
2023-03-31 12:56 ` xuyang2018.jy
2023-03-31 19:29 ` Eric Biggers
2023-04-03 1:24 ` xuyang2018.jy
2023-04-03 3:06 ` Eric Biggers
2023-04-03 10:44 ` [LTP] [PATCH v2 1/4] lapi/stat.h: Add STATX_DIOALIGN related definition Yang Xu
2023-04-03 10:44 ` [LTP] [PATCH v2 2/4] syscalls/statx10: Add basic test for STATX_DIOALIGN on regular file Yang Xu
2023-04-03 17:01 ` Eric Biggers
2023-04-04 3:10 ` xuyang2018.jy
2023-04-04 5:46 ` xuyang2018.jy
2023-04-03 10:44 ` [LTP] [PATCH v2 3/4] syscalls/statx11: Add basic test for STATX_DIOALIGN on blockdev Yang Xu
2023-04-03 17:04 ` Eric Biggers
2023-04-04 3:14 ` xuyang2018.jy
2023-04-04 7:30 ` [LTP] [PATCH v3 1/4] lapi/stat.h: Add STATX_DIOALIGN related definition Yang Xu
2023-04-04 7:30 ` [LTP] [PATCH v3 2/4] syscalls/statx10: Add basic test for STATX_DIOALIGN on regular file Yang Xu
2023-04-04 21:52 ` Eric Biggers
2023-04-06 4:52 ` xuyang2018.jy
2023-04-04 7:30 ` [LTP] [PATCH v3 3/4] syscalls/statx11: Add basic test for STATX_DIOALIGN on block device Yang Xu
2023-04-04 21:59 ` Eric Biggers
2023-04-06 4:57 ` xuyang2018.jy
2023-04-06 5:36 ` xuyang2018.jy
2023-04-06 5:40 ` [LTP] [PATCH v4 1/4] lapi/stat.h: Add STATX_DIOALIGN related definition Yang Xu
2023-04-06 5:40 ` [LTP] [PATCH v4 2/4] syscalls/statx10: Add basic test for STATX_DIOALIGN on regular file Yang Xu
2023-04-26 22:06 ` Eric Biggers
2023-04-27 3:03 ` Yang Xu (Fujitsu)
2023-05-01 17:44 ` Eric Biggers [this message]
2023-05-01 17:47 ` Eric Biggers
2023-05-08 8:25 ` Yang Xu (Fujitsu)
2023-05-08 8:30 ` Yang Xu (Fujitsu)
2023-04-06 5:40 ` [LTP] [PATCH v4 3/4] syscalls/statx11: Add basic test for STATX_DIOALIGN on block device Yang Xu
2023-04-26 22:12 ` Eric Biggers
2023-04-27 3:37 ` Yang Xu (Fujitsu)
2023-04-27 3:50 ` Yang Xu (Fujitsu)
2023-05-01 17:49 ` Eric Biggers
2023-05-08 8:26 ` Yang Xu (Fujitsu)
2023-04-06 5:40 ` [LTP] [PATCH v4 4/4] lapi/stat.h: Remove deprecated STATX_ALL macro Yang Xu
2023-04-26 21:56 ` Eric Biggers
2023-04-27 1:52 ` Yang Xu (Fujitsu)
2023-04-26 9:57 ` [LTP] [PATCH v4 1/4] lapi/stat.h: Add STATX_DIOALIGN related definition Yang Xu (Fujitsu)
2023-04-26 21:56 ` Eric Biggers
2023-04-27 1:36 ` Yang Xu (Fujitsu)
2023-04-04 7:30 ` [LTP] [PATCH v3 4/4] lapi/stat.h: Remove deprecated STATX_ALL macro Yang Xu
2023-04-03 10:44 ` [LTP] [PATCH v2 " Yang Xu
2023-03-30 8:22 ` [LTP] [PATCH 3/3] " Yang Xu
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=20230501174442.GA1224@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=ltp@lists.linux.it \
--cc=xuyang2018.jy@fujitsu.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.