FS/XFS testing framework
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: fstests@vger.kernel.org, "Darrick J. Wong" <djwong@kernel.org>
Subject: Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment
Date: Tue, 15 Sep 2026 01:43:10 +0800	[thread overview]
Message-ID: <aqgx_usAw1NOtjm1@zlang-mailbox> (raw)
In-Reply-To: <20260914114550.2451308-3-hch@lst.de>

On Mon, Sep 14, 2026 at 01:45:44PM +0200, Christoph Hellwig wrote:
> Add an option to query the STATX_DIO_READ_ALIGN if provided.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> ---

Thanks Christoph, this version is good to me:)

Reviewed-by: Zorro Lang <zlang@kernel.org>

>  src/min_dio_alignment.c | 45 +++++++++++++++++++++++++++++++----------
>  1 file changed, 34 insertions(+), 11 deletions(-)
> 
> diff --git a/src/min_dio_alignment.c b/src/min_dio_alignment.c
> index 866fba1546c4..a557ce93a5d6 100644
> --- a/src/min_dio_alignment.c
> +++ b/src/min_dio_alignment.c
> @@ -1,17 +1,19 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (c) 2024 Christoph Hellwig
> + * Copyright (c) 2024,2026 Christoph Hellwig
>   */
>  #include <fcntl.h>
> +#include <stdbool.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> +#include <getopt.h>
>  #include <sys/mount.h>
>  #include <sys/ioctl.h>
>  #include <sys/stat.h>
>  #include "statx.h"
>  
> -static int min_dio_alignment(const char *mntpnt, const char *devname)
> +static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
>  {
>  	struct statx stx = { };
>  	struct stat st;
> @@ -27,9 +29,17 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
>  	 */
>  	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
>  	if (fd >= 0 &&
> -	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
> -	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
> -		return stx.stx_dio_offset_align;
> +	    xfstests_statx(fd, "", AT_EMPTY_PATH,
> +			STATX_DIOALIGN | STATX_DIO_READ_ALIGN, &stx) == 0) {
> +		if (read &&
> +		    (stx.stx_mask & STATX_DIO_READ_ALIGN) &&
> +		    stx.stx_dio_read_offset_align != 0)
> +			return stx.stx_dio_read_offset_align;
> +
> +		if ((stx.stx_mask & STATX_DIOALIGN) &&
> +		    stx.stx_dio_offset_align != 0)
> +			return stx.stx_dio_offset_align;
> +	}
>  
>  	/*
>  	 * If we are on a block device and no explicit aligned is reported, use
> @@ -42,9 +52,8 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
>  		if (dev_fd > 0 &&
>  		    fstat(dev_fd, &st) == 0 &&
>  		    S_ISBLK(st.st_mode) &&
> -		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0) {
> +		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0)
>  			return logical_block_size;
> -		}
>  	}
>  
>  	/*
> @@ -56,11 +65,25 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
>  
>  int main(int argc, char **argv)
>  {
> -	if (argc != 3) {
> -		fprintf(stderr, "usage: %s mountpoint devicename\n", argv[0]);
> -		exit(1);
> +	bool read = false;
> +	int c;
> +
> +	while ((c = getopt(argc, argv, "r")) != -1) {
> +		switch(c) {
> +		case 'r':
> +			read = 1;
> +			break;
> +		default:
> +			goto usage;
> +		}
>  	}
>  
> -	printf("%d\n", min_dio_alignment(argv[1], argv[2]));
> +	if (argc - optind != 2)
> +		goto usage;
> +
> +	printf("%d\n", min_dio_alignment(argv[optind], argv[optind + 1], read));
>  	exit(0);
> +usage:
> +	fprintf(stderr, "usage: %s [-r] mountpoint devicename\n", argv[0]);
> +	exit(1);
>  }
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-09-14 17:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 11:45 actually exercise sub-block direct I/O reads v2 Christoph Hellwig
2026-09-14 11:45 ` [PATCH 1/5] statx.h: update to latest kernel UAPI Christoph Hellwig
2026-09-14 14:35   ` Darrick J. Wong
2026-09-14 17:43     ` Zorro Lang
2026-09-14 11:45 ` [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment Christoph Hellwig
2026-09-14 17:43   ` Zorro Lang [this message]
2026-09-14 11:45 ` [PATCH 3/5] generic/091: enable sub-block reads Christoph Hellwig
2026-09-14 11:45 ` [PATCH 4/5] generic/263: " Christoph Hellwig
2026-09-14 11:45 ` [PATCH 5/5] generic/760: " Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2026-08-31  6:51 actually exercise sub-block direct I/O reads Christoph Hellwig
2026-08-31  6:51 ` [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment Christoph Hellwig
2026-08-31 17:16   ` Darrick J. Wong
2026-09-02 16:26   ` Zorro Lang
2026-09-03  5:34     ` Christoph Hellwig
2026-09-03 13:39       ` Zorro Lang
2026-09-14  9:44         ` Zorro Lang
2026-09-14 11:44           ` Christoph Hellwig
2026-09-02 16:31   ` Zorro Lang

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=aqgx_usAw1NOtjm1@zlang-mailbox \
    --to=zlang@kernel.org \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    /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