From patchwork Wed May 19 23:56:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, LOTS_OF_MONEY,MAILING_LIST_MULTI,MONEY_NOHTML,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2436C433ED for ; Wed, 19 May 2021 23:56:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A44CA611BD for ; Wed, 19 May 2021 23:56:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbhESX6I (ORCPT ); Wed, 19 May 2021 19:58:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:48476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhESX6H (ORCPT ); Wed, 19 May 2021 19:58:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3FA7F600CC; Wed, 19 May 2021 23:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468607; bh=dDXU+ropiBVVQdNWsOUKAj7y/QA1F1r4t5Me4FlrA8A=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=KQBdmL4kGlJ26tVY25OYlqmbHfm3+L95Jz0wdcw9GVVLqeRNs5d6xnYuxvD8S0S+2 /yxaja4eqK0tgtVwHzBmsUTtyaRWgNu3lKDFSsfPHCInwNqDX26WHnncxe1eShO55H yDBXzmwpuiE9QvPd2IGGvGsOgAai/XfCArCfPGDThe6C0V8lCIdvdODcSfhmJBFnWN b/uKe73P2PDywfiM12QVmkLM+lei5LvtMP0EOYUDlnYHszAO4ewu8PXDYKre+Skp/y XrKsiiMsHHbopkzMP1wJzE0P1XIWWAMHDpEq0APdfNzKuRaAFfAIPIM0vql3vY6Ai/ KfkGU8lsvzQFQ== Subject: [PATCH 1/6] common/xfs: refactor commands to select a particular xfs backing device From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:56:46 -0700 Message-ID: <162146860674.2500122.8733670522999610459.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong Refactor all the places where we try to force new file data allocations to a specific xfs backing device so that we don't end up open-coding the same xfs_io command lines over and over. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- common/populate | 2 +- common/xfs | 25 +++++++++++++++++++++++++ tests/generic/223 | 3 ++- tests/generic/449 | 2 +- tests/xfs/004 | 2 +- tests/xfs/146 | 2 +- tests/xfs/147 | 2 +- tests/xfs/272 | 2 +- tests/xfs/318 | 2 +- tests/xfs/431 | 4 ++-- tests/xfs/521 | 2 +- tests/xfs/528 | 2 +- tests/xfs/532 | 2 +- tests/xfs/533 | 2 +- tests/xfs/538 | 2 +- 15 files changed, 41 insertions(+), 15 deletions(-) diff --git a/common/populate b/common/populate index d484866a..867776cd 100644 --- a/common/populate +++ b/common/populate @@ -162,7 +162,7 @@ _scratch_xfs_populate() { # Clear the rtinherit flag on the root directory so that files are # always created on the data volume regardless of MKFS_OPTIONS. We can # set the realtime flag when needed. - $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT + _xfs_force_bdev data $SCRATCH_MNT blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" dblksz="$($XFS_INFO_PROG "${SCRATCH_MNT}" | grep naming.*bsize | sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g')" diff --git a/common/xfs b/common/xfs index 725819bd..d7f2a005 100644 --- a/common/xfs +++ b/common/xfs @@ -194,6 +194,31 @@ _xfs_get_file_block_size() $XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g' } +# Set or clear the realtime status of every supplied path. The first argument +# is either 'data' or 'realtime'. All other arguments should be paths to +# existing directories or empty regular files. +# +# For each directory, each file subsequently created will target the given +# device for file data allocations. For each empty regular file, each +# subsequent file data allocation will be on the given device. +_xfs_force_bdev() +{ + local device="$1" + shift + local chattr_arg="" + + case "$device" in + "data") chattr_arg="-t";; + "realtime") chattr_arg="+t";; + *) + echo "${device}: Don't know what device this is?" + return 1 + ;; + esac + + $XFS_IO_PROG -c "chattr $chattr_arg" "$@" +} + _xfs_get_fsxattr() { local field="$1" diff --git a/tests/generic/223 b/tests/generic/223 index f6393293..078fd725 100755 --- a/tests/generic/223 +++ b/tests/generic/223 @@ -46,7 +46,8 @@ for SUNIT_K in 8 16 32 64 128; do # This test checks for stripe alignments of space allocations on the # filesystem. Make sure all files get created on the main device, # which for XFS means no rt files. - test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT + test "$FSTYP" = "xfs" && \ + _xfs_force_bdev data $SCRATCH_MNT for SIZE_MULT in 1 2 8 64 256; do let SIZE=$SIZE_MULT*$SUNIT_BYTES diff --git a/tests/generic/449 b/tests/generic/449 index 5fd15367..2a5065f6 100755 --- a/tests/generic/449 +++ b/tests/generic/449 @@ -46,7 +46,7 @@ _scratch_mount || _fail "mount failed" # This is a test of xattr behavior when we run out of disk space for xattrs, # so make sure the pwrite goes to the data device and not the rt volume. test "$FSTYP" = "xfs" && \ - $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT + _xfs_force_bdev data $SCRATCH_MNT TFILE=$SCRATCH_MNT/testfile.$seq diff --git a/tests/xfs/004 b/tests/xfs/004 index 7633071c..d3fb9c95 100755 --- a/tests/xfs/004 +++ b/tests/xfs/004 @@ -31,7 +31,7 @@ _populate_scratch() # This test looks at specific behaviors of the xfs_db freesp command, # which reports on the contents of the free space btrees for the data # device. Don't let anything get created on the realtime volume. - $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT + _xfs_force_bdev data $SCRATCH_MNT dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 & dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 & dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 & diff --git a/tests/xfs/146 b/tests/xfs/146 index 8f85024d..49020e01 100755 --- a/tests/xfs/146 +++ b/tests/xfs/146 @@ -78,7 +78,7 @@ _scratch_mkfs -r size=$rtsize >> $seqres.full _scratch_mount >> $seqres.full # Make sure the root directory has rtinherit set so our test file will too -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT +_xfs_force_bdev realtime $SCRATCH_MNT # Allocate some stuff at the start, to force the first falloc of the ouch file # to happen somewhere in the middle of the rt volume diff --git a/tests/xfs/147 b/tests/xfs/147 index da962f96..5cc363aa 100755 --- a/tests/xfs/147 +++ b/tests/xfs/147 @@ -50,7 +50,7 @@ rextblks=$((rextsize / blksz)) echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full # Make sure the root directory has rtinherit set so our test file will too -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT +_xfs_force_bdev realtime $SCRATCH_MNT sz=$((rextsize * 100)) range="$((blksz * 3)) $blksz" diff --git a/tests/xfs/272 b/tests/xfs/272 index 6c0fede5..6a1372b8 100755 --- a/tests/xfs/272 +++ b/tests/xfs/272 @@ -38,7 +38,7 @@ _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount # Make sure everything is on the data device -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT +_xfs_force_bdev data $SCRATCH_MNT _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full sync diff --git a/tests/xfs/318 b/tests/xfs/318 index 07375b1f..07b4f7f1 100755 --- a/tests/xfs/318 +++ b/tests/xfs/318 @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full # This test depends on specific behaviors of the data device, so create all # files on it. -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT +_xfs_force_bdev data $SCRATCH_MNT echo "Create files" touch $SCRATCH_MNT/file1 diff --git a/tests/xfs/431 b/tests/xfs/431 index e67906dc..797b8fcd 100755 --- a/tests/xfs/431 +++ b/tests/xfs/431 @@ -47,7 +47,7 @@ _scratch_mount # Set realtime inherit flag on scratch mount, suppress output # as this may simply error out on future kernels -$XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT &> /dev/null +_xfs_force_bdev realtime $SCRATCH_MNT &> /dev/null # Check if 't' is actually set, as xfs_io returns 0 even when it fails to set # an attribute. And erroring out here is fine, this would be desired behavior @@ -60,7 +60,7 @@ if $XFS_IO_PROG -c 'lsattr' $SCRATCH_MNT | grep -q 't'; then # Remove the testfile and rt inherit flag after we are done or # xfs_repair will fail. rm -f $SCRATCH_MNT/testfile - $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT | tee -a $seqres.full 2>&1 + _xfs_force_bdev data $SCRATCH_MNT | tee -a $seqres.full 2>&1 fi # success, all done diff --git a/tests/xfs/521 b/tests/xfs/521 index b8026d45..99408a06 100755 --- a/tests/xfs/521 +++ b/tests/xfs/521 @@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir echo "Check rt volume stats" -$XFS_IO_PROG -c 'chattr +t' $testdir +_xfs_force_bdev realtime $testdir $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full before=$(stat -f -c '%b' $testdir) diff --git a/tests/xfs/528 b/tests/xfs/528 index 7f98c5b8..d483ae82 100755 --- a/tests/xfs/528 +++ b/tests/xfs/528 @@ -77,7 +77,7 @@ test_ops() { _notrun "Could not mount rextsize=$rextsize with synthetic rt volume" # Force all files to be realtime files - $XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT + _xfs_force_bdev realtime $SCRATCH_MNT log "Test regular write, rextsize=$rextsize" mk_file $SCRATCH_MNT/write $rextsize diff --git a/tests/xfs/532 b/tests/xfs/532 index 560af586..f421070a 100755 --- a/tests/xfs/532 +++ b/tests/xfs/532 @@ -47,7 +47,7 @@ _scratch_mount >> $seqres.full # Disable realtime inherit flag (if any) on root directory so that space on data # device gets fragmented rather than realtime device. -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT +_xfs_force_bdev data $SCRATCH_MNT bsize=$(_get_block_size $SCRATCH_MNT) diff --git a/tests/xfs/533 b/tests/xfs/533 index dd4cb4c4..1c8cc925 100755 --- a/tests/xfs/533 +++ b/tests/xfs/533 @@ -58,7 +58,7 @@ _scratch_mount >> $seqres.full # Disable realtime inherit flag (if any) on root directory so that space on data # device gets fragmented rather than realtime device. -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT +_xfs_force_bdev data $SCRATCH_MNT echo "Consume free space" fillerdir=$SCRATCH_MNT/fillerdir diff --git a/tests/xfs/538 b/tests/xfs/538 index 97273b88..dc0e5f28 100755 --- a/tests/xfs/538 +++ b/tests/xfs/538 @@ -44,7 +44,7 @@ _scratch_mount >> $seqres.full # Disable realtime inherit flag (if any) on root directory so that space on data # device gets fragmented rather than realtime device. -$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT +_xfs_force_bdev data $SCRATCH_MNT bsize=$(_get_file_block_size $SCRATCH_MNT) From patchwork Wed May 19 23:56:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B208BC433B4 for ; Wed, 19 May 2021 23:56:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97540600CC for ; Wed, 19 May 2021 23:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbhESX6O (ORCPT ); Wed, 19 May 2021 19:58:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhESX6N (ORCPT ); Wed, 19 May 2021 19:58:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C5ED61007; Wed, 19 May 2021 23:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468613; bh=Jilndsq459/6kZq4Q3+F1Dh6m7zGawEGLy3rxXGfD9Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kHok4PUFeAKTy3nLH4EQWeMOC2RDnxVDdceZ+wF1FM0seT7AcfG+WzdCLXywGU3yo IAtwnbBDyprcYvIsJjXMxsYMxj8Mzr7nR6rtEK64sfZ0SIxPWRCc9JExgfmBf9QgFB 5rvuADDD25XKmPkR33Ez82fMPaA3tcScArhLV0Y8HZTbIYKYqbfcLB1RvghUhnuoR2 H1oV1pSTNyuad6U+KEXP3pR6FrRNuUdlf6d7QMulgaa6Rw7Lwy6fi0MEKNFvLORimB 4o0XPsZGDUx1ynqwBX02USk9VxBchKuXsqSzx41c2scKbYWEXfJpYVVEU7Ovve4ugS 3AoIOWgkaZmLA== Subject: [PATCH 2/6] xfs: force file creation to the data device for certain layout tests From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:56:52 -0700 Message-ID: <162146861270.2500122.8499973348974838405.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong I found a bunch more tests in the xfs/ directory that try to create specific metadata layouts on the data device, either because they're fuzz tests or because they're testing specific edge cases of the code base. Either way, these test need to override '-d rtinherit' in the MKFS_OPTIONS, so do that with _xfs_force_bdev. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- tests/xfs/088 | 1 + tests/xfs/089 | 1 + tests/xfs/091 | 1 + tests/xfs/120 | 1 + tests/xfs/130 | 1 + tests/xfs/139 | 2 ++ tests/xfs/207 | 1 + tests/xfs/229 | 1 + tests/xfs/235 | 1 + 9 files changed, 10 insertions(+) diff --git a/tests/xfs/088 b/tests/xfs/088 index 6c5cbec8..b3e65dcf 100755 --- a/tests/xfs/088 +++ b/tests/xfs/088 @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null echo "+ mount fs image" _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" mkdir -p "${TESTDIR}" diff --git a/tests/xfs/089 b/tests/xfs/089 index 2892ad9e..21380798 100755 --- a/tests/xfs/089 +++ b/tests/xfs/089 @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null echo "+ mount fs image" _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" mkdir -p "${TESTDIR}" diff --git a/tests/xfs/091 b/tests/xfs/091 index 04322cec..ff8f0f1f 100755 --- a/tests/xfs/091 +++ b/tests/xfs/091 @@ -48,6 +48,7 @@ _scratch_mkfs_xfs > /dev/null echo "+ mount fs image" _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" mkdir -p "${TESTDIR}" diff --git a/tests/xfs/120 b/tests/xfs/120 index e66bc763..f5eb14cc 100755 --- a/tests/xfs/120 +++ b/tests/xfs/120 @@ -47,6 +47,7 @@ echo "+ mount fs image" _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" nr="$((blksz * 2 / 16))" +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * nr))" -c 'fsync' "${SCRATCH_MNT}/bigfile" >> $seqres.full diff --git a/tests/xfs/130 b/tests/xfs/130 index 3071eace..6f6e8512 100755 --- a/tests/xfs/130 +++ b/tests/xfs/130 @@ -43,6 +43,7 @@ echo "+ mount fs image" _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" agcount="$(_xfs_mount_agcount $SCRATCH_MNT)" +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" _pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full" diff --git a/tests/xfs/139 b/tests/xfs/139 index 1444444d..58b71711 100755 --- a/tests/xfs/139 +++ b/tests/xfs/139 @@ -38,12 +38,14 @@ rm -f $seqres.full _scratch_mkfs >/dev/null 2>&1 _scratch_mount +_xfs_force_bdev data $SCRATCH_MNT blksz=$(_get_file_block_size $SCRATCH_MNT) _scratch_unmount echo "Format and mount" _scratch_mkfs -d agsize=$((16384 * $blksz)) > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 +_xfs_force_bdev data $SCRATCH_MNT testdir=$SCRATCH_MNT/test-$seq mkdir $testdir diff --git a/tests/xfs/207 b/tests/xfs/207 index f703c0dc..f0f30754 100755 --- a/tests/xfs/207 +++ b/tests/xfs/207 @@ -50,6 +50,7 @@ rm -f $seqres.full echo "Format and mount" _scratch_mkfs > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 +_xfs_force_bdev data $SCRATCH_MNT testdir=$SCRATCH_MNT/test-$seq mkdir $testdir diff --git a/tests/xfs/229 b/tests/xfs/229 index e723b10b..64851557 100755 --- a/tests/xfs/229 +++ b/tests/xfs/229 @@ -38,6 +38,7 @@ _require_fs_space $TEST_DIR 3200000 TDIR="${TEST_DIR}/t_holes" NFILES="10" EXTSIZE="256k" +_xfs_force_bdev data $TEST_DIR # Create the test directory mkdir ${TDIR} diff --git a/tests/xfs/235 b/tests/xfs/235 index a2ab9e55..55f5c5a6 100755 --- a/tests/xfs/235 +++ b/tests/xfs/235 @@ -41,6 +41,7 @@ echo "+ mount fs image" _scratch_mount blksz=$(stat -f -c '%s' ${SCRATCH_MNT}) agcount=$(_xfs_mount_agcount $SCRATCH_MNT) +_xfs_force_bdev data $SCRATCH_MNT echo "+ make some files" _pwrite_byte 0x62 0 $((blksz * 64)) ${SCRATCH_MNT}/file0 >> $seqres.full From patchwork Wed May 19 23:56:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B60BC433B4 for ; Wed, 19 May 2021 23:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C496610A1 for ; Wed, 19 May 2021 23:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbhESX6U (ORCPT ); Wed, 19 May 2021 19:58:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:48548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbhESX6T (ORCPT ); Wed, 19 May 2021 19:58:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4672D61007; Wed, 19 May 2021 23:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468619; bh=Yu+eAjhxeMKVLsBYZVl6EusGwPVpt+1jAIWovF6dlvQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QIwvHApgjGpNXR1fA81V9mKsCZYx+ShfjDWTEbpyVFel8WX+8ukQKyrQ9bis2HcvU VpwPMmcj+FEfih9zxbhw/7G3Qb/hNO/mapL3T6YnzVtdiXia6L0hpJqlQr2qsG7RpK AMI4ukjKnOqje7tIJ6jn5nAhrsYYz/7z8MVjhL9Aq6LvYHsEsTjrXN9peqkprgutSN UJjG60g0owSmjE+MvgghpMoy++OeGxvlVQHm3zx0PGpgRdKsBJysZVP37bYPW3Bf8c bQ6e0/dSwO3XpEhjkBUDxXTb6ReUstVKRrtL56DihG9JCpJvWLi5p14UvLCzHT+T/E ppOBWGQEU66zQ== Subject: [PATCH 3/6] xfs/117: fix fragility in this fuzz test From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:56:58 -0700 Message-ID: <162146861868.2500122.10790450415786633712.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong This fuzz test has some fragility problems -- it doesn't do anything to guarantee that the inodes that it checks for EFSCORRUPTED are the same ones that it fuzzed, and it doesn't explicitly try to avoid victimizing inodes in the same chunk as the root directory. As a result, this test fails annoyingly frequently. Fix both of these problems and get rid of the confusingly named TESTDIR variable. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- tests/xfs/117 | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tests/xfs/117 b/tests/xfs/117 index d3f4675f..32be525f 100755 --- a/tests/xfs/117 +++ b/tests/xfs/117 @@ -39,8 +39,7 @@ _require_xfs_db_blocktrash_z_command test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3" rm -f $seqres.full -TESTDIR="${SCRATCH_MNT}/scratchdir" -TESTFILE="${TESTDIR}/testfile" +victimdir="${SCRATCH_MNT}/scratchdir" echo "+ create scratch fs" _scratch_mkfs_xfs > /dev/null @@ -50,37 +49,49 @@ _scratch_mount blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" echo "+ make some files" -mkdir -p "${TESTDIR}" -for x in `seq 1 1024`; do - touch "${SCRATCH_MNT}/junk.${x}" - inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")" - if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then - mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1" - break - fi +mkdir -p "$victimdir" + +rootdir="$(stat -c '%i' "$SCRATCH_MNT")" +rootchunk=$(( rootdir / 64 )) + +# First we create some dummy file so that the victim files don't get created +# in the same inode chunk as the root directory, because a corrupt inode in +# the root chunk causes mount to fail. +for ((i = 0; i < 256; i++)); do + fname="$SCRATCH_MNT/dummy.$i" + touch "$fname" + ino="$(stat -c '%i' "$fname")" + ichunk=$(( ino / 64 )) + test "$ichunk" -gt "$rootchunk" && break done -for x in `seq 2 64`; do - touch "${TESTFILE}.${x}" + +# Now create some victim files +inos=() +for ((i = 0; i < 64; i++)); do + fname="$victimdir/test.$i" + touch "$fname" + inos+=("$(stat -c '%i' "$fname")") done -inode="$(stat -c '%i' "${TESTFILE}.1")" +echo "First victim inode is: " >> $seqres.full +stat -c '%i' "$fname" >> $seqres.full umount "${SCRATCH_MNT}" echo "+ check fs" _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail" echo "+ corrupt image" -seq "${inode}" "$((inode + 63))" | while read ino; do +for ino in "${inos[@]}"; do _scratch_xfs_db -x -c "inode ${ino}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1 done echo "+ mount image && modify files" broken=1 if _try_scratch_mount >> $seqres.full 2>&1; then - - for x in `seq 1 64`; do - stat "${TESTFILE}.${x}" >> $seqres.full 2>&1 + for ((i = 0; i < 64; i++)); do + fname="$victimdir/test.$i" + stat "$fname" &>> $seqres.full test $? -eq 0 && broken=0 - touch "${TESTFILE}.${x}" >> $seqres.full 2>&1 + touch "$fname" &>> $seqres.full test $? -eq 0 && broken=0 done umount "${SCRATCH_MNT}" From patchwork Wed May 19 23:57:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FC36C433ED for ; Wed, 19 May 2021 23:57:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 312F6611BD for ; Wed, 19 May 2021 23:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbhESX60 (ORCPT ); Wed, 19 May 2021 19:58:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:48594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbhESX6Z (ORCPT ); Wed, 19 May 2021 19:58:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F24061007; Wed, 19 May 2021 23:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468625; bh=cFicwlFrt0V4AhGjbJ0/9P8jCG5wSmfLw8AAJyqqYPc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=hJCoyIgjWWwun6jX88uRGiD6gwxj6B1+hPGOzy4B9yvA4HPACZzy4vMHYj5gAyYgr BUGO+re/NRDh+Y90ij2lqRoF25n/T2I3F5fLOFYmyuh7QGF5MiGIN7bypw9XgIq4MR WYe2Izm1mQ8C3o/+Kx6Knr0vPEa/N9LvWoo1bqNIYTd8wPFXGa6S+HF3z4SGAtrK7n PaAjty5FP/EedejM40hSr9V3WFmyRfhku9y3a5re0FPzPys1CJ0k4oHqxH45fxveoM thhc4+cN4I8AXWxtXCCXBk7UKKGEzNQz7N148GWCVSyPne1muhJl9G3YhrlsD9iHv7 dMkV283dBQM6Q== Subject: [PATCH 4/6] fsx/fsstress: round blocksize properly From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:57:04 -0700 Message-ID: <162146862463.2500122.10829551919577698395.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong The block sizes reported by stat and DIOINFO aren't required to be powers of two. This can happen on an XFS filesystem with a realtime extent size that isn't a power of two; on such filesystems, certain IO calls will fail due to alignment issues. Fix that by providing rounding helpers that work for all sizes. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- ltp/fsstress.c | 24 ++++++++++++------------ ltp/fsx.c | 22 +++++++++++----------- src/global.h | 13 +++++++++++++ 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index e7cd0eae..b4ddf5e2 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -2140,7 +2140,7 @@ do_aio_rw(int opno, long r, int flags) " fallback to stat()\n", procid, opno, f.path, st, errno); diob.d_mem = diob.d_miniosz = stb.st_blksize; - diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1); + diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz); } dio_env = getenv("XFS_DIO_MIN"); if (dio_env) @@ -2608,7 +2608,7 @@ clonerange_f( /* Calculate offsets */ len = (random() % FILELEN_MAX) + 1; - len &= ~(stat1.st_blksize - 1); + len = rounddown_64(len, stat1.st_blksize); if (len == 0) len = stat1.st_blksize; if (len > stat1.st_size) @@ -2620,7 +2620,7 @@ clonerange_f( else off1 = (off64_t)(lr % MIN(stat1.st_size - len, MAXFSIZE)); off1 %= maxfsize; - off1 &= ~(stat1.st_blksize - 1); + off1 = rounddown_64(off1, stat1.st_blksize); /* * If srcfile == destfile, randomly generate destination ranges @@ -2631,7 +2631,7 @@ clonerange_f( lr = ((int64_t)random() << 32) + random(); off2 = (off64_t)(lr % max_off2); off2 %= maxfsize; - off2 &= ~(stat2.st_blksize - 1); + off2 = rounddown_64(off2, stat2.st_blksize); } while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len); /* Clone data blocks */ @@ -2968,7 +2968,7 @@ deduperange_f( /* Never try to dedupe more than half of the src file. */ len = (random() % FILELEN_MAX) + 1; - len &= ~(stat[0].st_blksize - 1); + len = rounddown_64(len, stat[0].st_blksize); if (len == 0) len = stat[0].st_blksize / 2; if (len > stat[0].st_size / 2) @@ -2981,7 +2981,7 @@ deduperange_f( else off[0] = (off64_t)(lr % MIN(stat[0].st_size - len, MAXFSIZE)); off[0] %= maxfsize; - off[0] &= ~(stat[0].st_blksize - 1); + off[0] = rounddown_64(off[0], stat[0].st_blksize); /* * If srcfile == destfile[i], randomly generate destination ranges @@ -2997,7 +2997,7 @@ deduperange_f( else off[i] = (off64_t)(lr % MIN(stat[i].st_size - len, MAXFSIZE)); off[i] %= maxfsize; - off[i] &= ~(stat[i].st_blksize - 1); + off[i] = rounddown_64(off[i], stat[i].st_blksize); } while (stat[0].st_ino == stat[i].st_ino && llabs(off[i] - off[0]) < len && tries++ < 10); @@ -3406,7 +3406,7 @@ dread_f(int opno, long r) " fallback to stat()\n", procid, opno, f.path, st, errno); diob.d_mem = diob.d_miniosz = stb.st_blksize; - diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1); + diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz); } dio_env = getenv("XFS_DIO_MIN"); @@ -3483,7 +3483,7 @@ dwrite_f(int opno, long r) " %s%s return %d, fallback to stat()\n", procid, opno, f.path, st, errno); diob.d_mem = diob.d_miniosz = stb.st_blksize; - diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1); + diob.d_maxiosz = rounddown_64(INT_MAX, diob.d_miniosz); } dio_env = getenv("XFS_DIO_MIN"); @@ -3579,8 +3579,8 @@ do_fallocate(int opno, long r, int mode) */ if ((mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)) && (opno % 2)) { - off = ((off + stb.st_blksize - 1) & ~(stb.st_blksize - 1)); - len = ((len + stb.st_blksize - 1) & ~(stb.st_blksize - 1)); + off = roundup_64(off, stb.st_blksize); + len = roundup_64(len, stb.st_blksize); } mode |= FALLOC_FL_KEEP_SIZE & random(); e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0; @@ -4186,7 +4186,7 @@ do_mmap(int opno, long r, int prot) lr = ((int64_t)random() << 32) + random(); off = (off64_t)(lr % stb.st_size); - off &= (off64_t)(~(sysconf(_SC_PAGE_SIZE) - 1)); + off = rounddown_64(off, sysconf(_SC_PAGE_SIZE)); len = (size_t)(random() % MIN(stb.st_size - off, FILELEN_MAX)) + 1; flags = (random() % 2) ? MAP_SHARED : MAP_PRIVATE; diff --git a/ltp/fsx.c b/ltp/fsx.c index d526d294..12c2cc33 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -203,7 +203,7 @@ static void *round_ptr_up(void *ptr, unsigned long align, unsigned long offset) { unsigned long ret = (unsigned long)ptr; - ret = ((ret + align - 1) & ~(align - 1)); + ret = roundup_64(ret, align); ret += offset; return (void *)ret; } @@ -1948,12 +1948,12 @@ static void generate_dest_range(bool bdy_align, TRIM_OFF_LEN(*src_offset, *size, file_size); if (bdy_align) { - *src_offset -= *src_offset % readbdy; + *src_offset = rounddown_64(*src_offset, readbdy); if (o_direct) - *size -= *size % readbdy; + *size = rounddown_64(*size, readbdy); } else { - *src_offset = *src_offset & ~(block_size - 1); - *size = *size & ~(block_size - 1); + *src_offset = rounddown_64(*src_offset, block_size); + *size = rounddown_64(*size, block_size); } do { @@ -1964,9 +1964,9 @@ static void generate_dest_range(bool bdy_align, *dst_offset = random(); TRIM_OFF(*dst_offset, max_range_end); if (bdy_align) - *dst_offset -= *dst_offset % writebdy; + *dst_offset = rounddown_64(*dst_offset, writebdy); else - *dst_offset = *dst_offset & ~(block_size - 1); + *dst_offset = rounddown_64(*dst_offset, block_size); } while (range_overlaps(*src_offset, *dst_offset, *size) || *dst_offset + *size > max_range_end); } @@ -2156,8 +2156,8 @@ test(void) break; case OP_COLLAPSE_RANGE: TRIM_OFF_LEN(offset, size, file_size - 1); - offset = offset & ~(block_size - 1); - size = size & ~(block_size - 1); + offset = rounddown_64(offset, block_size); + size = rounddown_64(size, block_size); if (size == 0) { log4(OP_COLLAPSE_RANGE, offset, size, FL_SKIPPED); goto out; @@ -2167,8 +2167,8 @@ test(void) case OP_INSERT_RANGE: TRIM_OFF(offset, file_size); TRIM_LEN(file_size, size, maxfilelen); - offset = offset & ~(block_size - 1); - size = size & ~(block_size - 1); + offset = rounddown_64(offset, block_size); + size = rounddown_64(size, block_size); if (size == 0) { log4(OP_INSERT_RANGE, offset, size, FL_SKIPPED); goto out; diff --git a/src/global.h b/src/global.h index e5e46234..b4407099 100644 --- a/src/global.h +++ b/src/global.h @@ -171,4 +171,17 @@ #include #endif +static inline unsigned long long +rounddown_64(unsigned long long x, unsigned int y) +{ + x /= y; + return x * y; +} + +static inline unsigned long long +roundup_64(unsigned long long x, unsigned int y) +{ + return rounddown_64(x + y - 1, y); +} + #endif /* GLOBAL_H */ From patchwork Wed May 19 23:57:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B28A4C433B4 for ; Wed, 19 May 2021 23:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 919B861007 for ; Wed, 19 May 2021 23:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbhESX6c (ORCPT ); Wed, 19 May 2021 19:58:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:48674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbhESX6b (ORCPT ); Wed, 19 May 2021 19:58:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 445A7600CC; Wed, 19 May 2021 23:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468631; bh=jtZ+BVQ1OTCwkIANLmYBRfwz4ehrvttO0CykMrsV1qY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=RYuCiF8uJRy/zmDbT7FoDKvsRRPVx/ZRcBjPj4yfgXgYmGzyrkejPmzVeo1VVyRCF bT6nentf/sHbHpFJAcHkLR1wsxOdpSMVVz+ASH4iJoxGwO02TcfIDjlp1bcOJnhcde p1MYaRkvDLr+0W7ymaUr4k10PMx4ommMLlnD3Ls9f+E2fAcVgXIJ+PXlmMdDYBTRWu 1y8UjrxZQqnGDYKyi43snfOS1iWoSRTRS9oBm+lAsoSAjYYvIZg7EZ1whhYS2yRCni YOEmsy6zBMlzsA3hMcw/iVgNrzOjNcGSh7SdD+lc32rEhi7RyQtLaiCm7VVvLHfpKf Ys8j710ANjRNQ== Subject: [PATCH 5/6] xfs/178: fix mkfs success test From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:57:10 -0700 Message-ID: <162146863062.2500122.10306270841818355198.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong Fix the obviously incorrect code here that wants to fail the test if mkfs doesn't succeed. The return value ("$?") is always the status of the /last/ command in the pipe. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- tests/xfs/178 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/xfs/178 b/tests/xfs/178 index a24ef50c..122d63d2 100755 --- a/tests/xfs/178 +++ b/tests/xfs/178 @@ -57,8 +57,8 @@ _supported_fs xfs # fix filesystem, new mkfs.xfs will be fine. _require_scratch -_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \ - || _fail "mkfs failed!" +_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs +test "${PIPESTATUS[0]}" -eq 0 || _fail "mkfs failed!" # By executing the followint tmp file, will get on the mkfs options stored in # variables From patchwork Wed May 19 23:57:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12268657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BE07C433B4 for ; Wed, 19 May 2021 23:57:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02514610A1 for ; Wed, 19 May 2021 23:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbhESX6i (ORCPT ); Wed, 19 May 2021 19:58:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:48718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbhESX6h (ORCPT ); Wed, 19 May 2021 19:58:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42AFB61007; Wed, 19 May 2021 23:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621468637; bh=IPZ/LFYkiDiAKITR3H2kj94cG/UOsADTmHjKuAxvEZs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=G1MRYRU2DJmF82njnvhzGiRLAfijw2CkaKnHDlHNvjSUwgTR7j8pxj8rRArgI6uh8 upk/krL0WmgjNjqqDlyo0Gfda7LrflBEJtXKm9gc8PFndOwnoMyder2v6aNOe+JCI9 1mp4pZhJmY3wjSOYoLGw36XkBpIXNEnTKeTvYOiXX0N1T4eLVi96Msxf2Boow3B5KS 6nwnBonPSKCuDOvYJxIDf6hzBJ/ecgw0uDQV5t50luUgCg/O41+uTigQK3MPRYkfzH vflNvSLw/6E508jXa8caRY2y1aZUwngsh6CK2xdyFXkpxiopf+r+WXWoU26wiNGwEa GNbjFojXUuScQ== Subject: [PATCH 6/6] aio-dio-append-write-fallocate-race: fix directio buffer alignment bugs From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Wed, 19 May 2021 16:57:16 -0700 Message-ID: <162146863667.2500122.9363433713420860828.stgit@magnolia> In-Reply-To: <162146860057.2500122.8732083536936062491.stgit@magnolia> References: <162146860057.2500122.8732083536936062491.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong This program fails on filesystems where the stat() block size isn't a strict power of two because it foolishly feeds that to posix_memalign to allocate an aligned memory buffer for directio. posix_memalign requires the alignment value to be a power of two, so generic/586 fails. The system page size generally works well for directio buffers, so use that instead. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- .../aio-dio-append-write-fallocate-race.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c b/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c index 091b047d..d3a2e5fc 100644 --- a/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c +++ b/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c @@ -65,7 +65,7 @@ test( } blocksize = sbuf.st_blksize; - ret = posix_memalign((void **)&buf, blocksize, blocksize); + ret = posix_memalign((void **)&buf, sysconf(_SC_PAGESIZE), blocksize); if (ret) { errno = ret; perror("buffer");