From patchwork Mon Jan 23 09:38:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13111801 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 E0D04C05027 for ; Mon, 23 Jan 2023 09:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231872AbjAWJiG (ORCPT ); Mon, 23 Jan 2023 04:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbjAWJiF (ORCPT ); Mon, 23 Jan 2023 04:38:05 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6F14EF4 for ; Mon, 23 Jan 2023 01:38:04 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 21559341F5; Mon, 23 Jan 2023 09:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674466683; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Pfp5o58ccdf2xgm1YypZhtoaQWMC//ij1ULXNxnj0Yw=; b=SfYAC/DikB5RL9Rby4DjdMoKYn2d+cfWkrkdgGp9SSnMyTv5r2Tn3FOkaG2zB/aC2yhJkD Vo1tDI+myaDcmpRIybB41Hi25pGsVcdiwb/neNzcghgGDAfj8TLLcKUD1eA9XYmDHJMyqY nAX64btDnXbblKFfds9AArKncm7iPDk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674466683; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Pfp5o58ccdf2xgm1YypZhtoaQWMC//ij1ULXNxnj0Yw=; b=1eHaKXkhv35AgoSF238C68u1qE48Ml/pFZevUgMqq7ruAy1zxgjV3qzdY7TqnssEasUEd5 L5Hr/j6Pf7r5k3Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0B038134F5; Mon, 23 Jan 2023 09:38:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lCu3AntVzmOofQAAMHmgww (envelope-from ); Mon, 23 Jan 2023 09:38:03 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 859FEA06B5; Mon, 23 Jan 2023 10:38:02 +0100 (CET) From: Jan Kara To: Cc: Jan Kara Subject: [PATCH] common: Improve blocksize support for udf Date: Mon, 23 Jan 2023 10:38:00 +0100 Message-Id: <20230123093800.3394-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Add better support for blocksize selection in _scratch_mkfs_sized (accept another variant of mkfs options, select correct default block size if not specified). Also add blocksize selection support to _scratch_mkfs_blocksized. For _check_udf_filesystem to keep working when blocksize is not specified in MKFS_OPTIONS, add detection of blocksize from a mounted filesystem. Signed-off-by: Jan Kara --- common/rc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/common/rc b/common/rc index 7f80afe7aeec..e49918c9deab 100644 --- a/common/rc +++ b/common/rc @@ -922,9 +922,15 @@ _scratch_mkfs_sized() btrfs) def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-s ?+([0-9]+).*/\1/p'` ;; - ext2|ext3|ext4|ext4dev|udf|reiser4|ocfs2|reiserfs) + ext2|ext3|ext4|ext4dev|reiser4|ocfs2|reiserfs) def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'` ;; + udf) + def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'` + if [ -z "$def_blksz" ]; then + def_blksz=512 + fi + ;; jfs) def_blksz=4096 ;; @@ -1116,6 +1122,9 @@ _scratch_mkfs_blocksized() ${MKFS_PROG} -t $FSTYP $MKFS_OPTIONS --block_size=$blocksize \ $SCRATCH_DEV ;; + udf) + _scratch_mkfs -b $blocksize + ;; *) _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized" ;; @@ -3074,17 +3083,18 @@ _check_udf_filesystem() return fi + local device=$1 + local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'` + if [ -z "$blksz" ]; then + blksz=512 + fi # Is the filesystem mounted? local type=`_fs_type $device` if [ "$type" = "$FSTYP" ]; then + blksz=`blockdev --getbsz $device` local mountpoint=`_umount_or_remount_ro $device` fi - local device=$1 - local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'` - if [ -z "$blksz" ]; then - blksz=512 - fi local opt_arg="-ecclength 1 -blocksize $blksz" if [ $# -eq 2 ]; then opt_arg+=" -lastvalidblock $(( $2 - 1 ))"