From patchwork Thu Jan 16 23:35:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942697 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FD3F1F3FD5; Thu, 16 Jan 2025 23:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070521; cv=none; b=LOcLOs+TGsg1+tfu+AjD2Ei3nGs1gmIO4DOlO7Vs/Es8KxYPkRQTig7OGTCTckC6Dg1QW5qGMEPibioeaBZHQtBx5S53WpepQ2b24sbeUKHtT6mDVF95qaw/PRNCUmAaUfoX9KT7/Iz9S6Hv1MPM0gZoTv+ZHgbKbbnZTpOiSoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070521; c=relaxed/simple; bh=gRf4MxVnHddUnc4UV+EqKuTeS7NKEjOCvLesxG8DCRA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qjcVyAz91FAAqc0GPsjNuxsUmA6syOYdKgsUkSJeXNeJ0TWrf6JyaIzhlNNw6jrS20KvNWlahLbfHOfkALLNuIyQxAGBo16U13oy6Qi4L074yDKx84mN/tOmvMEFhAeyn13gyhLSIoKQFqnYts2tQBvVoOgNqWDZd1pPXCghrxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N+5P48vq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N+5P48vq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F5AC4CED6; Thu, 16 Jan 2025 23:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070520; bh=gRf4MxVnHddUnc4UV+EqKuTeS7NKEjOCvLesxG8DCRA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=N+5P48vqB4iKL/Othh7lJ7OdFkLRb5kBdRiskE9fXmE9Uj4kgmuX8p7YVfHsr+hlT Hl9TIKa0VJ+TWjQ+K+l8arPoyuK0s22/sQRIhphT7/vRGss0VQsLb++G+k7XpGjWOE 1tIFapQHZJuKcCCdo+SsWo7GeattY0U0WEU71tLq0M5swb/wRCTJIldqiLP8YBK4Hn kilNyxGazUs2xp7FcevySxQF3ho59R6izyItSkKieprU7SlRsZS+DNItSQhdnm1BIs iigeuK/4nrC4X2V0AQEzxRwoGi0CRiP18FYsZ8nUfO10vphm+3AhDVsweCXSUzBZz1 wBfAFSFTEfq2A== Date: Thu, 16 Jan 2025 15:35:20 -0800 Subject: [PATCH 01/14] common/populate: refactor caching of metadumps to a helper From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976078.1928798.12300798830762503667.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Hoist out of _scratch_populate_cached all the code that we use to save a metadump of the populated filesystem. We're going to make this more involved for XFS in the next few patches so that we can take advantage of the new support for external devices in metadump/mdrestore. Signed-off-by: "Darrick J. Wong" --- common/populate | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/common/populate b/common/populate index 4cf9c0691956a3..4cc4415697ac78 100644 --- a/common/populate +++ b/common/populate @@ -1051,6 +1051,31 @@ _scratch_populate_restore_cached() { return 1 } +# Take a metadump of the scratch filesystem and cache it for later. +_scratch_populate_save_metadump() +{ + local metadump_file="$1" + + case "${FSTYP}" in + "xfs") + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + + _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ + compress -a -o + res=$? + ;; + "ext2"|"ext3"|"ext4") + _ext4_metadump "${SCRATCH_DEV}" "${metadump_file}" compress + res=$? + ;; + *) + _fail "Don't know how to save a ${FSTYP} filesystem." + esac + return $res +} + # Populate a scratch FS from scratch or from a cached image. _scratch_populate_cached() { local meta_descr="$(_scratch_populate_cache_tag "$@")" @@ -1074,26 +1099,20 @@ _scratch_populate_cached() { # Oh well, just create one from scratch _scratch_mkfs - echo "${meta_descr}" > "${populate_metadump_descr}" case "${FSTYP}" in "xfs") _scratch_xfs_populate $@ _scratch_xfs_populate_check - - local logdev=none - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ - logdev=$SCRATCH_LOGDEV - - _xfs_metadump "$POPULATE_METADUMP" "$SCRATCH_DEV" "$logdev" \ - compress -a -o ;; "ext2"|"ext3"|"ext4") _scratch_ext4_populate $@ _scratch_ext4_populate_check - _ext4_metadump "${SCRATCH_DEV}" "${POPULATE_METADUMP}" compress ;; *) _fail "Don't know how to populate a ${FSTYP} filesystem." ;; esac + + _scratch_populate_save_metadump "${POPULATE_METADUMP}" && \ + echo "${meta_descr}" > "${populate_metadump_descr}" } From patchwork Thu Jan 16 23:35:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942698 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E338A1F3FD7; Thu, 16 Jan 2025 23:35:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070537; cv=none; b=RNcNG2qyHwaBMbLOFrV7LGr+m+J5cypGApc5NWvEbYGPzOtfufMh5wFlHcjyuCBz9XddK2EMW5eQXJQOsmrympJJGr99Xr/5t4nZWBNdTVy9XKjcE+Vzldag4BR/uJdHWQcNmvbssaipL7xtPONRbkQKWVX23hMvUyLJ3Hvo03o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070537; c=relaxed/simple; bh=rhltLT/ppZYKCi5Ez89cB7XeFHOQYBDN55ZjeImE8j8=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M4YrAnVr6Y3z0RB2ebqkCeHWfGpBieNGaMqFPyd60ZuTPdbAYGIebYEXYR+6N/eQgzeEnyc9rhM8ng248WhLQ17dzZUnH5Es7SPwT6N2XmAA0fHIQ37ur0g0m7oiqRLdSQO+2+xWXfpsZDTUTofc6wrxj6maDD6a/AR/fadhKZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l82z7khT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l82z7khT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EF93C4CEDD; Thu, 16 Jan 2025 23:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070536; bh=rhltLT/ppZYKCi5Ez89cB7XeFHOQYBDN55ZjeImE8j8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=l82z7khThBqvUjb8BCyD6Ckdpns3ZksM7p7CEmtNdjCoeQQobIJVZ5aRnPQOJFgnr EA6A/dsvyoYHQbpME3K3lAU5ppGt3NBq+Gu0cA1brdXsdsEkMNydK06r3SLVyf/9Ek +zT6FqWf/LV0S1bF/GaTcB8TRiWDD4dkDm0Fty9c3TOooJSIjqv445vget2R4R1iKf ww3obuMgK436FdwE1e543vLCOjD0rp1OLCflPhvLNIbj/baQ4S3uHi4IpoRnscaSIa kKUfNcBu4wDG0FHx97pwS/MlkrMNtEZtbLqBH0NUIRswzLYD1ny15nj6PyPB1X6ABV wpag8e2IsK3Sg== Date: Thu, 16 Jan 2025 15:35:36 -0800 Subject: [PATCH 02/14] common/{fuzzy,populate}: use _scratch_xfs_mdrestore From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976093.1928798.18219737153083282251.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Port the fuzzing and populated filesystem cache code to use this helper to pick up external log devices for the scratch filesystem. Signed-off-by: "Darrick J. Wong" --- common/fuzzy | 2 +- common/populate | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/common/fuzzy b/common/fuzzy index 331bf5ad7bbafa..9fcaf9b6ee55a9 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -306,7 +306,7 @@ __scratch_xfs_fuzz_unmount() __scratch_xfs_fuzz_mdrestore() { __scratch_xfs_fuzz_unmount - _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" || \ + _scratch_xfs_mdrestore "${POPULATE_METADUMP}" || \ _fail "${POPULATE_METADUMP}: Could not find metadump to restore?" } diff --git a/common/populate b/common/populate index 4cc4415697ac78..814f28a41c9bea 100644 --- a/common/populate +++ b/common/populate @@ -1017,19 +1017,8 @@ _scratch_populate_restore_cached() { case "${FSTYP}" in "xfs") - _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" - res=$? - test $res -ne 0 && return $res - - # Cached images should have been unmounted cleanly, so if - # there's an external log we need to wipe it and run repair to - # format it to match this filesystem. - if [ -n "${SCRATCH_LOGDEV}" ]; then - $WIPEFS_PROG -a "${SCRATCH_LOGDEV}" - _scratch_xfs_repair - res=$? - fi - return $res + _scratch_xfs_mdrestore "${metadump}" + return $? ;; "ext2"|"ext3"|"ext4") _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" From patchwork Thu Jan 16 23:35:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942699 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AADFB1F3FD5; Thu, 16 Jan 2025 23:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070552; cv=none; b=om1jGV8txioDb4DGUK1DGyfv/hUnTTDKrVBFYhtTxfqAJEIb7qAwjiSsufu2dfgL8ON4laWpDKRejBIoPtKHpyLnsLYK2pKSlQlNjcCh8KFPrQTR4am1PmFNxvcRJqkJA9wNcE5ft4BWO8VwnR8sNctvdcNSs25FrFEUnZ3f0E0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070552; c=relaxed/simple; bh=O9Bv49fnlzRJaUvFdZ+3SZB7Mb3tW+wgFkVZSKCqvaI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FwRFKkr8XbD1yml9ZZpSojPRzm5+mjs5lhY6YanGL+OBRZbi54Dm9CQSWgEGkTbdx14CVaKrgdF/+Dol+1oppQ8cHpeETnYoYzazOA3Uh3lPu4fsj1yfVLEFDKAQ9z6Phxh8qws3kUE78/8DrCt8Zx6ENSdS1P9GulReSWIGJbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ljpwbQnN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ljpwbQnN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FA4AC4CED6; Thu, 16 Jan 2025 23:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070552; bh=O9Bv49fnlzRJaUvFdZ+3SZB7Mb3tW+wgFkVZSKCqvaI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ljpwbQnNHXr4bRG8VWYIsU7LX26YRfL6CyxyPYb2EMg0U0mm1uh2xRg6s/2NHs+Ma y0jEk8XJbuPTv8yl7BDzXwCMVXeegj2pERvyRdHuN49jpCJksY/ukefIbd9EmvqqYB XPU7wx1Gnwi/woyNAYqJDm33FM+g1fCmAK6nT796bsHllhZYMfFbEdhEXQ1Ihrh9YO aj2UO7YWqs4C2Y+i75v9Jv//bwzteEzmJeeswgXvPuptl5RgtfPgKWpFvZ4Ps+jDs3 ttKzHzSTcyGdsL15gqHsGMitUVRBiuiap2EgDhvJpl+09FtdS9sqLyjrEkcUzj/jdp PBw18bIWksa8w== Date: Thu, 16 Jan 2025 15:35:51 -0800 Subject: [PATCH 03/14] fuzzy: stress data and rt sections of xfs filesystems equally From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976109.1928798.465942861320732980.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If we're stress-testing scrub on a realtime filesystem, make sure that we run fsstress on separate directory trees for data and realtime workouts. Signed-off-by: "Darrick J. Wong" --- common/fuzzy | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/common/fuzzy b/common/fuzzy index 9fcaf9b6ee55a9..a7e28dda137e8a 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -1018,15 +1018,28 @@ __stress_scrub_fsx_loop() { rm -f "$runningfile" } +# Run fsstress and record outcome +__run_fsstress() { + _run_fsstress $* + local res=$? + echo "fsstress $* exits with $res at $(date)" >> $seqres.full + test "$res" -ne 0 && touch "$tmp.killstress" +} + # Run fsstress while we're testing online fsck. __stress_scrub_fsstress_loop() { local end="$1" local runningfile="$2" local remount_period="$3" local stress_tgt="$4" - local focus=() - local res + local focus=(-p 4 -n 2000000) + local res res2 local duration + local has_rt + local d_args r_args + + test $FSTYP = "xfs" && _xfs_has_feature "$SCRATCH_MNT" realtime && \ + has_rt=1 case "$stress_tgt" in "parent") @@ -1118,9 +1131,21 @@ __stress_scrub_fsstress_loop() { # As of March 2022, 2 million fsstress ops should be enough to keep # any filesystem busy for a couple of hours. - local args=$(_scale_fsstress_args -p 4 -d $SCRATCH_MNT -n 2000000 "${focus[@]}") - echo "Running $FSSTRESS_PROG $args" >> $seqres.full + if [ -n "$has_rt" ]; then + mkdir -p $SCRATCH_MNT/rt $SCRATCH_MNT/data + $XFS_IO_PROG -c 'chattr +rt' $SCRATCH_MNT/rt + $XFS_IO_PROG -c 'chattr -rt' $SCRATCH_MNT/data + r_args=$(_scale_fsstress_args -d $SCRATCH_MNT/rt "${focus[@]}") + d_args=$(_scale_fsstress_args -d $SCRATCH_MNT/data "${focus[@]}") + echo "Running $FSSTRESS_PROG $d_args" >> $seqres.full + echo "Running $FSSTRESS_PROG $r_args" >> $seqres.full + else + d_args=$(_scale_fsstress_args -d $SCRATCH_MNT "${focus[@]}") + echo "Running $FSSTRESS_PROG $d_args" >> $seqres.full + fi + + rm -f "$tmp.killstress" if [ -n "$remount_period" ]; then local mode="rw" local rw_arg="" @@ -1130,12 +1155,10 @@ __stress_scrub_fsstress_loop() { test "$mode" = "rw" && __stress_scrub_clean_scratch && continue duration=$(___stress_scrub_duration "$end" "$remount_period") - _run_fsstress_bg $duration $args $rw_arg >> $seqres.full - sleep $remount_period - _kill_fsstress - res=$? - echo "$mode fsstress exits with $res at $(date)" >> $seqres.full - [ "$res" -ne 0 ] && break; + __run_fsstress $duration $d_args $rw_arg & + test -n "$has_rt" && __run_fsstress $duration $r_args $rw_arg & + wait + test -e "$tmp.killstress" && break if [ "$mode" = "rw" ]; then mode="ro" @@ -1151,7 +1174,7 @@ __stress_scrub_fsstress_loop() { sleep 0.2 done done - rm -f "$runningfile" + rm -f "$runningfile" "$tmp.killstress" return 0 fi @@ -1159,12 +1182,12 @@ __stress_scrub_fsstress_loop() { # Need to recheck running conditions if we cleared anything __stress_scrub_clean_scratch && continue duration=$(___stress_scrub_duration "$end" "$remount_period") - _run_fsstress $duration $args >> $seqres.full - res=$? - echo "$mode fsstress exits with $res at $(date)" >> $seqres.full - [ "$res" -ne 0 ] && break; + __run_fsstress $duration $d_args & + test -n "$has_rt" && __run_fsstress $duration $r_args & + wait + test -e "$tmp.killstress" && break done - rm -f "$runningfile" + rm -f "$runningfile" "$tmp.killstress" } # Make sure we have everything we need to run stress and scrub From patchwork Thu Jan 16 23:36:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942700 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 501D81F55FF; Thu, 16 Jan 2025 23:36:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070568; cv=none; b=d9Zb5rlpNF62SCQAWgTRImqvsQjYqC/LLeir2uN7UhFl0kMCOJG6/UCKXj/xqXvCqnq4/UCj5MotZvNwpqHX7GrlITN32+HEVVUNBqqax50invE7aQ+lMSynvCmYFu1eC52UwsXIlyHGpN3slmHCnxXq0ql2rrB9K92AAP/BnPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070568; c=relaxed/simple; bh=sQN5jC6hMqKGwXcUtJCu4yR8YznzXedjrsTFwcWnhh8=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FCC74fyVFeCtSa2NCaUE7VZCXX3kWhVRCXv9exTzLv5ss2wjg5fhs57eBuHmWP9SDDLb1mTQPb5PjbcrnAs+Q2v56YgX2iQdlJQEl9zW114pvDphCk0AFnu5W0+mP0IqzCFQPApCcDQ2vdVHlvJer1b1mrfHiYF3sYDEQy/z6/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cL2gkpFJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cL2gkpFJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEBDBC4CED6; Thu, 16 Jan 2025 23:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070567; bh=sQN5jC6hMqKGwXcUtJCu4yR8YznzXedjrsTFwcWnhh8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cL2gkpFJ+uryP+Qmz0pqD88ae68fZIUCS3jjpCL90qy6ALX+6zCvzaOdFFYHqDmLI qXNlTQyv9pxz/vfMeB7QoyG6gpTwmpNhEWLjiWiC/4q8t1HeOBtcyT1ZQtpTx1a2z5 erg8DKxW+DsyxbThDmqjKr/pNJmQQagbKqyUxwiEp9TIZmjdLplbusNKqhaZmdASX9 bqS1sSKitxq0Me4tpu9mOZaxEJRRA5R8BB4dKLQkfXpnSAoxAIDuzXMhynLvD/gtpW uObJytyx0DuMpB/8BWulHkAe6nw+8dRGTnorRPb38nqJ0C7gKjT5PDcNfSF23yaV+z JSC0MZfO2GpGg== Date: Thu, 16 Jan 2025 15:36:07 -0800 Subject: [PATCH 04/14] common/ext4: reformat external logs during mdrestore operations From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976124.1928798.14068806212309421064.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong The e2image file format doesn't support the capture of external log devices, which means that mdrestore ought to reformat the external log to get the restored filesystem to work again. The common/populate code could already do this, so push it to the common ext4 helper. While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the populate code. Signed-off-by: "Darrick J. Wong" --- common/ext4 | 17 ++++++++++++++++- common/populate | 18 +++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/common/ext4 b/common/ext4 index 13921bb8165a4d..e1b336d3d20cba 100644 --- a/common/ext4 +++ b/common/ext4 @@ -134,7 +134,8 @@ _ext4_mdrestore() { local metadump="$1" local device="$2" - shift; shift + local logdev="$3" + shift; shift; shift local options="$@" # If we're configured for compressed dumps and there isn't already an @@ -148,6 +149,20 @@ _ext4_mdrestore() test -r "$metadump" || return 1 $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" + res=$? + test $res -ne 0 && return $res + + # ext4 cannot e2image external logs, so we have to reformat the log + # device to match the restored fs + if [ "${logdev}" != "none" ]; then + local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ + grep 'Journal UUID:' | \ + sed -e 's/Journal UUID:[[:space:]]*//g')" + $MKFS_EXT4_PROG -O journal_dev "${logdev}" \ + -F -U "${fsuuid}" + res=$? + fi + return $res } # this test requires the ext4 kernel support crc feature on scratch device diff --git a/common/populate b/common/populate index 814f28a41c9bea..65fbd19b30e4e1 100644 --- a/common/populate +++ b/common/populate @@ -1021,20 +1021,12 @@ _scratch_populate_restore_cached() { return $? ;; "ext2"|"ext3"|"ext4") - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" - ret=$? - test $ret -ne 0 && return $ret + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV - # ext4 cannot e2image external logs, so we have to reformat - # the scratch device to match the restored fs - if [ -n "${SCRATCH_LOGDEV}" ]; then - local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ - grep 'Journal UUID:' | \ - sed -e 's/Journal UUID:[[:space:]]*//g')" - $MKFS_EXT4_PROG -O journal_dev "${SCRATCH_LOGDEV}" \ - -F -U "${fsuuid}" - fi - return 0 + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" + return $? ;; esac return 1 From patchwork Thu Jan 16 23:36:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942701 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D7DC1F5608; Thu, 16 Jan 2025 23:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070583; cv=none; b=QQ4rTt5BVfFcjnpj1q9YJHvTdNH9PCYkpRdwOdwnVlU3Q903cbzVaE0qhW0pMzHs43Hv9UeMdNsk9jVMFYIP3cpauni2v5y0yhXmay9tb7vnlAjNvx0RzKWokHvPZW9ob3TVIrEBQUjxyseP3zWVD3CAh+WpnIA+76KoNQu7Rzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070583; c=relaxed/simple; bh=Iw4t699RvEK0soPcLHfWcXPINGsWZ3+yX52nmWR2sb4=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UklgDgQ7//KCE1EEP9bq8TWm0Wu+dJYjDQUdo70g0ClcHXstEhmsOgprMnTs/VgYF5H/wVKIpmH3LiyWjOEkcK39m/fyAaNK4yUdpf7Uoitd8UEX+0z36mhp6SJl0dvosgNzIZdGIFxjUY78xpdGx/1LOdkBLYXJ2uuMXVA9vVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HEGuruDL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HEGuruDL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 661A0C4CED6; Thu, 16 Jan 2025 23:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070583; bh=Iw4t699RvEK0soPcLHfWcXPINGsWZ3+yX52nmWR2sb4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=HEGuruDLvZ8wjCdls6mFhpOCW25uIFd/0wSN4vgSIRl96wFXosN5Tn58wXnFfZiQV Uf7vsdYkCNwgUm/yscJzyInNM0iS/0fSLhl2va2yeQ1e0yonMU89XzqqyqNBrw1IZa oBibSiNdrGQmztKeUuPzrp+RqMtLT2eWFulX4m7IBQlNFX/UgTYwJ4fUmJDNSU0qk/ nnmRHI3pHIcakLcZfV4kgIk0xaeRl3AQ5xI/nv9vChSqJpgCkoRWFca2lC9EzY5JYU D5CIiMlQRQlEXbihpsALWtU5LPYN1xzM/nu1Df2LdV/y/vkDvtBXsEK19t0YByMb9d 3nJ3Cxpg10ZBg== Date: Thu, 16 Jan 2025 15:36:22 -0800 Subject: [PATCH 05/14] common/populate: use metadump v2 format by default for fs metadata snapshots From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976139.1928798.13803844705915710708.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong When we're snapshotting filesystem metadata after creating a populated filesystem, force the creation of metadump v2 files by default to exercise the new format, since xfs_metadump continues to use the v1 format unless told otherwise. Signed-off-by: "Darrick J. Wong" --- common/populate | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/populate b/common/populate index 65fbd19b30e4e1..96fc13875df503 100644 --- a/common/populate +++ b/common/populate @@ -55,7 +55,12 @@ __populate_fail() { case "$FSTYP" in xfs) _scratch_unmount - _scratch_xfs_metadump "$metadump" -a -o + + mdargs=('-a' '-o') + test "$(_xfs_metadump_max_version)" -gt 1 && \ + mdargs+=('-v' '2') + + _scratch_xfs_metadump "$metadump" "${mdargs[@]}" ;; ext4) _scratch_unmount @@ -1043,8 +1048,12 @@ _scratch_populate_save_metadump() [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ logdev=$SCRATCH_LOGDEV + mdargs=('-a' '-o') + test "$(_xfs_metadump_max_version)" -gt 1 && \ + mdargs+=('-v' '2') + _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ - compress -a -o + compress "${mdargs[@]}" res=$? ;; "ext2"|"ext3"|"ext4") From patchwork Thu Jan 16 23:36:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942702 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75FC81F5608; Thu, 16 Jan 2025 23:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070599; cv=none; b=B7BmwGBWgsl3VjV7Cv8U1cGbZhdDjgwsJ1HtJLDctpSrcG4xl4mCs3715zwUXblM8x1laEutB8dgutbqEif5XkyYlZTbUssZYlbNdbyUb+t4apFw4NUf7s4KyLONmeS3ZpleUx0XcQnJxmvI/0pm/T/tc03lZR/R+ULXFnqe4RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070599; c=relaxed/simple; bh=w9l5oe9KrYAocr3lXFRNF6FqOuQwVPQ9y4X2JWHYETc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dToNRGY02qjT0NGejR/MfIIdMVRjjqKIAmbYEam2q5mpgzE0gWOIXx9djz2dkUVGN7DnU8h2wHFTUhr+V0cC98YWmn9psyHnbHsIV3FkprHZuMj5PHdV7La18rOLun/Ee5xuIha6RnaQX9Vn97SM9qiLBcL9OL+PPqG9rVa8es8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dXmVPKgq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dXmVPKgq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03F77C4CEDD; Thu, 16 Jan 2025 23:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070599; bh=w9l5oe9KrYAocr3lXFRNF6FqOuQwVPQ9y4X2JWHYETc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=dXmVPKgqT+38MgjPqbDAdOUOvUp1vQbTngNPN3IdYBUucdKTtYDWXTi1wMXA5bAq7 x8+aJSEtaq68IlHJql9sbqZ5hUi7qGRdRZyowpWg/RZAT+PMl6CCyeTi7+TgwPYPwY bO62N1+brPPcIyheKQQ0pKSaKBRs0sTXXs3/Vg9fRxueA1bL0kN47Bb5wcRj/0k6F5 trywLnx+ngrnBU2ZReruXHin2PTwNopAuHbzOEhE3v2pSHCY2too5G4kvityyOrSQ6 RZW5MbFATZ4ESX6lcsF3WiITN6T0tot0gFs8iNn36DRl/mCwszd201HZ7hJawexEEt BG0IpMWGE5btg== Date: Thu, 16 Jan 2025 15:36:38 -0800 Subject: [PATCH 06/14] punch-alternating: detect xfs realtime files with large allocation units From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976155.1928798.1174262523504222244.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong For files on the XFS realtime volume, it's possible that the file allocation unit (aka the minimum size we have to punch to deallocate file blocks) could be greater than a single fs block. This utility assumed that it's always possible to punch a single fs block, but for these types of files, all that does is zeroes the page cache. While that's what most *user applications* want, fstests uses punching to fragment file mapping metadata and/or fragment free space, so adapt this test for that purpose by detecting realtime files. Signed-off-by: "Darrick J. Wong" --- src/punch-alternating.c | 28 +++++++++++++++++++++++++++- tests/xfs/114 | 4 ++++ tests/xfs/146 | 2 +- tests/xfs/187 | 3 ++- tests/xfs/341 | 4 ++-- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/punch-alternating.c b/src/punch-alternating.c index 18dd215197db2b..d2bb4b6a2276c9 100644 --- a/src/punch-alternating.c +++ b/src/punch-alternating.c @@ -20,6 +20,28 @@ void usage(char *cmd) exit(1); } +/* Compute the file allocation unit size for an XFS file. */ +static int detect_xfs_alloc_unit(int fd) +{ + struct fsxattr fsx; + struct xfs_fsop_geom fsgeom; + int ret; + + ret = ioctl(fd, XFS_IOC_FSGEOMETRY, &fsgeom); + if (ret) + return -1; + + ret = ioctl(fd, XFS_IOC_FSGETXATTR, &fsx); + if (ret) + return -1; + + ret = fsgeom.blocksize; + if (fsx.fsx_xflags & XFS_XFLAG_REALTIME) + ret *= fsgeom.rtextsize; + + return ret; +} + int main(int argc, char *argv[]) { struct stat s; @@ -82,7 +104,11 @@ int main(int argc, char *argv[]) goto err; sz = s.st_size; - blksz = sf.f_bsize; + c = detect_xfs_alloc_unit(fd); + if (c > 0) + blksz = c; + else + blksz = sf.f_bsize; mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; for (offset = start_offset * blksz; diff --git a/tests/xfs/114 b/tests/xfs/114 index 510d31a4028598..f764cad73babb7 100755 --- a/tests/xfs/114 +++ b/tests/xfs/114 @@ -47,6 +47,10 @@ $XFS_IO_PROG -f \ -c "pwrite -S 0x68 -b 1048576 0 $len2" \ $SCRATCH_MNT/f2 >> $seqres.full +# The arguments to punch-alternating must be specified in units of file +# allocation units, so we divide the argument by $file_blksz. We already +# verified that $blksz is congruent with $file_blksz, so the fpunch parameters +# will always align with the file allocation unit. $here/src/punch-alternating -o $((16 * blksz / file_blksz)) \ -s $((blksz / file_blksz)) \ -i $((blksz * 2 / file_blksz)) \ diff --git a/tests/xfs/146 b/tests/xfs/146 index b6f4c2bd093d45..1cd7076d2426ee 100755 --- a/tests/xfs/146 +++ b/tests/xfs/146 @@ -67,7 +67,7 @@ _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 $XFS_IO_PROG -f -c 'falloc 0 64m' "$SCRATCH_MNT/b" -$here/src/punch-alternating -i $((rextblks * 2)) -s $((rextblks)) "$SCRATCH_MNT/b" +$here/src/punch-alternating "$SCRATCH_MNT/b" avail="$(df -P "$SCRATCH_MNT" | awk 'END {print $4}')"1 toobig="$((avail * 2))" diff --git a/tests/xfs/187 b/tests/xfs/187 index 56a9adc164eab2..1d32d702f629c9 100755 --- a/tests/xfs/187 +++ b/tests/xfs/187 @@ -130,7 +130,8 @@ $XFS_IO_PROG -f -c "truncate $required_sz" -c "falloc 0 $remap_sz" $SCRATCH_MNT/ # Punch out every other extent of the last two sections, to fragment free space. frag_sz=$((remap_sz * 3)) punch_off=$((bigfile_sz - frag_sz)) -$here/src/punch-alternating $SCRATCH_MNT/bigfile -o $((punch_off / fsbsize)) -i $((rtextsize_blks * 2)) -s $rtextsize_blks +rtextsize_bytes=$((fsbsize * rtextsize_blks)) +$here/src/punch-alternating $SCRATCH_MNT/bigfile -o $((punch_off / rtextsize_bytes)) # Make sure we have some free rtextents. free_rtx=$(_xfs_statfs_field "$SCRATCH_MNT" statfs.f_bavail) diff --git a/tests/xfs/341 b/tests/xfs/341 index 6e25549b2b3d08..9b12febf8d5c49 100755 --- a/tests/xfs/341 +++ b/tests/xfs/341 @@ -41,8 +41,8 @@ len=$((blocks * rtextsz)) echo "Create some files" $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full -$here/src/punch-alternating -i $((2 * rtextsz_blks)) -s $rtextsz_blks $SCRATCH_MNT/f1 >> "$seqres.full" -$here/src/punch-alternating -i $((2 * rtextsz_blks)) -s $rtextsz_blks $SCRATCH_MNT/f2 >> "$seqres.full" +$here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full" +$here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full" echo garbage > $SCRATCH_MNT/f3 ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount From patchwork Thu Jan 16 23:36:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942703 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C36B91F153D; Thu, 16 Jan 2025 23:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070614; cv=none; b=lCs7opUSadnOJnJzoEyQiadq2kqA2AiSodV7MGh01fu3RXViuaAXBDQeUFOH9dDPw/ECRZU4wSiqiHEU5W4hJYhTzrH1G/j7Xm+Mfy7ZfrsDp2Xd3peY7OYh/Ydai+Qo6ZCoZk1MBcRJrMLAaAHiDAQt0NYH3AXKoKFI9AT+0S0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070614; c=relaxed/simple; bh=duWzI1uS82Jk3R0gIyLbBxxtpjoQqhp5UbLvIPzcoI0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jATl78doxjUf672YKcD6TyvCcYoCNaxvfOK+RnlaiRbKUiJl6n3ReqjMMoKh88p7zhgYfFOdO06f0VCU7rVa8J/j9Ib3WK88Fv9zp+RoDGiPEjMBLOyzBC+GPQgilvA3DkwqI+FbAoBOyzuwdVysg6+Ap+Si6cVvHVmsizEL97k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gBmigk0r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gBmigk0r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C0B2C4CED6; Thu, 16 Jan 2025 23:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070614; bh=duWzI1uS82Jk3R0gIyLbBxxtpjoQqhp5UbLvIPzcoI0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gBmigk0r5lFwOA+RtNR5OptXVImmeqkQrtylLxYNAbwIr5+xI7IMT81SAjqg2Bj8P +gwCbDXEzLU9L+Q9zaKeRxFu9wD6q2DCp/XDaNXYYmnmiMyAym8ymmnNOqCbc2X4Lx rG35zIK7a1wRkpKe4xpBiiKd216payph2eUK3E4y+40rnrJTiiak4iSEwKLm66VfrX dxgcijVJL3Q+oxrZDeOa6w1xtQQf8POX0pJCW0oU8Ce8PdUwUvu//1VrQ7H9NK4z1F pOfw0RbGU3zLk07MkopwPZiACcyYpiqybmRKFPqtQcMtn/m52j3SLMV9DgPRa1JDuh Tbku1LnW/mffw== Date: Thu, 16 Jan 2025 15:36:54 -0800 Subject: [PATCH 07/14] xfs/206: update mkfs filtering for rt groups feature From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976170.1928798.2498500799249120486.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Filter out the new mkfs lines that show the rtgroup information, since this test is heavily dependent on old mkfs output. Signed-off-by: "Darrick J. Wong" --- tests/xfs/206 | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/xfs/206 b/tests/xfs/206 index ef5f4868e9bdca..01531e1f08c37e 100755 --- a/tests/xfs/206 +++ b/tests/xfs/206 @@ -65,6 +65,7 @@ mkfs_filter() -e "/exchange=/d" \ -e '/metadir=.*/d' \ -e 's/, parent=[01]//' \ + -e '/rgcount=/d' \ -e "/^Default configuration/d" } From patchwork Thu Jan 16 23:37:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942704 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E1DB1F78F5; Thu, 16 Jan 2025 23:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070630; cv=none; b=fr9BgriwQy2SSu/niGtfvJgAl4C0TAtyWonWhT90i1EEGeNB7zI6SQ09R5ywWYIoSu0rSSCdXIkk2Z3MfB9MK5TBjVd27jr69kr3hw59hJVKUMSfuqXJvnahG5U1Q2Bwyr/8VfDnXqQuuU6ezd0NcmAMiEj7VSfXz8eJWlGUA/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070630; c=relaxed/simple; bh=whgHXdDe4v2qGzbi60U9hg9fOP5STBty49Ju3sKfVek=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sCc+3k+UzkxcLUtbNhFvQJ2t9ltooFBncGH75mHAgfi/xcgihn/TD5/lq8KLhcvXoNjo3IgzH/f7juH1rpSUl1Lc1UbmPb7BG0M5M3+GZ3xqgjGg5ppRGbTY/2KTUWLTEd1i+hMoDGs7E1oWTjjKKeqLG7P5K6WRWQlk9Zno27E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GB8TtDP/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GB8TtDP/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3143CC4CEDD; Thu, 16 Jan 2025 23:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070630; bh=whgHXdDe4v2qGzbi60U9hg9fOP5STBty49Ju3sKfVek=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=GB8TtDP/I3elHXqtnFdhco0YQk/utPZSjUumFHT1S5/E9fJRQium3bAabljsmXLYX li6gle40pKXvroaXD6r68xSpfpLPQfu36Hlp+pNn+wgdWNOkoTr3XThFEI6bySkrlG KrcZdmG6spcaaC1idIJ6FEYb4TS7b7vgXlRr5ekIcTxXpSlM2Z0xlwQTzTD85/+JgG YACSSgOUupSvmJQQPrWi21KX5g8blliXyRziP6F0xAc+aOza6N/CXZcHJIbzn4SfI0 5nVCn5nZojGS99GlawQwKz+2GTA1qFbXF7GisYdjwiO66t+MN79dJwQDwwCUlTVN2c Wmynl9h3HrHzg== Date: Thu, 16 Jan 2025 15:37:09 -0800 Subject: [PATCH 08/14] common: pass the realtime device to xfs_db when possible From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976185.1928798.11944257459731657070.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Teach xfstests to pass the realtime device to xfs_db when it supports that option. Signed-off-by: "Darrick J. Wong" --- common/xfs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/xfs b/common/xfs index b8e24c2e0ce8fe..6e2070b5647b38 100644 --- a/common/xfs +++ b/common/xfs @@ -308,6 +308,10 @@ _scratch_xfs_db_options() SCRATCH_OPTIONS="" [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV" + if [ "$USE_EXTERNAL" = yes ] && [ ! -z "$SCRATCH_RTDEV" ]; then + $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev' && \ + SCRATCH_OPTIONS="$SCRATCH_OPTIONS -R$SCRATCH_RTDEV" + fi echo $SCRATCH_OPTIONS $* $SCRATCH_DEV } From patchwork Thu Jan 16 23:37:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942705 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33A3E1F560F; Thu, 16 Jan 2025 23:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070646; cv=none; b=UaleSupLXt6fiDbg39vMpfmTeTrLFtVto6nQ0zggHva0LH3zAXdvR5zxdSVvfPWYwr20O8zkDiMyq2apMF2YpCRmsuFF1DqYPEaYqNyVr5FLWeXePJTTYQPvXbjpE8n3pYk4UEwSzZwRo65AWFc7n2AWx+ThprPrLETO30k6aNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070646; c=relaxed/simple; bh=xoEhcutLggFEZrv8+/ZgQrcuPbQWa3NzM+O892meeg0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ke4i3LKGEYebkJx5k2dS50a3WyyLY9CpQf0C/HoHv0ws6pQwSlvEQhlglByYK00vNzIImyNNedCsXeUhYAZ5h8tHO2/LM9UO1isXcNChdxL3R012jFCA+Bzh2UtdUpJOX/jYyTwBkCZER+c9CJrJzzZazB0CVyRDugWM38ne9hc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V+WmrG15; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V+WmrG15" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10822C4CED6; Thu, 16 Jan 2025 23:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070646; bh=xoEhcutLggFEZrv8+/ZgQrcuPbQWa3NzM+O892meeg0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=V+WmrG15Uyzv9HrmWTKKfG3Cgz8tJLew0pR8WoyG52axz7vwS51bQgEQG08cb9dYX qqe6ctrxH4/AosUP60CsjFLrkUD9dz6RcsNJuEEbTvg2+mxXaKhWF1hS0U7td9ELKX WeGke/yrlxUBjXlulGGZiuuaNFrMe2MI+L7wCLEPjdxTpgDg/VUjun3bu919PbrJUJ UeJAWibkkwxXUO40ODOQh+KqHR+EIfB4n+sZao4nxtQzSXlIZgYainwMlv45Hf2LGZ dPX9YijSS0RxiXCap1qvonwkF8UAjI+SlIYiycuXPWezFxKzXYB1AQM8tZMXvihtZ1 HPVWKxwYRrP0A== Date: Thu, 16 Jan 2025 15:37:25 -0800 Subject: [PATCH 09/14] xfs/185: update for rtgroups From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976201.1928798.8997062757177421772.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong This old test is a bit too fixated on exact rt allocator behavior. With rtgroups enabled, we can end up with one large contiguous region that's split into multiple bmbt mappings to avoid crossing rtgroup boundaries. The realtime superblock throws another twist into the mix because the first rtx will always be in use, which can shift the start of the physical space mappings by up to 1 rtx. Also fix a bug where we'd try to fallocate the total number of rtx, whereas we should be asking for the number of free rtx to avoid ENOSPC errors. Signed-off-by: "Darrick J. Wong" --- tests/xfs/185 | 65 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/tests/xfs/185 b/tests/xfs/185 index f3601a5292ef0b..7aceb383ce4609 100755 --- a/tests/xfs/185 +++ b/tests/xfs/185 @@ -97,10 +97,17 @@ test "$ddbytes" -lt "$((rtbytes + (10 * rtextsize) ))" || \ # higher than the size of the data device. For realtime files this is really # easy because fallocate for the first rt file always starts allocating at # physical offset zero. -alloc_rtx="$((rtbytes / rtextsize))" +rtfreebytes="$(stat -f -c '%S * %a' $rtfile | bc)" +alloc_rtx="$((rtfreebytes / rtextsize))" $XFS_IO_PROG -c "falloc 0 $((alloc_rtx * rtextsize))" $rtfile -expected_end="$(( (alloc_rtx * rtextsize - 1) / 512 ))" +# log a bunch of geometry data to the full file for debugging +echo "rtbytes $rtbytes rtfreebytes $rtfreebytes rtextsize $rtextsize" >> $seqres.full +echo "allocrtx $alloc_rtx falloc $((alloc_rtx * rtextsize))" >> $seqres.full +$XFS_IO_PROG -c statfs $SCRATCH_MNT >> $seqres.full + +total_rtx=$(_xfs_statfs_field $SCRATCH_MNT geom.rtextents) +expected_end="$(( (total_rtx * rtextsize - 1) / 512 ))" # Print extent mapping of rtfile in format: # file_offset file_end physical_offset physical_end @@ -113,13 +120,28 @@ rtfile_exts() { done } -# Make sure that we actually got the entire device. -rtfile_exts | $AWK_PROG -v end=$expected_end ' +# Make sure that fallocate actually managed to map the entire rt device. The +# realtime superblock may consume the first rtx, so we allow for that here. +# Allow for multiple contiguous mappings if the rtgroups are very small. +allowed_start=$((rtextsize / 512)) +rtfile_exts | $AWK_PROG -v exp_start=$allowed_start -v exp_end=$expected_end ' +BEGIN { + start = -1; + end = -1; +} { - if ($3 != 0) - printf("%s: unexpected physical offset %s, wanted 0\n", $0, $3); - if ($4 != end) - printf("%s: unexpected physical end %s, wanted %d\n", $0, $4, end); + if (end >= 0 && ($3 != end + 1)) + printf("%s: non-contiguous allocation should have started at %s\n", $0, end + 1); + if (start < 0 || $3 < start) + start = $3; + if (end < 0 || $4 > end) + end = $4; +} +END { + if (start > exp_start) + printf("%s: unexpected physical offset %d, wanted <= %d\n", $0, start, exp_start); + if (end != exp_end) + printf("%s: unexpected physical end %d, wanted %d\n", $0, end, exp_end); }' # Now punch out a range that is slightly larger than the size of the data @@ -132,14 +154,27 @@ expected_offset="$((punch_rtx * rtextsize / 512))" echo "rtfile should have physical extent from $expected_offset to $expected_end sectors" >> $seqres.full -# Make sure that the realtime file now has only one extent at the end of the -# realtime device -rtfile_exts | $AWK_PROG -v offset=$expected_offset -v end=$expected_end ' +# Make sure that the realtime file now maps one large extent at the end of the +# realtime device. Due to rtgroups boundary rules, there may be multiple +# contiguous mappings. +rtfile_exts | $AWK_PROG -v exp_start=$expected_offset -v exp_end=$expected_end ' +BEGIN { + start = -1; + end = -1; +} { - if ($3 != offset) - printf("%s: unexpected physical offset %s, wanted %d\n", $0, $3, offset); - if ($4 != end) - printf("%s: unexpected physical end %s, wanted %d\n", $0, $4, end); + if (end >= 0 && ($3 != end + 1)) + printf("%s: non-contiguous allocation should have started at %s\n", $0, end + 1); + if (start < 0 || $3 < start) + start = $3; + if (end < 0 || $4 > end) + end = $4; +} +END { + if (start < exp_start) + printf("%s: unexpected physical offset %d, wanted >= %d\n", $0, start, exp_start); + if (end != exp_end) + printf("%s: unexpected physical end %d, wanted %d\n", $0, end, exp_end); }' $XFS_IO_PROG -c 'bmap -elpv' $rtfile >> $seqres.full From patchwork Thu Jan 16 23:37:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942706 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F80E1F91DB; Thu, 16 Jan 2025 23:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070662; cv=none; b=DtN3Wm9mA13+P9rDpnYybZa0acwWqYTt1kkDfgrRxXOes1e/8ZCG4YxIkGPADc4OIEs7BRUzBwuNo8bUo14k1+nf5G9chrSa5ot8Qsxo6hxpEA44pNFPIRKcCsZdIsKZ8NBnJZpIdpKajWM1aTpljZ94HQysuA3ujwHzK3g+wfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070662; c=relaxed/simple; bh=y2ABjItUbd32HXtlfAm1Ea3pYTAv4cHjPK7axHPk1jU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JiTqn7Yk4o7h/8wouyEi3hgEZmpPOu51xe8T2p252hKt7zUThr+3L4pwl0wDeBFSS/xkOb5JbvDqHYS9xhadUGOS1arZn+871WvYY2k106pH8Ot9jvdEfdmNB+OrFBjqQnn43uBS2sa9sWLnc+aLkchnOOpgNunK4UygtvQKjWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MhVJ6raV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MhVJ6raV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93A0DC4CED6; Thu, 16 Jan 2025 23:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070661; bh=y2ABjItUbd32HXtlfAm1Ea3pYTAv4cHjPK7axHPk1jU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=MhVJ6raVIXW/D70fXORx/hO9w43cPDaCGj7tG3ZItOA1JiWXFcbBZCKyRBUcsuP65 x3WJtdoa1tTX1pEkLgtIo100uBhKZYaCSNb2pGoesKSopJEq6q3GOKU/q+qy31J7DT 7CE864WX7KU8KXzStQIsqF+gAQiaVexrcv+wMAr2bxUIMsN0ZeIedFKAvZzlkbGnFL f3Cze19Ga2891JFqhkJF5rdzO0ty5Bj9JUfaNVLcF08y+de2FUh00TJzTg5X5PJnD1 32G7fkhKTs4NwewhjMXnTIEqXVWhAqr9ZLl9GlUbiqbnS0SU/4Vx4PyQoYPiyJgxfr D6A7f2agd0VUQ== Date: Thu, 16 Jan 2025 15:37:41 -0800 Subject: [PATCH 10/14] xfs/449: update test to know about xfs_db -R From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976216.1928798.18232305078880656112.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong The realtime groups feature added a -R flag to xfs_db so that users can pass in the realtime device. Since we've now modified the _scratch_xfs_db to use this facility, we can update the test to do exact comparisons of the xfs_db info command against the mkfs output. Signed-off-by: "Darrick J. Wong" --- tests/xfs/449 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/xfs/449 b/tests/xfs/449 index 3d528e03a483fb..a739df50e319c5 100755 --- a/tests/xfs/449 +++ b/tests/xfs/449 @@ -30,7 +30,11 @@ echo DB >> $seqres.full cat $tmp.dbinfo >> $seqres.full # xfs_db doesn't take a rtdev argument, so it reports "realtime=external". # mkfs does, so make a quick substitution -diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external extsz=/g') $tmp.dbinfo +if $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev'; then + diff -u $tmp.mkfs $tmp.dbinfo +else + diff -u <(cat $tmp.mkfs | sed -e 's/realtime =\/.*extsz=/realtime =external extsz=/g') $tmp.dbinfo +fi _scratch_mount From patchwork Thu Jan 16 23:37:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942707 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A786F1F3FD5; Thu, 16 Jan 2025 23:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070677; cv=none; b=l97/PTYoj55QWWIDFCsPvZpM+3rqZxxpxk2kqELIUQPa/FbD6sepLEaVORwpaxwdBHTDIi3H655t3Zi3AR7CCHorj2I4TftnJAvvi9mz32X2PfCbYFPyC6Yg4U0/2AswwHiJW3h7LMs2Qb3hT4T4LjuKp8spR7V/ksvv3OUOQeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070677; c=relaxed/simple; bh=NHQjM9TWFExQ7V97IMv5MRWE4QOHhBt36m+LGrRRNV0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TsxjzGZulT8C/1+Db8Klvdf3DsoXO8iW9GxW3GvA8tZ3m025q16LihK6t7Q+h+dmE5SrUTpCERR+dcjLR+ZtsDMWl2Ezet8UnCX/kGteL2lpLu4ON7H25TtMG7MCnWikVFQZg2wrEgcp4xBZ915qpoUkyciWmTRely97+zZp7JU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uG9dLFhs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uG9dLFhs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34E41C4CED6; Thu, 16 Jan 2025 23:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070677; bh=NHQjM9TWFExQ7V97IMv5MRWE4QOHhBt36m+LGrRRNV0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=uG9dLFhsqXFcoKZf2bNUVCKTW+SDPpnI+hCwr3Yuaf63wgKpKbJANxRqbukUtprHj 1ah6TydS9jvgMIiStL5N+xAlP+PytKSswnIfTF/yksF38ty3MJa0cQ5ovKbkC9yJN+ FRECMPAQK3fruucQywe+m0B+wb6+1mgIZr6zHBwM1+Sb8KFaqXrmSyNW4r2jz2o2SQ QWUHObTrvGeDpWlGy69ZxtlXBVLFs3U5zdGsHOrgVRapJskDy7aJ2W7WWm9gqrAqk3 KOk55gAbouO+dqZ7C9Ose46le5qeRrzZKBM6is2ZiGOfp0sQacp2rRnC5yOyAY0wMN Y89Ip2s+xbI+Q== Date: Thu, 16 Jan 2025 15:37:56 -0800 Subject: [PATCH 11/14] xfs/271,xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976231.1928798.8963336797307739220.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Fix these tests to deal with the xfs_io bmap and fsmap commands printing out realtime group numbers if the feature is enabled. Signed-off-by: "Darrick J. Wong" --- common/xfs | 7 +++++++ tests/xfs/271 | 4 +++- tests/xfs/556 | 16 ++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/common/xfs b/common/xfs index 6e2070b5647b38..744785279df97b 100644 --- a/common/xfs +++ b/common/xfs @@ -419,6 +419,13 @@ _xfs_has_feature() feat="rtextents" feat_regex="[1-9][0-9]*" ;; + "rtgroups") + # any fs with rtgroups enabled will have a nonzero rt group + # size, even if there is no rt device (and hence zero actual + # groups) + feat="rgsize" + feat_regex="[1-9][0-9]*" + ;; esac local answer="$($XFS_INFO_PROG "$fs" 2>&1 | grep -E -w -c "$feat=$feat_regex")" diff --git a/tests/xfs/271 b/tests/xfs/271 index 420f4e7479220a..8a71746d6eaede 100755 --- a/tests/xfs/271 +++ b/tests/xfs/271 @@ -29,6 +29,8 @@ _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount agcount=$(_xfs_mount_agcount $SCRATCH_MNT) +agcount_wiggle=0 +_xfs_has_feature $SCRATCH_MNT rtgroups && agcount_wiggle=1 # mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt, # rmapbt, refcountbt, and then allocates AGFL blocks. Since GETFSMAP has the @@ -46,7 +48,7 @@ cat $TEST_DIR/fsmap >> $seqres.full echo "Check AG header" | tee -a $seqres.full grep 'static fs metadata[[:space:]]*[0-9]*[[:space:]]*(0\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout -_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v +_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount $agcount_wiggle -v echo "Check freesp/rmap btrees" | tee -a $seqres.full grep 'per-AG metadata[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout diff --git a/tests/xfs/556 b/tests/xfs/556 index 79e03caf40a0a5..83d5022e700c8b 100755 --- a/tests/xfs/556 +++ b/tests/xfs/556 @@ -45,16 +45,20 @@ victim=$SCRATCH_MNT/a file_blksz=$(_get_file_block_size $SCRATCH_MNT) $XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((4 * file_blksz))" -c "fsync" $victim >> $seqres.full unset errordev -_xfs_is_realtime_file $victim && errordev="RT" + +awk_len_prog='{print $6}' +if _xfs_is_realtime_file $victim; then + if ! _xfs_has_feature $SCRATCH_MNT rtgroups; then + awk_len_prog='{print $4}' + fi + errordev="RT" +fi bmap_str="$($XFS_IO_PROG -c "bmap -elpv" $victim | grep "^[[:space:]]*0:")" echo "$errordev:$bmap_str" >> $seqres.full phys="$(echo "$bmap_str" | $AWK_PROG '{print $3}')" -if [ "$errordev" = "RT" ]; then - len="$(echo "$bmap_str" | $AWK_PROG '{print $4}')" -else - len="$(echo "$bmap_str" | $AWK_PROG '{print $6}')" -fi +len="$(echo "$bmap_str" | $AWK_PROG "$awk_len_prog")" + fs_blksz=$(_get_block_size $SCRATCH_MNT) echo "file_blksz:$file_blksz:fs_blksz:$fs_blksz" >> $seqres.full kernel_sectors_per_fs_block=$((fs_blksz / 512)) From patchwork Thu Jan 16 23:38:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942708 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F34DA1F91DB; Thu, 16 Jan 2025 23:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070693; cv=none; b=aQN0ju3svuFaS1x+5tOKdikOwPDkCCP/869Inls+lEnZxt2dlh2RTP8+euCJ7j6WutsR6tSfgoxIInsyi4ZifMJLTek2i2kPiM3juC3aPcPymghMEUfdv0k1irEDEKXnEs9r+kWOOB0kXJTFskwQbMfLH6G7MQ0FKMwI0ZLpx8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070693; c=relaxed/simple; bh=BhadfMJ8TmXsL/TuzqaIyLDi1yHk20PYFa/skS+Haok=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FKGDBWw+8whwWXMEAFYH2Fjr28BdAhBmUu8NrXMxLStLzYZWlw08zo/x0lafPvMb7zAqGRaJub/c1vopMkbCvEPVrG6zJmHmK366lninkUvL0EvtjTvqq+Z661AA1OGlAyiN0Xz5VNGt4cX11Y9f6M4iBCGYe+QgQzs6rGifbeM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GkUhjxkI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GkUhjxkI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8EBFC4CED6; Thu, 16 Jan 2025 23:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070692; bh=BhadfMJ8TmXsL/TuzqaIyLDi1yHk20PYFa/skS+Haok=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=GkUhjxkIkX55b8FjHFfWKa42Am7V7Q41ISCJEFZsGlU3my2KrU9UPxCLHjLT0NZQW 4q8pMneuzLZngBq6xcxofnobUNf8qgtHLqDLdqDc7sQJeKWDx4ZmgeuC1/je50yqVI j5K5fiWRDFJhi9BFoQjVupiZ135wtyfJSm/20Y+KgpRYbGYBvP/NUg2BwlMBNQDK4H pDMOAQ5rNqEg5PUKoicvNPHL4+hEjLbNueOfVr2YN6a6SzAgMzGEtYXo/y0Gy/PyeE PqX5RP7OBXQAmZF3GHGzSb6TMPmknx8TUTcOGwCoPfT9BxFwXVUlBP/RqDbuZDWnAN 53RP5RJNbp7BA== Date: Thu, 16 Jan 2025 15:38:12 -0800 Subject: [PATCH 12/14] common/xfs: capture realtime devices during metadump/mdrestore From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976247.1928798.10688828222606951604.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong If xfs_metadump supports the -r switch to capture the contents of realtime devices and there is a realtime device, add the option to the command line to enable preservation. Similarly, if the dump file could restore to an external scratch rtdev, pass the -r option to mdrestore so that we can restore rtdev contents. Signed-off-by: "Darrick J. Wong" --- common/metadump | 22 ++++++++++++++++++---- common/populate | 6 +++++- common/xfs | 48 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/common/metadump b/common/metadump index a4ec9a7f921acf..61ba3cbb91647c 100644 --- a/common/metadump +++ b/common/metadump @@ -27,6 +27,7 @@ _xfs_cleanup_verify_metadump() if [ -n "$XFS_METADUMP_IMG" ]; then [ -b "$METADUMP_DATA_LOOP_DEV" ] && _destroy_loop_device $METADUMP_DATA_LOOP_DEV [ -b "$METADUMP_LOG_LOOP_DEV" ] && _destroy_loop_device $METADUMP_LOG_LOOP_DEV + [ -b "$METADUMP_RT_LOOP_DEV" ] && _destroy_loop_device $METADUMP_RT_LOOP_DEV for img in "$XFS_METADUMP_IMG"*; do test -e "$img" && rm -f "$img" done @@ -101,6 +102,7 @@ _xfs_verify_metadump_v2() local version="-v 2" local data_img="$XFS_METADUMP_IMG.data" local log_img="" + local rt_img="" # Capture metadump, which creates metadump_file _scratch_xfs_metadump $metadump_file $metadump_args $version @@ -111,8 +113,12 @@ _xfs_verify_metadump_v2() # from such a metadump file. test -n "$SCRATCH_LOGDEV" && log_img="$XFS_METADUMP_IMG.log" + # Use a temporary file to hold restored rt device contents + test -n "$SCRATCH_RTDEV" && _xfs_metadump_supports_rt && \ + rt_img="$XFS_METADUMP_IMG.rt" + # Restore metadump, which creates data_img and log_img - SCRATCH_DEV=$data_img SCRATCH_LOGDEV=$log_img \ + SCRATCH_DEV=$data_img SCRATCH_LOGDEV=$log_img SCRATCH_RTDEV=$rt_img \ _scratch_xfs_mdrestore $metadump_file # Create loopdev for data device so we can mount the fs @@ -121,12 +127,15 @@ _xfs_verify_metadump_v2() # Create loopdev for log device if we recovered anything test -s "$log_img" && METADUMP_LOG_LOOP_DEV=$(_create_loop_device $log_img) + # Create loopdev for rt device if we recovered anything + test -s "$rt_img" && METADUMP_RT_LOOP_DEV=$(_create_loop_device $rt_img) + # Mount fs, run an extra test, fsck, and unmount - SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV _scratch_mount + SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV SCRATCH_RTDEV=$METADUMP_RT_LOOP_DEV _scratch_mount if [ -n "$extra_test" ]; then - SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV $extra_test + SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV SCRATCH_RTDEV=$METADUMP_RT_LOOP_DEV $extra_test fi - SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV _check_xfs_scratch_fs + SCRATCH_DEV=$METADUMP_DATA_LOOP_DEV SCRATCH_LOGDEV=$METADUMP_LOG_LOOP_DEV SCRATCH_RTDEV=$METADUMP_RT_LOOP_DEV _check_xfs_scratch_fs _unmount $METADUMP_DATA_LOOP_DEV # Tear down what we created @@ -135,6 +144,11 @@ _xfs_verify_metadump_v2() unset METADUMP_LOG_LOOP_DEV rm -f $log_img fi + if [ -b "$METADUMP_RT_LOOP_DEV" ]; then + _destroy_loop_device $METADUMP_RT_LOOP_DEV + unset METADUMP_RT_LOOP_DEV + rm -f $rt_img + fi _destroy_loop_device $METADUMP_DATA_LOOP_DEV unset METADUMP_DATA_LOOP_DEV rm -f $data_img diff --git a/common/populate b/common/populate index 96fc13875df503..9c3d49efebb3a4 100644 --- a/common/populate +++ b/common/populate @@ -1048,12 +1048,16 @@ _scratch_populate_save_metadump() [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ logdev=$SCRATCH_LOGDEV + local rtdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + mdargs=('-a' '-o') test "$(_xfs_metadump_max_version)" -gt 1 && \ mdargs+=('-v' '2') _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ - compress "${mdargs[@]}" + "$rtdev" compress "${mdargs[@]}" res=$? ;; "ext2"|"ext3"|"ext4") diff --git a/common/xfs b/common/xfs index 744785279df97b..81b080b7d8088f 100644 --- a/common/xfs +++ b/common/xfs @@ -625,14 +625,19 @@ _xfs_metadump() { local metadump="$1" local device="$2" local logdev="$3" - local compressopt="$4" - shift; shift; shift; shift + local rtdev="$4" + local compressopt="$5" + shift; shift; shift; shift; shift local options="$@" if [ "$logdev" != "none" ]; then options="$options -l $logdev" fi + if [ "$rtdev" != "none" ] && _xfs_metadump_supports_rt; then + options="$options -r $rtdev" + fi + $XFS_METADUMP_PROG $options "$device" "$metadump" res=$? [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] && @@ -656,7 +661,8 @@ _xfs_mdrestore() { local metadump="$1" local device="$2" local logdev="$3" - shift; shift; shift + local rtdev="$4" + shift; shift; shift; shift local options="$@" local dumpfile_ver @@ -684,6 +690,18 @@ _xfs_mdrestore() { options="$options -l $logdev" fi + if [ "$rtdev" != "none" ] && [[ $dumpfile_ver > 1 ]] && _xfs_metadump_supports_rt; then + # metadump and mdrestore capture and restore metadata on the + # realtime volume by turning on metadump v2 format. This is + # only done if the realtime volume contains metadata such as + # rtgroup superblocks. The -r option to mdrestore wasn't added + # until the creation of rtgroups. + # + # Hence it only makes sense to specify -r here if the dump file + # itself is in v2 format. + options="$options -r $rtdev" + fi + $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" } @@ -697,17 +715,27 @@ _xfs_metadump_max_version() fi } +# Do xfs_metadump/mdrestore support the -r switch for realtime devices? +_xfs_metadump_supports_rt() +{ + $XFS_METADUMP_PROG --help 2>&1 | grep -q -- '-r rtdev' +} + # Snapshot the metadata on the scratch device _scratch_xfs_metadump() { local metadump=$1 shift local logdev=none + local rtdev=none [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ logdev=$SCRATCH_LOGDEV - _xfs_metadump "$metadump" "$SCRATCH_DEV" "$logdev" nocompress "$@" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + + _xfs_metadump "$metadump" "$SCRATCH_DEV" "$logdev" "$rtdev" nocompress "$@" } # Restore snapshotted metadata on the scratch device @@ -716,6 +744,7 @@ _scratch_xfs_mdrestore() local metadump=$1 shift local logdev=none + local rtdev=none local options="$@" # $SCRATCH_LOGDEV should have a non-zero length value only when all of @@ -726,7 +755,10 @@ _scratch_xfs_mdrestore() logdev=$SCRATCH_LOGDEV fi - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$logdev" "$@" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + rtdev=$SCRATCH_RTDEV + + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$logdev" "$rtdev" "$@" } # Do not use xfs_repair (offline fsck) to rebuild the filesystem @@ -847,7 +879,7 @@ _check_xfs_filesystem() if [ "$ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.check.md" "$device" "$logdev" \ - compress -a -o >> $seqres.full + "$rtdev" compress -a -o >> $seqres.full fi # Optionally test the index rebuilding behavior. @@ -880,7 +912,7 @@ _check_xfs_filesystem() if [ "$rebuild_ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.rebuild.md" "$device" \ - "$logdev" compress -a -o >> $seqres.full + "$logdev" "$rtdev" compress -a -o >> $seqres.full fi fi @@ -964,7 +996,7 @@ _check_xfs_filesystem() if [ "$orebuild_ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.orebuild.md" "$device" \ - "$logdev" compress -a -o >> $seqres.full + "$logdev" "$rtdev" compress -a -o >> $seqres.full fi fi From patchwork Thu Jan 16 23:38:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942709 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0A8B1F91DB; Thu, 16 Jan 2025 23:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070708; cv=none; b=GG+2UF0BWdf4WtTv/GDYRWUg7Mg8ouLVqJvwU7zXubJ5CinmlDObYKDiLY9J7BwEWNrxTCr5HDHhCV/1OReX2Q7IgCaXrZIwM4eSVAnsC4v98qtAhaRU8UTq+vC30lnLAW27mYzy5LJYmr6IiGH1l43n0VDjHlP8bwtcyJc1q9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070708; c=relaxed/simple; bh=/ZBsD2Xwg5ru18V7PNt7LuHytPGayJg1zYiqDPCF4kI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BYSwHtoP8mfd/LbpdnMSzYk53G60sz0AD2nPOZKaKyqG+2+ObOwstgBz9+6Yt3EIq9wtJNaXXdIhKsXx3OEjX0bnuS3E4qZOgKgw//1TsfLJBXe1A/RqeZKnMe+mGRXAubf2+bPORwtnTfMWvO0bxNUg6AQbBAVzWwBEumsCoxA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oFwcC32l; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oFwcC32l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74565C4CED6; Thu, 16 Jan 2025 23:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070708; bh=/ZBsD2Xwg5ru18V7PNt7LuHytPGayJg1zYiqDPCF4kI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=oFwcC32lhI+XvOOy6SLKx0DrQTg88/LJ+/595JTMsMEQFAAmP6MfLOJ0DQjn68zk1 AMXYSsKE9+Sty9gDdVpopFErWTIoAU7um5+ururKQLpAJN9SYTg15m5jyxYKNxT/09 VFs6LnhTsCgf1TXxF2MnFArsv+NEd3HW9tQ7K0TQYawDcEVOvV/udUBYNukkI1bnXe bFzs/dDDsk0q6ptEccIq6rnXQqLvN7GrlRfRYx6WsRkjzm43LiJ4Cd9aNMscrwS53Q u9ewuc4ugPgBTGMojCL9h2yF/jDnyTz8ztL1k26cboYIto+MhfcQWDCoQgdBHKTSjQ CJNRJWO2k1Nkg== Date: Thu, 16 Jan 2025 15:38:27 -0800 Subject: [PATCH 13/14] common/fuzzy: adapt the scrub stress tests to support rtgroups From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976263.1928798.8062426953705413541.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Adapt the scrub stress testing framework to support checking realtime group metadata. Signed-off-by: "Darrick J. Wong" --- common/fuzzy | 27 ++++++++++++++++++++++----- common/xfs | 9 +++++++++ tests/xfs/581 | 2 +- tests/xfs/720 | 2 +- tests/xfs/795 | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/common/fuzzy b/common/fuzzy index a7e28dda137e8a..ad28ba9275a09f 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -829,8 +829,10 @@ __stress_one_scrub_loop() { local scrub_tgt="$3" local scrub_startat="$4" local start_agno="$5" - shift; shift; shift; shift; shift + local start_rgno="$6" + shift; shift; shift; shift; shift; shift local agcount="$(_xfs_mount_agcount $SCRATCH_MNT)" + local rgcount="$(_xfs_mount_rgcount $SCRATCH_MNT)" local xfs_io_args=() for arg in "$@"; do @@ -843,6 +845,12 @@ __stress_one_scrub_loop() { local ag_arg="$(echo "$arg" | sed -e "s|%agno%|$agno|g")" xfs_io_args+=('-c' "$ag_arg") done + elif echo "$arg" | grep -q -w '%rgno%'; then + # Substitute the rtgroup number + for ((rgno = start_rgno; rgno < rgcount; rgno++)); do + local rg_arg="$(echo "$arg" | sed -e "s|%rgno%|$rgno|g")" + xfs_io_args+=('-c' "$rg_arg") + done else xfs_io_args+=('-c' "$arg") fi @@ -1273,7 +1281,9 @@ _scratch_xfs_stress_scrub_cleanup() { __stress_scrub_check_commands() { local scrub_tgt="$1" local start_agno="$2" - shift; shift + local start_rgno="$3" + shift; shift; shift + local rgcount="$(_xfs_mount_rgcount $SCRATCH_MNT)" local cooked_tgt="$scrub_tgt" case "$scrub_tgt" in @@ -1303,6 +1313,10 @@ __stress_scrub_check_commands() { cooked_arg="$(echo "$cooked_arg" | sed -e 's/^repair/repair -R/g')" fi cooked_arg="$(echo "$cooked_arg" | sed -e "s/%agno%/$start_agno/g")" + if echo "$cooked_arg" | grep -q -w '%rgno%'; then + test "$rgcount" -eq 0 && continue + cooked_arg="$(echo "$cooked_arg" | sed -e "s/%rgno%/$start_rgno/g")" + fi testio=`$XFS_IO_PROG -x -c "$cooked_arg" "$cooked_tgt" 2>&1` echo $testio | grep -q "Unknown type" && \ _notrun "xfs_io scrub subcommand support is missing" @@ -1328,6 +1342,7 @@ __stress_scrub_check_commands() { # in a separate loop. If zero -i options are specified, do not run. # Callers must check each of these commands (via _require_xfs_io_command) # before calling here. +# -R For %rgno% substitution, start with this rtgroup instead of rtgroup 0. # -r Run fsstress for this amount of time, then remount the fs ro or rw. # The default is to run fsstress continuously with no remount, unless # XFS_SCRUB_STRESS_REMOUNT_PERIOD is set. @@ -1374,6 +1389,7 @@ _scratch_xfs_stress_scrub() { local remount_period="${XFS_SCRUB_STRESS_REMOUNT_PERIOD}" local stress_tgt="${XFS_SCRUB_STRESS_TARGET:-default}" local start_agno=0 + local start_rgno=0 __SCRUB_STRESS_FREEZE_PID="" __SCRUB_STRESS_REMOUNT_LOOP="" @@ -1381,12 +1397,13 @@ _scratch_xfs_stress_scrub() { touch "$runningfile" OPTIND=1 - while getopts "a:fi:r:s:S:t:w:x:X:" c; do + while getopts "a:fi:r:R:s:S:t:w:x:X:" c; do case "$c" in a) start_agno="$OPTARG";; f) freeze=yes;; i) io_args+=("$OPTARG");; r) remount_period="$OPTARG";; + R) start_rgno="$OPTARG";; s) one_scrub_args+=("$OPTARG");; S) xfs_scrub_args+=("$OPTARG");; t) scrub_tgt="$OPTARG";; @@ -1397,7 +1414,7 @@ _scratch_xfs_stress_scrub() { esac done - __stress_scrub_check_commands "$scrub_tgt" "$start_agno" \ + __stress_scrub_check_commands "$scrub_tgt" "$start_agno" "$start_rgno" \ "${one_scrub_args[@]}" if ! command -v "__stress_scrub_${exerciser}_loop" &>/dev/null; then @@ -1458,7 +1475,7 @@ _scratch_xfs_stress_scrub() { if [ "${#one_scrub_args[@]}" -gt 0 ]; then __stress_one_scrub_loop "$end" "$runningfile" "$scrub_tgt" \ - "$scrub_startat" "$start_agno" \ + "$scrub_startat" "$start_agno" "$start_rgno" \ "${one_scrub_args[@]}" & fi diff --git a/common/xfs b/common/xfs index 81b080b7d8088f..49fb2ea7e7894e 100644 --- a/common/xfs +++ b/common/xfs @@ -1496,6 +1496,15 @@ _xfs_mount_agcount() $XFS_INFO_PROG "$1" | sed -n "s/^.*agcount=\([[:digit:]]*\).*/\1/p" } +# Find rtgroup count of mounted filesystem +_xfs_mount_rgcount() +{ + local rtgroups="$($XFS_INFO_PROG "$1" | grep rgcount= | sed -e 's/^.*rgcount=\([0-9]*\).*$/\1/g')" + + test -z "$rtgroups" && rtgroups=0 + echo "$rtgroups" +} + # Wipe the superblock of each XFS AGs _try_wipe_scratch_xfs() { diff --git a/tests/xfs/581 b/tests/xfs/581 index 39eb42da4b10c5..6aa360b37b90c5 100755 --- a/tests/xfs/581 +++ b/tests/xfs/581 @@ -30,7 +30,7 @@ _require_xfs_stress_scrub _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount _require_xfs_has_feature "$SCRATCH_MNT" realtime -_scratch_xfs_stress_scrub -s "scrub rtbitmap" +_scratch_xfs_stress_scrub -s "scrub rtbitmap" -s "scrub rgbitmap %rgno%" # success, all done echo Silence is golden diff --git a/tests/xfs/720 b/tests/xfs/720 index 68a6c7f6e2d584..97b3d2579cbd7f 100755 --- a/tests/xfs/720 +++ b/tests/xfs/720 @@ -37,7 +37,7 @@ alloc_unit=$(_get_file_block_size $SCRATCH_MNT) scratchfile=$SCRATCH_MNT/file touch $scratchfile $XFS_IO_PROG -x -c 'inject force_repair' $SCRATCH_MNT -__stress_scrub_check_commands "$scratchfile" "" 'repair bmapbtd' +__stress_scrub_check_commands "$scratchfile" "" "" 'repair bmapbtd' # Compute the number of extent records needed to guarantee btree format, # assuming 16 bytes for each ondisk extent record diff --git a/tests/xfs/795 b/tests/xfs/795 index 217f96092a4c42..e7004705b526a5 100755 --- a/tests/xfs/795 +++ b/tests/xfs/795 @@ -37,7 +37,7 @@ scratchfile=$SCRATCH_MNT/file mkdir $scratchdir touch $scratchfile $XFS_IO_PROG -x -c 'inject force_repair' $SCRATCH_MNT -__stress_scrub_check_commands "$scratchdir" "" 'repair directory' +__stress_scrub_check_commands "$scratchdir" "" "" 'repair directory' # Create a 2-dirblock directory total_size=$((alloc_unit * 2)) From patchwork Thu Jan 16 23:38:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13942710 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 417131F91D4; Thu, 16 Jan 2025 23:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070724; cv=none; b=B7K+yYVHACK/mtIvL2SQHW2A+sjnCn6IM5lXyJ9m8qgCoBGUSjUjJPLOTOpMqxNXWuCAoRHCKKfnJFAWMW8ol5Amz08IPDa/xbWNQOm27S6o1d5EythONBI4m80ZKFrbPgnQ498CPeMAWKAHhOoqfJSXHV0IPQ3p7FNTcAASCCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737070724; c=relaxed/simple; bh=KpyB4PUV2mWZYH4zeUxxOw+bvtin+sw/bMUjNntUZoE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nuT7UHH5biwnwyx+BY1mKiR+5+b+IfWopvCsirkgmVXdmGQkmQUZARzscfYPU8KuygQSXjO5jRwfKswENqsCeG8mwpjn1nw04t15t9hx8tmu2PwN9pjiHu31nZmCY1I/VsE0mASBNnmeBorXHzekUgRugIiN6NvgV5Jdq8L7AIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KgEDG54I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KgEDG54I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DFBCC4CED6; Thu, 16 Jan 2025 23:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737070724; bh=KpyB4PUV2mWZYH4zeUxxOw+bvtin+sw/bMUjNntUZoE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=KgEDG54I0s9Kw/GGb8k4sEDWfSg0+7Ux5wjgyn926MlgRGpUHI+1OkByuFOIM8lSO hsNwvyjh9vk8p3M2ujNgU88sBhu/QB7kNON3SfcCIADTA9BoHfWSFpbYhaWf4JkiVr zYbjjb7+SwZ/2spNCHsqY1jm8KKo8m/mg89k8bpbWIEblhWD51ab5NSXxSjdhG8CNx NORRKCHnK/2PBVjRBfM+v9I1INNna1P+/zE52/324Gq3gFFbeUmkt1/Utjn26QZ+89 9TGnyJmmb25iZ6sWaKlyFFfzj3JhWdhGAK9PvUoQjrEe4Qy7ShwACEX3x0dH7lVhAb CTNCISsJ9D3qw== Date: Thu, 16 Jan 2025 15:38:43 -0800 Subject: [PATCH 14/14] xfs: fix fuzz tests of rtgroups bitmap and summary files From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: hch@lst.de, fstests@vger.kernel.org, linux-xfs@vger.kernel.org Message-ID: <173706976278.1928798.16957823477897463484.stgit@frogsfrogsfrogs> In-Reply-To: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> References: <173706976044.1928798.958381010294853384.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong With rtgroups, the rt bitmap and summary files are now per-group, so adjust the fuzz and fsck tests to find the new locations. Signed-off-by: "Darrick J. Wong" --- common/xfs | 19 +++++++++++++++++++ tests/xfs/581 | 9 ++++++++- tests/xfs/582 | 14 +++++++------- tests/xfs/739 | 6 +++++- tests/xfs/740 | 6 +++++- tests/xfs/741 | 6 +++++- tests/xfs/742 | 6 +++++- tests/xfs/743 | 6 +++++- tests/xfs/744 | 6 +++++- tests/xfs/745 | 6 +++++- tests/xfs/746 | 6 +++++- tests/xfs/793 | 14 +++++++------- 12 files changed, 81 insertions(+), 23 deletions(-) diff --git a/common/xfs b/common/xfs index 49fb2ea7e7894e..aa635f8b4745fa 100644 --- a/common/xfs +++ b/common/xfs @@ -1956,6 +1956,25 @@ _scratch_xfs_find_metafile() local metafile="$1" local sb_field + # With metadir=1, the realtime volume is sharded into allocation + # groups. Each rtgroup has its own bitmap and summary file. Tests + # should pick a particular file, but this compatibility shim still + # exists to keep old tests working. + case "$metafile" in + "rbmino") + if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + echo "path -m /rtgroups/0.bitmap" + return 0 + fi + ;; + "rsumino") + if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + echo "path -m /rtgroups/0.summary" + return 0 + fi + ;; + esac + sb_field="$(_scratch_xfs_get_sb_field "$metafile")" if echo "$sb_field" | grep -q -w 'not found'; then return 1 diff --git a/tests/xfs/581 b/tests/xfs/581 index 6aa360b37b90c5..7d79dbcad70149 100755 --- a/tests/xfs/581 +++ b/tests/xfs/581 @@ -30,7 +30,14 @@ _require_xfs_stress_scrub _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount _require_xfs_has_feature "$SCRATCH_MNT" realtime -_scratch_xfs_stress_scrub -s "scrub rtbitmap" -s "scrub rgbitmap %rgno%" + +if _xfs_has_feature "$SCRATCH_MNT" rtgroups; then + _scratch_xfs_stress_scrub -s "scrub rtbitmap %rgno%" +elif xfs_io -c 'help scrub' | grep -q rgsuper; then + _scratch_xfs_stress_scrub -s "scrub rtbitmap 0" +else + _scratch_xfs_stress_scrub -s "scrub rtbitmap" +fi # success, all done echo Silence is golden diff --git a/tests/xfs/582 b/tests/xfs/582 index e92f128f8a5695..a2cc58c04bf8d2 100755 --- a/tests/xfs/582 +++ b/tests/xfs/582 @@ -31,13 +31,13 @@ _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount _require_xfs_has_feature "$SCRATCH_MNT" realtime -# XXX the realtime summary scrubber isn't currently implemented upstream. -# Don't bother trying to test it on those kernels -$XFS_IO_PROG -c 'scrub rtsummary' -c 'scrub rtsummary' "$SCRATCH_MNT" 2>&1 | \ - grep -q 'Scan was not complete' && \ - _notrun "rtsummary scrub is incomplete" - -_scratch_xfs_stress_scrub -s "scrub rtsummary" +if _xfs_has_feature "$SCRATCH_MNT" rtgroups; then + _scratch_xfs_stress_scrub -s "scrub rtsummary %rgno%" +elif xfs_io -c 'help scrub' | grep -q rgsuper; then + _scratch_xfs_stress_scrub -s "scrub rtsummary 0" +else + _scratch_xfs_stress_scrub -s "scrub rtsummary" +fi # success, all done echo Silence is golden diff --git a/tests/xfs/739 b/tests/xfs/739 index 5fd6caa5bce2f8..77cceac7ac7f02 100755 --- a/tests/xfs/739 +++ b/tests/xfs/739 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -path="$(_scratch_xfs_find_metafile rbmino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.bitmap" +else + path="$(_scratch_xfs_find_metafile rbmino)" +fi _scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" diff --git a/tests/xfs/740 b/tests/xfs/740 index c8990034773b32..fe5d054956d5e2 100755 --- a/tests/xfs/740 +++ b/tests/xfs/740 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -path="$(_scratch_xfs_find_metafile rsumino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.summary" +else + path="$(_scratch_xfs_find_metafile rsumino)" +fi _scratch_xfs_fuzz_metadata '' 'online' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" diff --git a/tests/xfs/741 b/tests/xfs/741 index 96c2315c524311..35f78aab7faead 100755 --- a/tests/xfs/741 +++ b/tests/xfs/741 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -path="$(_scratch_xfs_find_metafile rbmino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.bitmap" +else + path="$(_scratch_xfs_find_metafile rbmino)" +fi _scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" diff --git a/tests/xfs/742 b/tests/xfs/742 index 301ae7b9574320..04087c1a224558 100755 --- a/tests/xfs/742 +++ b/tests/xfs/742 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -path="$(_scratch_xfs_find_metafile rsumino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.summary" +else + path="$(_scratch_xfs_find_metafile rsumino)" +fi _scratch_xfs_fuzz_metadata '' 'offline' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" diff --git a/tests/xfs/743 b/tests/xfs/743 index 039624f711c0a6..1e70147fa3bcef 100755 --- a/tests/xfs/743 +++ b/tests/xfs/743 @@ -26,7 +26,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -path="$(_scratch_xfs_find_metafile rbmino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.bitmap" +else + path="$(_scratch_xfs_find_metafile rbmino)" +fi _scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" diff --git a/tests/xfs/744 b/tests/xfs/744 index 13f63b9ceb1756..0db3dd617c2d1f 100755 --- a/tests/xfs/744 +++ b/tests/xfs/744 @@ -26,7 +26,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -path="$(_scratch_xfs_find_metafile rsumino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.summary" +else + path="$(_scratch_xfs_find_metafile rsumino)" +fi _scratch_xfs_fuzz_metadata '' 'both' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" diff --git a/tests/xfs/745 b/tests/xfs/745 index 56a6d58ef9f4ca..acfbe72597fd5a 100755 --- a/tests/xfs/745 +++ b/tests/xfs/745 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtbitmap" -path="$(_scratch_xfs_find_metafile rbmino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.bitmap" +else + path="$(_scratch_xfs_find_metafile rbmino)" +fi _scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtbitmap" diff --git a/tests/xfs/746 b/tests/xfs/746 index 935b2e5acba5d4..0d1ab895aacd62 100755 --- a/tests/xfs/746 +++ b/tests/xfs/746 @@ -25,7 +25,11 @@ echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 echo "Fuzz rtsummary" -path="$(_scratch_xfs_find_metafile rsumino)" +if _xfs_has_feature "$SCRATCH_DEV" rtgroups; then + path="path -m /rtgroups/0.summary" +else + path="$(_scratch_xfs_find_metafile rsumino)" +fi _scratch_xfs_fuzz_metadata '' 'none' "$path" 'dblock 0' >> $seqres.full echo "Done fuzzing rtsummary" diff --git a/tests/xfs/793 b/tests/xfs/793 index a779bf81738537..07c64e7a3f9744 100755 --- a/tests/xfs/793 +++ b/tests/xfs/793 @@ -32,13 +32,13 @@ _scratch_mount _require_xfs_has_feature "$SCRATCH_MNT" realtime _xfs_force_bdev realtime $SCRATCH_MNT -# XXX the realtime summary scrubber isn't currently implemented upstream. -# Don't bother trying to fix it on those kernels -$XFS_IO_PROG -c 'scrub rtsummary' -c 'scrub rtsummary' "$SCRATCH_MNT" 2>&1 | \ - grep -q 'Scan was not complete' && \ - _notrun "rtsummary scrub is incomplete" - -_scratch_xfs_stress_online_repair -s "repair rtsummary" +if _xfs_has_feature "$SCRATCH_MNT" rtgroups; then + _scratch_xfs_stress_online_repair -s "repair rtsummary %rgno%" +elif xfs_io -c 'help scrub' | grep -q rgsuper; then + _scratch_xfs_stress_online_repair -s "repair rtsummary 0" +else + _scratch_xfs_stress_online_repair -s "repair rtsummary" +fi # success, all done echo Silence is golden