FS/XFS testing framework
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: fstests@vger.kernel.org, Chao Yu <chao@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH] src/min_dio_alignment: don't return invalid dio_offset_align
Date: Wed, 11 Sep 2024 11:53:33 +0800	[thread overview]
Message-ID: <20240911035333.364961-1-chao@kernel.org> (raw)

If returned parameters of statx() are: a)STATX_DIOALIGN is set in
stx_mask, b)stx.stx_dio_offset_align is zero, it indicates filesystem
supports DIO, but the file doesn't.

It needs to avoid returning zeroed stx.stx_dio_offset_align value,
instead, we can fallthrough to get alignment size of block device or
page size, otherwise, it may cause potential deadloop, e.g.
generic/465:

align=stx_dio_offset_align(it equals to zero)
page_size=4096
while [ $align -le $page_size ]; do
    echo "$AIO_TEST -a $align -d $testfile.$align" >> $seqres.full
    $AIO_TEST -a $align -d $testfile.$align 2>&1 | tee -a $seqres.full
    align=$((align * 2))
done

Cc: Christoph Hellwig <hch@lst.de>
Cc: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
 src/min_dio_alignment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/min_dio_alignment.c b/src/min_dio_alignment.c
index 131f6023..c1d7112d 100644
--- a/src/min_dio_alignment.c
+++ b/src/min_dio_alignment.c
@@ -28,7 +28,7 @@ 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_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
 		return stx.stx_dio_offset_align;
 
 	/*
-- 
2.40.1


             reply	other threads:[~2024-09-11  3:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11  3:53 Chao Yu [this message]
2024-09-11  7:46 ` [PATCH] src/min_dio_alignment: don't return invalid dio_offset_align Christoph Hellwig
2024-09-11 10:10   ` Chao Yu

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=20240911035333.364961-1-chao@kernel.org \
    --to=chao@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=zlang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox