From patchwork Wed Mar 29 00:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13191788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B09D5C6FD18 for ; Wed, 29 Mar 2023 00:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjC2A6N (ORCPT ); Tue, 28 Mar 2023 20:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjC2A6M (ORCPT ); Tue, 28 Mar 2023 20:58:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00B751FE2; Tue, 28 Mar 2023 17:58:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7D86361A15; Wed, 29 Mar 2023 00:58:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC4D2C433EF; Wed, 29 Mar 2023 00:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680051490; bh=7X4wCnYJn7Rq6nGNOHZh/8BiePB5G0VwBfETuwqyVSw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=SlLgb+tHU9w6x5nOa79rae0fkF4t7ZY1T7JXvKkP7WYp7QiyjWcEzlmI5ayzJkVmE 8sn09pzKWH/i/ltNdTvwAIZWQc/614EV/yOPhsbiSPnGQQwB2QyvDtJp0ilnJzr+CW l6ictsfoExpgcsodm0NJC50ZIqeSEmnhT/3uioCDPOi7j3iAepDG4JWDLiAk+tq8a2 0zx/5Vw6gIbPiMEChxwHczkbl2D2X/L5vI5ezNqJeOsZR1/i8x3tpAEMhDfCSb/5nJ 4X8f+La+B5ZwEo52NMPQp/S0YBzTw3xom5OHFfjO3Cb+Z3bNMs3EtPieDJ2FUJJs9E +yUrF16ZNpsQw== Subject: [PATCH 1/3] generic/{251,260}: compute maximum fitrim offset From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 28 Mar 2023 17:58:10 -0700 Message-ID: <168005149047.4147931.2729971759269213680.stgit@frogsfrogsfrogs> In-Reply-To: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> References: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong FITRIM is a bizarre ioctl. Callers are allowed to pass in "start" and "length" parameters, which are clearly some kind of range argument. No means is provided to discover the minimum or maximum range. Although regular userspace programs default to (start=0, length=-1ULL), this test tries to exercise different parameters. However, the test assumes that the "size" column returned by the df command is the maximum value supported by the FITRIM command, and is surprised if the number of bytes trimmed by (start=0, length=-1ULL) is larger than this size quantity. This is completely wrong on XFS with realtime volumes, because the statfs output (which is what df reports) will reflect the realtime volume if the directory argument is a realtime file or a directory flagged with rtinherit. This is trivially reproducible by configuring a rt volume that is much larger than the data volume, setting rtinherit on the root dir at mkfs time, and running either of these tests. Refactor the open-coded df logic so that we can determine the value programmatically for XFS. Signed-off-by: Darrick J. Wong --- common/rc | 15 +++++++++++++++ common/xfs | 11 +++++++++++ tests/generic/251 | 2 +- tests/generic/260 | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/common/rc b/common/rc index 90749343f3..228982fa4d 100644 --- a/common/rc +++ b/common/rc @@ -3927,6 +3927,21 @@ _require_batched_discard() fi } +# Given a mountpoint and the device associated with that mountpoint, return the +# maximum start offset that the FITRIM command will accept, in units of 1024 +# byte blocks. +_discard_max_offset_kb() +{ + case "$FSTYP" in + xfs) + _xfs_discard_max_offset_kb "$1" + ;; + *) + $DF_PROG -k | grep "$1" | grep "$2" | awk '{print $3}' + ;; + esac +} + _require_dumpe2fs() { if [ -z "$DUMPE2FS_PROG" ]; then diff --git a/common/xfs b/common/xfs index e8e4832cea..a6c82fc6c7 100644 --- a/common/xfs +++ b/common/xfs @@ -1783,3 +1783,14 @@ _require_xfs_scratch_atomicswap() _notrun "atomicswap dependencies not supported by scratch filesystem type: $FSTYP" _scratch_unmount } + +# Return the maximum start offset that the FITRIM command will accept, in units +# of 1024 byte blocks. +_xfs_discard_max_offset_kb() +{ + local path="$1" + local blksz="$($XFS_IO_PROG -c 'statfs' "$path" | grep "geom.bsize" | cut -d ' ' -f 3)" + local dblks="$($XFS_IO_PROG -c 'statfs' "$path" | grep "geom.datablocks" | cut -d ' ' -f 3)" + + echo "$((dblks * blksz / 1024))" +} diff --git a/tests/generic/251 b/tests/generic/251 index 2a271cd126..8ee74980cc 100755 --- a/tests/generic/251 +++ b/tests/generic/251 @@ -71,7 +71,7 @@ _guess_max_minlen() fstrim_loop() { trap "_destroy_fstrim; exit \$status" 2 15 - fsize=$($DF_PROG | grep $SCRATCH_MNT | grep $SCRATCH_DEV | awk '{print $3}') + fsize=$(_discard_max_offset_kb "$SCRATCH_MNT" "$SCRATCH_DEV") mmlen=$(_guess_max_minlen) while true ; do diff --git a/tests/generic/260 b/tests/generic/260 index 2f653b4af2..08fde46873 100755 --- a/tests/generic/260 +++ b/tests/generic/260 @@ -27,7 +27,7 @@ _scratch_mount _require_batched_discard $SCRATCH_MNT -fssize=$($DF_PROG -k | grep "$SCRATCH_MNT" | grep "$SCRATCH_DEV" | awk '{print $3}') +fssize=$(_discard_max_offset_kb "$SCRATCH_MNT" "$SCRATCH_DEV") beyond_eofs=$(_math "$fssize*2048") max_64bit=$(_math "2^64 - 1") From patchwork Wed Mar 29 00:58:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13191789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD54C761A6 for ; Wed, 29 Mar 2023 00:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbjC2A6T (ORCPT ); Tue, 28 Mar 2023 20:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjC2A6S (ORCPT ); Tue, 28 Mar 2023 20:58:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96BF719B1; Tue, 28 Mar 2023 17:58:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C68D61A21; Wed, 29 Mar 2023 00:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F2FAC433D2; Wed, 29 Mar 2023 00:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680051496; bh=JCJB0mfkCICRzc3ydZ+FdB85+bN7patQ8AJ1SWFkHwo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=q5O95SraFBszxtM45D/5pp6ABbL7CbHEaUf8ZAL7R/idVy19Nm6rvrDQ0tQJNe3r6 vJwFj28pXJRWiV+cttgJlvjP7jT0c9zEi+HCoMp2eFwtXtGtRuhb+xtA+lzoR6N3rK ObyenLC0vGzWzsuSU1FQj6auNmKYdLJ7PHDgd6lYnXaX1yw3hThYGcQJ7fSu3KDwT4 058Uobq2taq8vn+eeWpZk4DlS0lmdmdcfoS0d7GhuzLFXlcltf+/PjiGNyefZ/qXzi sd+FnQcjh/XcFIlVO09MBdDTxIqRBp10TWHtHxUFAUbqQdxcrRjzQkv8nv5pwNEDDm aBZhpgMJl0IaQ== Subject: [PATCH 2/3] xfs/242: fix _filter_bmap for xfs_io bmap that does rt file properly From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 28 Mar 2023 17:58:16 -0700 Message-ID: <168005149606.4147931.15638466274918510566.stgit@frogsfrogsfrogs> In-Reply-To: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> References: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong xfsprogs commit b1faed5f787 ("xfs_io: fix bmap command not detecting realtime files with xattrs") fixed the xfs_io bmap output to display realtime file columns for realtime files with xattrs. As a result, the data and unwritten flags are in column 5 and not column 7. Signed-off-by: Darrick J. Wong Reviewed-by: David Disseldorp --- common/punch | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/punch b/common/punch index 3b8be21a2a..9e730404e2 100644 --- a/common/punch +++ b/common/punch @@ -188,6 +188,7 @@ _filter_hole_fiemap() _coalesce_extents } +# Column 7 for datadev files and column 5 for rtdev files # 10000 Unwritten preallocated extent # 01000 Doesn't begin on stripe unit # 00100 Doesn't end on stripe unit @@ -200,6 +201,13 @@ _filter_bmap() print $1, $2, $3; next; } + $5 ~ /1[01][01][01][01]/ { + print $1, $2, "unwritten"; + next; + } + $5 ~ /0[01][01][01][01]/ { + print $1, $2, "data" + } $7 ~ /1[01][01][01][01]/ { print $1, $2, "unwritten"; next; From patchwork Wed Mar 29 00:58:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13191790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB77AC76196 for ; Wed, 29 Mar 2023 00:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229479AbjC2A6Z (ORCPT ); Tue, 28 Mar 2023 20:58:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbjC2A6Y (ORCPT ); Tue, 28 Mar 2023 20:58:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 367531724; Tue, 28 Mar 2023 17:58:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C5F7661A21; Wed, 29 Mar 2023 00:58:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27FBFC433D2; Wed, 29 Mar 2023 00:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680051502; bh=QmpXWT6LReg9Numkt8jhEE44oOAqZQb+vKXg5M8rhqI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=L3Lb7zO3E32jm19ZNLn7Z9VAcQFqOm7AmiISdK+A8/OZ5dyy1bagvbpsAAFi8giIM VhIIYu1Gimd+Zj8/cLAsWym/dYo2UjQto+hjWirGTQ8yrh3CBsO87uUSFCd6G3Tbon yToyO1MfPwt3VDsycHcQ3oTJhkBUstRompzg0IgdI5l5X4NdLCt9/fVjcErriTQUIp Xw7YZr1/MM6mWAQ8fuRmfD8pUaeQjY1/omR3ZY56GbKNSo3AfqngwurXzXPgG+d1um gFCfa1TO7eaW291uWySwQwgowZ8ge7NazhBO/1tv0pR8ZyxP/vMDFX+UC+4hgqpLmy pY6aBjsp92yEg== Subject: [PATCH 3/3] common/report: fix typo in FSSTRESS_AVOID From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 28 Mar 2023 17:58:21 -0700 Message-ID: <168005150172.4147931.1361107257343712396.stgit@frogsfrogsfrogs> In-Reply-To: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> References: <168005148468.4147931.1986862498548445502.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Fix a minor typo. Signed-off-by: Darrick J. Wong Reviewed-by: David Disseldorp --- common/report | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/report b/common/report index 23ddbb096d..be930e0b06 100644 --- a/common/report +++ b/common/report @@ -10,7 +10,7 @@ REPORT_ENV_LIST=("SECTION" "FSTYP" "PLATFORM" "MKFS_OPTIONS" "MOUNT_OPTIONS" \ "SCRATCH_DEV" "SCRATCH_MNT" "OVL_UPPER" "OVL_LOWER" "OVL_WORK") # Variables that are captured in the report /if/ they are set. -REPORT_ENV_LIST_OPT=("TAPE_DEV" "RMT_TAPE_DEV" "FSSTRES_AVOID" "FSX_AVOID" +REPORT_ENV_LIST_OPT=("TAPE_DEV" "RMT_TAPE_DEV" "FSSTRESS_AVOID" "FSX_AVOID" "KCONFIG_PATH" "PERF_CONFIGNAME" "MIN_FSSIZE" "IDMAPPED_MOUNTS")