diff mbox series

[2/2] dio_writeback_race: align the directio buffer to base page size

Message ID 173992586646.4077946.4152131666050168978.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/2] dio-writeback-race: fix missing mode in O_CREAT | expand

Commit Message

Darrick J. Wong Feb. 19, 2025, 12:49 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

There's no need to align the memory buffer for the direcio write to the
file allocation unit size; base page size will do.  This fixes the
following error when generic/761 is run against an XFS rt filesystem
with a 28k rtextsize:

 QA output created by 761
+failed to allocate aligned memory
+cat: /opt/foobar: No such file or directory
 Silence is golden

Cc: <fstests@vger.kernel.org> # v2025.02.16
Fixes: 17fb49493426ad ("fstests: add a generic test to verify direct IO writes with buffer contents change")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 src/dio-writeback-race.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Feb. 19, 2025, 5:51 a.m. UTC | #1
On Tue, Feb 18, 2025 at 04:49:31PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> There's no need to align the memory buffer for the direcio write to the
> file allocation unit size; base page size will do.  This fixes the
> following error when generic/761 is run against an XFS rt filesystem
> with a 28k rtextsize:

Note that in theory even just the memory alignment reported by
statx / XFS_IOC_DIOINFO is enough, but I don't see how reducing the
alignment futher would benefit us much here.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong Feb. 19, 2025, 5:55 a.m. UTC | #2
On Tue, Feb 18, 2025 at 09:51:06PM -0800, Christoph Hellwig wrote:
> On Tue, Feb 18, 2025 at 04:49:31PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > There's no need to align the memory buffer for the direcio write to the
> > file allocation unit size; base page size will do.  This fixes the
> > following error when generic/761 is run against an XFS rt filesystem
> > with a 28k rtextsize:
> 
> Note that in theory even just the memory alignment reported by
> statx / XFS_IOC_DIOINFO is enough, but I don't see how reducing the
> alignment futher would benefit us much here.

<nod> I guess its a bit fragile if there's hardware out there that
can't handle 4k alignment, but those probably don't live long on the
market.

> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!

--D
diff mbox series

Patch

diff --git a/src/dio-writeback-race.c b/src/dio-writeback-race.c
index 2d3156e5b0974a..cca7d0e3b94cc9 100644
--- a/src/dio-writeback-race.c
+++ b/src/dio-writeback-race.c
@@ -102,7 +102,7 @@  int main (int argc, char *argv[])
 		fprintf(stderr, "missing argument\n");
 		goto error;
 	}
-	ret = posix_memalign(&buf, blocksize, blocksize);
+	ret = posix_memalign(&buf, sysconf(_SC_PAGESIZE), blocksize);
 	if (!buf) {
 		fprintf(stderr, "failed to allocate aligned memory\n");
 		exit(EXIT_FAILURE);