Skip to contentSkip to conversation

fstests: Fix checking of UDF filesystems

PATCH Superseded Jan Kara 3 participants 8 messages Jan 19, 2023 – Jan 20, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

cover fstests: Fix checking of UDF filesystems

Hello,

these two patches fix the usage of udf_test program in _check_udf_filesystem so that it can reliably check udf filesystems. It provides it proper arguments and also unmounts the filesystem prior to running the check.

Honza

author
#1 lore raw

PATCH 1/2 common: Provide blocksize and ecclength to udf fsck

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +6 -2
index 8060c03b7d18..de94e5a4cde4 100644
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
+    if [ -z "$blksz" ]; then
+	blksz=512
+    fi
+    local opt_arg="-ecclength 1 -blocksize $blksz"
     if [ $# -eq 2 ]; then
-	opt_arg="-lastvalidblock $(( $2 - 1 ))"
+	opt_arg+=" -lastvalidblock $(( $2 - 1 ))"
     fi
 
     rm -f $seqres.checkfs
Signature · 1 line
2.35.3
#2 lore raw

Re: [PATCH 1/2] common: Provide blocksize and ecclength to udf fsck

Hi Jan,

Quoted 14 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index 8060c03b7d18..de94e5a4cde4 100644

common/rc _check_udf_filesystem() · line 3078

Quoted 5 lines
common/rc +1 -1
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`

It looks as though mkudffs also accepts --blocksize= for this, so it should also be handled here, IIUC.

Looks fine otherwise.

Quoted 10 lines
common/rc +5 -1
+    if [ -z "$blksz" ]; then
+	blksz=512
+    fi
+    local opt_arg="-ecclength 1 -blocksize $blksz"
     if [ $# -eq 2 ]; then
-	opt_arg="-lastvalidblock $(( $2 - 1 ))"
+	opt_arg+=" -lastvalidblock $(( $2 - 1 ))"
     fi
 
     rm -f $seqres.checkfs
author
#3 lore raw

Re: [PATCH 1/2] common: Provide blocksize and ecclength to udf fsck

Hello!

Quoted 17 lines · David Disseldorp
Quoted 16 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index 8060c03b7d18..de94e5a4cde4 100644
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
Quoted 6 lines

common/rc _check_udf_filesystem() · line 3078

Quoted 3 lines
common/rc +1 -1
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`

It looks as though mkudffs also accepts --blocksize= for this, so it should also be handled here, IIUC.

Thanks for review! I've fixed this.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw

Re: [PATCH 1/2] common: Provide blocksize and ecclength to udf fsck

Quoted 26 lines · Jan Kara

Hello!

Quoted 23 lines · David Disseldorp
Quoted 14 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index 8060c03b7d18..de94e5a4cde4 100644

common/rc _check_udf_filesystem() · line 3078

Quoted 5 lines
common/rc +1 -1
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`

It looks as though mkudffs also accepts --blocksize= for this, so it should also be handled here, IIUC.

And _scratch_mkfs_sized need blocksize too. If udf support blocksize parameter, you might like to take a look at that helper too, due to it always use 4096 for udf blocksize.

Similar helpers are _scratch_mkfs_geom (maybe not suit for udf) and _scratch_mkfs_blocksized.

Thanks,
Zorro

Quoted 8 lines

Thanks for review! I've fixed this.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#5 lore raw

Re: [PATCH 1/2] common: Provide blocksize and ecclength to udf fsck

Quoted 28 lines · Zorro Lang
Quoted 26 lines · Jan Kara

Hello!

Quoted 23 lines · David Disseldorp
Quoted 14 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index 8060c03b7d18..de94e5a4cde4 100644

common/rc _check_udf_filesystem() · line 3078

Quoted 5 lines
common/rc +1 -1
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`

It looks as though mkudffs also accepts --blocksize= for this, so it should also be handled here, IIUC.

Quoted 6 lines

And _scratch_mkfs_sized need blocksize too. If udf support blocksize parameter, you might like to take a look at that helper too, due to it always use 4096 for udf blocksize.

Similar helpers are _scratch_mkfs_geom (maybe not suit for udf) and _scratch_mkfs_blocksized.

Thanks for the tips, I'll have a look into those next.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#6 lore raw

PATCH 2/2 common: Unmount udf filesystem prior checking

In reply to Jan Kara

_check_udf_filesystem forgot to unmount the filesystem prior to checking it. That was leading to check failures.

---
 common/rc | 10 ++++++++++
 1 file changed, 10 insertions(+)
common/rc +10 -0
index de94e5a4cde4..df6f237cabaa 100644
@@ -3074,6 +3074,12 @@ _check_udf_filesystem()
 	return
     fi
 
+    # Is the filesystem mounted?
+    local type=`_fs_type $device`
+    if [ "$type" = "$FSTYP" ]; then
+	local mountpoint=`_umount_or_remount_ro $device`
+    fi
+
     local device=$1
     local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
     if [ -z "$blksz" ]; then
@@ -3090,6 +3096,10 @@ _check_udf_filesystem()
 	_udf_test_known_error_filter | \
 	grep -E -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" && \
         echo "Warning UDF Verifier reported errors see $seqres.checkfs." && return 1
+    # Remount the filesystem
+    if [ "$type" = "$FSTYP" ]; then
+	_mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+    fi
     return 0
 }
 
Signature · 1 line
2.35.3
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] common: Unmount udf filesystem prior checking

Quoted 26 lines · Jan Kara

_check_udf_filesystem forgot to unmount the filesystem prior to checking it. That was leading to check failures.

---
 common/rc | 10 ++++++++++
 1 file changed, 10 insertions(+)
common/rc +6 -0
index de94e5a4cde4..df6f237cabaa 100644
@@ -3074,6 +3074,12 @@ _check_udf_filesystem()
 	return
     fi
 
+    # Is the filesystem mounted?
+    local type=`_fs_type $device`
+    if [ "$type" = "$FSTYP" ]; then
+	local mountpoint=`_umount_or_remount_ro $device`
+    fi
+
     local device=$1
     local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
     if [ -z "$blksz" ]; then

common/rc _check_udf_filesystem() · line 3105

Quoted 10 lines
common/rc +4 -0
@@ -3090,6 +3096,10 @@ _check_udf_filesystem()
 	_udf_test_known_error_filter | \
 	grep -E -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" && \
         echo "Warning UDF Verifier reported errors see $seqres.checkfs." && return 1
+    # Remount the filesystem
+    if [ "$type" = "$FSTYP" ]; then
+	_mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+    fi
     return 0
 }
 

Looks fine.