From patchwork Wed Aug 3 04:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12935169 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 3D95AC19F2B for ; Wed, 3 Aug 2022 04:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235389AbiHCEVv (ORCPT ); Wed, 3 Aug 2022 00:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233759AbiHCEVu (ORCPT ); Wed, 3 Aug 2022 00:21:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3666854668; Tue, 2 Aug 2022 21:21:49 -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 ams.source.kernel.org (Postfix) with ESMTPS id E70F9B82185; Wed, 3 Aug 2022 04:21:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6B92C433D6; Wed, 3 Aug 2022 04:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659500506; bh=eiPQn7cGJWMMHAwHakKJ/wtSzsCU8/1/HqgFWIpiSmA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=i3v+Wc6TM34LYI7KO3U6TUwAFhlGVZRM5PsHre/qPVkJLbT4fbCHRNDkC0VNwu0+C lKSr1tCiZZ4eT23iugFTfIcW331ZkwxvJTqrEj5xyUnHyxrE+G3446S5o6uYAq+Qet /WLEBccmxSim5Lne3J1OlEKJP/U87dLLoWDC+DOrKL0iWEbcmdHk9c5mMwyHDAJccu U/NpwqCpBDex2waT3vmZNfdUtgXH89P/BVYJRgxLqWIA4G+ieR31DWmCYr2EARkM/a +L850vAgt7/EfqC3ukftV4EXU9L9hngalkpeosoCxgA5OPESI17tLM/HzYekH6ZKiP Uu74oBm7LrANA== Subject: [PATCH 1/3] common/rc: move ext4-specific helpers into a separate common/ext4 file From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me, tytso@mit.edu, linux-ext4@vger.kernel.org Date: Tue, 02 Aug 2022 21:21:46 -0700 Message-ID: <165950050620.198922.11008917970026033609.stgit@magnolia> In-Reply-To: <165950050051.198922.13423077997881086438.stgit@magnolia> References: <165950050051.198922.13423077997881086438.stgit@magnolia> 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 Move the ext4-specific parts of common/rc into a separate file and source it when we test that. Signed-off-by: Darrick J. Wong --- common/config | 4 + common/ext4 | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/rc | 153 -------------------------------------------------------- 3 files changed, 160 insertions(+), 153 deletions(-) create mode 100644 common/ext4 diff --git a/common/config b/common/config index c30eec6d..5eaae447 100644 --- a/common/config +++ b/common/config @@ -512,6 +512,10 @@ _source_specific_fs() ;; ext4) [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found" + . ./common/ext4 + ;; + ext2|ext3|ext4dev) + . ./common/ext4 ;; f2fs) [ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found" diff --git a/common/ext4 b/common/ext4 new file mode 100644 index 00000000..287705af --- /dev/null +++ b/common/ext4 @@ -0,0 +1,156 @@ +# +# ext4 specific common functions +# + +_setup_large_ext4_fs() +{ + local fs_size=$1 + local tmp_dir=/tmp/ + + [ "$LARGE_SCRATCH_DEV" != yes ] && return 0 + [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0 + [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0 + + # Default free space in the FS is 50GB, but you can specify more via + # SCRATCH_DEV_EMPTY_SPACE + local space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE)) + + # mount the filesystem and create 16TB - 4KB files until we consume + # all the necessary space. + _try_scratch_mount 2>&1 >$tmp_dir/mnt.err + local status=$? + if [ $status -ne 0 ]; then + echo "mount failed" + cat $tmp_dir/mnt.err >&2 + rm -f $tmp_dir/mnt.err + return $status + fi + rm -f $tmp_dir/mnt.err + + local file_size=$((16*1024*1024*1024*1024 - 4096)) + local nfiles=0 + while [ $space_to_consume -gt $file_size ]; do + + xfs_io -F -f \ + -c "truncate $file_size" \ + -c "falloc -k 0 $file_size" \ + $SCRATCH_MNT/.use_space.$nfiles 2>&1 + status=$? + if [ $status -ne 0 ]; then + break; + fi + + space_to_consume=$(( $space_to_consume - $file_size )) + nfiles=$(($nfiles + 1)) + done + + # consume the remaining space. + if [ $space_to_consume -gt 0 ]; then + xfs_io -F -f \ + -c "truncate $space_to_consume" \ + -c "falloc -k 0 $space_to_consume" \ + $SCRATCH_MNT/.use_space.$nfiles 2>&1 + status=$? + fi + export NUM_SPACE_FILES=$nfiles + + _scratch_unmount + if [ $status -ne 0 ]; then + echo "large file prealloc failed" + cat $tmp_dir/mnt.err >&2 + return $status + fi + return 0 +} + +_scratch_mkfs_ext4() +{ + local mkfs_cmd="$MKFS_EXT4_PROG -F" + local mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \" | grep -v \"^$\"" + local tmp=`mktemp -u` + local mkfs_status + + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \ + mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV" + + _scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd + mkfs_status=$? + + if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then + # manually parse the mkfs output to get the fs size in bytes + local fs_size=`cat $tmp.mkfsstd | awk ' \ + /^Block size/ { split($2, a, "="); bs = a[2] ; } \ + / inodes, / { blks = $3 } \ + /reserved for the super user/ { resv = $1 } \ + END { fssize = bs * blks - resv; print fssize }'` + + _setup_large_ext4_fs $fs_size + mkfs_status=$? + fi + + # output mkfs stdout and stderr + cat $tmp.mkfsstd + cat $tmp.mkfserr >&2 + rm -f $tmp.mkfserr $tmp.mkfsstd + + return $mkfs_status +} + +_ext4_metadump() +{ + local device="$1" + local dumpfile="$2" + local compressopt="$3" + + test -n "$E2IMAGE_PROG" || _fail "e2image not installed" + $E2IMAGE_PROG -Q "$device" "$dumpfile" + [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] && + $DUMP_COMPRESSOR -f "$dumpfile" &>> "$seqres.full" +} + +# this test requires the ext4 kernel support crc feature on scratch device +# +_require_scratch_ext4_crc() +{ + _scratch_mkfs_ext4 >/dev/null 2>&1 + dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem" + _try_scratch_mount >/dev/null 2>&1 \ + || _notrun "Kernel doesn't support metadata_csum feature" + _scratch_unmount +} + +# Check whether the specified feature whether it is supported by +# mkfs.ext4 and the kernel. +_require_scratch_ext4_feature() +{ + if [ -z "$1" ]; then + echo "Usage: _require_scratch_ext4_feature feature" + exit 1 + fi + $MKFS_EXT4_PROG -F $MKFS_OPTIONS -O "$1" \ + $SCRATCH_DEV 512m >/dev/null 2>&1 \ + || _notrun "mkfs.ext4 doesn't support $1 feature" + _try_scratch_mount >/dev/null 2>&1 \ + || _notrun "Kernel doesn't support the ext4 feature(s): $1" + _scratch_unmount +} + +# Disable extent zeroing for ext4 on the given device +_ext4_disable_extent_zeroout() +{ + local dev=${1:-$TEST_DEV} + local sdev=`_short_dev $dev` + + [ -f /sys/fs/ext4/$sdev/extent_max_zeroout_kb ] && \ + echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb +} + +_require_scratch_richacl_ext4() +{ + _scratch_mkfs -O richacl >/dev/null 2>&1 \ + || _notrun "can't mkfs $FSTYP with option -O richacl" + _try_scratch_mount >/dev/null 2>&1 \ + || _notrun "kernel doesn't support richacl feature on $FSTYP" + _scratch_unmount +} diff --git a/common/rc b/common/rc index 197c9415..52dd3b41 100644 --- a/common/rc +++ b/common/rc @@ -559,113 +559,6 @@ _scratch_do_mkfs() return $mkfs_status } -_setup_large_ext4_fs() -{ - local fs_size=$1 - local tmp_dir=/tmp/ - - [ "$LARGE_SCRATCH_DEV" != yes ] && return 0 - [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0 - [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0 - - # Default free space in the FS is 50GB, but you can specify more via - # SCRATCH_DEV_EMPTY_SPACE - local space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE)) - - # mount the filesystem and create 16TB - 4KB files until we consume - # all the necessary space. - _try_scratch_mount 2>&1 >$tmp_dir/mnt.err - local status=$? - if [ $status -ne 0 ]; then - echo "mount failed" - cat $tmp_dir/mnt.err >&2 - rm -f $tmp_dir/mnt.err - return $status - fi - rm -f $tmp_dir/mnt.err - - local file_size=$((16*1024*1024*1024*1024 - 4096)) - local nfiles=0 - while [ $space_to_consume -gt $file_size ]; do - - xfs_io -F -f \ - -c "truncate $file_size" \ - -c "falloc -k 0 $file_size" \ - $SCRATCH_MNT/.use_space.$nfiles 2>&1 - status=$? - if [ $status -ne 0 ]; then - break; - fi - - space_to_consume=$(( $space_to_consume - $file_size )) - nfiles=$(($nfiles + 1)) - done - - # consume the remaining space. - if [ $space_to_consume -gt 0 ]; then - xfs_io -F -f \ - -c "truncate $space_to_consume" \ - -c "falloc -k 0 $space_to_consume" \ - $SCRATCH_MNT/.use_space.$nfiles 2>&1 - status=$? - fi - export NUM_SPACE_FILES=$nfiles - - _scratch_unmount - if [ $status -ne 0 ]; then - echo "large file prealloc failed" - cat $tmp_dir/mnt.err >&2 - return $status - fi - return 0 -} - -_scratch_mkfs_ext4() -{ - local mkfs_cmd="$MKFS_EXT4_PROG -F" - local mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \" | grep -v \"^$\"" - local tmp=`mktemp -u` - local mkfs_status - - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ - $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \ - mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV" - - _scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd - mkfs_status=$? - - if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then - # manually parse the mkfs output to get the fs size in bytes - local fs_size=`cat $tmp.mkfsstd | awk ' \ - /^Block size/ { split($2, a, "="); bs = a[2] ; } \ - / inodes, / { blks = $3 } \ - /reserved for the super user/ { resv = $1 } \ - END { fssize = bs * blks - resv; print fssize }'` - - _setup_large_ext4_fs $fs_size - mkfs_status=$? - fi - - # output mkfs stdout and stderr - cat $tmp.mkfsstd - cat $tmp.mkfserr >&2 - rm -f $tmp.mkfserr $tmp.mkfsstd - - return $mkfs_status -} - -_ext4_metadump() -{ - local device="$1" - local dumpfile="$2" - local compressopt="$3" - - test -n "$E2IMAGE_PROG" || _fail "e2image not installed" - $E2IMAGE_PROG -Q "$device" "$dumpfile" - [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] && - $DUMP_COMPRESSOR -f "$dumpfile" &>> "$seqres.full" -} - # Capture the metadata of a filesystem in a dump file for offline analysis. # This is not supported by all filesystem types, so this function should only # be used after a test has already failed. @@ -2245,33 +2138,6 @@ _require_non_zoned_device() fi } -# this test requires the ext4 kernel support crc feature on scratch device -# -_require_scratch_ext4_crc() -{ - _scratch_mkfs_ext4 >/dev/null 2>&1 - dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem" - _try_scratch_mount >/dev/null 2>&1 \ - || _notrun "Kernel doesn't support metadata_csum feature" - _scratch_unmount -} - -# Check whether the specified feature whether it is supported by -# mkfs.ext4 and the kernel. -_require_scratch_ext4_feature() -{ - if [ -z "$1" ]; then - echo "Usage: _require_scratch_ext4_feature feature" - exit 1 - fi - $MKFS_EXT4_PROG -F $MKFS_OPTIONS -O "$1" \ - $SCRATCH_DEV 512m >/dev/null 2>&1 \ - || _notrun "mkfs.ext4 doesn't support $1 feature" - _try_scratch_mount >/dev/null 2>&1 \ - || _notrun "Kernel doesn't support the ext4 feature(s): $1" - _scratch_unmount -} - # this test requires that external log/realtime devices are not in use # _require_nonexternal() @@ -2894,16 +2760,6 @@ _require_fail_make_request() not found. Seems that CONFIG_FAULT_INJECTION_DEBUG_FS kernel config option not enabled" } -# Disable extent zeroing for ext4 on the given device -_ext4_disable_extent_zeroout() -{ - local dev=${1:-$TEST_DEV} - local sdev=`_short_dev $dev` - - [ -f /sys/fs/ext4/$sdev/extent_max_zeroout_kb ] && \ - echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb -} - # The default behavior of SEEK_HOLE is to always return EOF. # Filesystems that implement non-default behavior return the offset # of holes with SEEK_HOLE. There is no way to query the filesystem @@ -3001,15 +2857,6 @@ _require_scratch_richacl_xfs() _scratch_unmount } -_require_scratch_richacl_ext4() -{ - _scratch_mkfs -O richacl >/dev/null 2>&1 \ - || _notrun "can't mkfs $FSTYP with option -O richacl" - _try_scratch_mount >/dev/null 2>&1 \ - || _notrun "kernel doesn't support richacl feature on $FSTYP" - _scratch_unmount -} - _require_scratch_richacl_support() { _scratch_mount From patchwork Wed Aug 3 04:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12935170 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 858C7C3F6B0 for ; Wed, 3 Aug 2022 04:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235310AbiHCEV6 (ORCPT ); Wed, 3 Aug 2022 00:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235407AbiHCEVx (ORCPT ); Wed, 3 Aug 2022 00:21:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B3054AC1; Tue, 2 Aug 2022 21:21:53 -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 E2469612E4; Wed, 3 Aug 2022 04:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F854C43140; Wed, 3 Aug 2022 04:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659500512; bh=bnN3+rr2Irc5hVunotTz6N7Asyuu/jHCPgME80PdV/0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mQA/70NoWex0FQGV7kcdlHEdQO/GM5DUyzVLgARuUxP4aUkktgtBCAYrEaj/Oo8f7 ONviVRbfNUT2yZjRpch2XBIfeS5HhUGoR7BoRFm31epxdjER17DtAxi2Vs4JUZHrsQ I0oo5UKKYq3mNMH9F3tCgFxkWi4KiqkJT3rnT+dHIaXhuhdbmu70tF60tS9Tau50Gm XkyTDQS98vGK581zo0wk2aQmTg/dh1W63kDEDqLtQu79W50m7saRD07WpTyUfBB4iW /HZNumJyTL/s/LBsvpF6tkSRSZyf778l29cEQGcg69bjzX6il0bmYiYVnoZ3M3egbl u0E2R/lMXHHXw== Subject: [PATCH 2/3] common/rc: move XFS-specific parts of _scratch_options into common/xfs From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me, tytso@mit.edu, linux-ext4@vger.kernel.org Date: Tue, 02 Aug 2022 21:21:51 -0700 Message-ID: <165950051183.198922.10544333892197894472.stgit@magnolia> In-Reply-To: <165950050051.198922.13423077997881086438.stgit@magnolia> References: <165950050051.198922.13423077997881086438.stgit@magnolia> 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 Move all the non-XFS code in _scratch_options into a _scratch_xfs_options helper in common/xfs, in preparation to add ext4 bits. Signed-off-by: Darrick J. Wong --- common/rc | 23 +++-------------------- common/xfs | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/common/rc b/common/rc index 52dd3b41..dc1d65c3 100644 --- a/common/rc +++ b/common/rc @@ -172,30 +172,13 @@ _clear_mount_stack() _scratch_options() { - local type=$1 - local rt_opt="" - local log_opt="" SCRATCH_OPTIONS="" - if [ "$FSTYP" != "xfs" ]; then - return - fi - - case $type in - mkfs) - SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f" - rt_opt="-r" - log_opt="-l" - ;; - mount) - rt_opt="-o" - log_opt="-o" + case "$FSTYP" in + "xfs") + _scratch_xfs_options "$@" ;; esac - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ - SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV" - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ - SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV" } _test_options() diff --git a/common/xfs b/common/xfs index 9f84dffb..f6f4cdd2 100644 --- a/common/xfs +++ b/common/xfs @@ -265,6 +265,29 @@ _xfs_check() return $status } +_scratch_xfs_options() +{ + local type=$1 + local rt_opt="" + local log_opt="" + + case $type in + mkfs) + SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f" + rt_opt="-r" + log_opt="-l" + ;; + mount) + rt_opt="-o" + log_opt="-o" + ;; + esac + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \ + SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV" + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV" +} + _scratch_xfs_db_options() { SCRATCH_OPTIONS="" From patchwork Wed Aug 3 04:21:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12935171 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 0F185C19F2A for ; Wed, 3 Aug 2022 04:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235503AbiHCEWC (ORCPT ); Wed, 3 Aug 2022 00:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235444AbiHCEV7 (ORCPT ); Wed, 3 Aug 2022 00:21:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DA95466A; Tue, 2 Aug 2022 21:21:58 -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 7F97661248; Wed, 3 Aug 2022 04:21:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D93A1C433C1; Wed, 3 Aug 2022 04:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659500517; bh=3uAwmeySBlqJ5bpC+m+eSKAg6CfcTUSV/7/H5638fxw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=dmMVwjjCZibKyIF8mJ4hj3V53X6V1M1RTAT9PJaLZo9LUAeuQ5LeMrdM8NPrn67sv TkLxCZNzuKElvzMehS/nQL+DhoI5/fftXi1PDeDDvi7D9CO6kGaLYsva3lY4RH0c04 Ck+jvJvZPlBuJ7qrBU/66SYDGnv1VgfVIwS0MRv5hoy8ZLOO98fektyDG6qZImEhqN U6SN/KDIcKxV9u6Jg+k0LFXZduw+AT+OAXqRyBGJQEsAuu9e3b1NcsIA3lzPftVAVJ iIiVX1mZ59sppwTukaxpzcvEqIaaKbEACAMI4ZZqqd1JHtwXpwvkqL1X96I2oJleXd D04Ormtvwa2RQ== Subject: [PATCH 3/3] common/ext4: provide custom ext4 scratch fs options From: "Darrick J. Wong" To: djwong@kernel.org, guaneryu@gmail.com, zlang@redhat.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me, tytso@mit.edu, linux-ext4@vger.kernel.org Date: Tue, 02 Aug 2022 21:21:57 -0700 Message-ID: <165950051745.198922.6487109955066878945.stgit@magnolia> In-Reply-To: <165950050051.198922.13423077997881086438.stgit@magnolia> References: <165950050051.198922.13423077997881086438.stgit@magnolia> 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 Create a _scratch_options backend for ext* so that we can inject pathnames to external log devices into the scratch fs mount options. This enables common/dm* to install block device filters, e.g. dm-error for stress testing. Signed-off-by: Darrick J. Wong --- common/ext4 | 20 ++++++++++++++++++++ common/rc | 3 +++ 2 files changed, 23 insertions(+) diff --git a/common/ext4 b/common/ext4 index 287705af..819f9786 100644 --- a/common/ext4 +++ b/common/ext4 @@ -154,3 +154,23 @@ _require_scratch_richacl_ext4() || _notrun "kernel doesn't support richacl feature on $FSTYP" _scratch_unmount } + +_scratch_ext4_options() +{ + local type=$1 + local log_opt="" + + case $type in + mkfs) + log_opt="-J device=$SCRATCH_LOGDEV" + ;; + mount) + # As of kernel 5.19, the kernel mount option path parser only accepts + # direct paths to block devices--the final path component cannot be a + # symlink. + log_opt="-o journal_path=$(realpath $SCRATCH_LOGDEV)" + ;; + esac + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}" +} diff --git a/common/rc b/common/rc index dc1d65c3..b82bb36b 100644 --- a/common/rc +++ b/common/rc @@ -178,6 +178,9 @@ _scratch_options() "xfs") _scratch_xfs_options "$@" ;; + ext2|ext3|ext4|ext4dev) + _scratch_ext4_options "$@" + ;; esac }