Skip to contentSkip to conversation

f2fs/012: adapt lookup_mode=x mount option

PATCH Superseded Chao Yu 2 participants 3 messages Aug 8, 2025 – Aug 16, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs/012: adapt lookup_mode=x mount option

w/ below change [1], f2fs will enable lookup_mode=perf by default, it will change f2fs dirent lookup method from linear based lookup to hash based lookup.

So that, f2fs will ignore sb.s_encoding_flags by default, which is not compatible w/ f2fs/012 testcase, in where it will control lookup method by configuring this flag w/ fsck.f2fs.

To avoid failure of f2fs/012, let's check whether f2fs has supported "lookup_mode=auto" mount option, mount w/ the option if it can, otherwise, don't.

[1] https://lore.kernel.org/linux-f2fs-devel/[email protected]

---
 tests/f2fs/012 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tests/f2fs/012 +11 -2
index b3df9a8f..15fc8f0c 100755
@@ -22,6 +22,15 @@ _require_scratch_nocheck
 _require_command "$F2FS_IO_PROG" f2fs_io
 _require_command "$F2FS_INJECT_PROG" inject.f2fs
 
+#check whether f2fs supports "lookup_mode=x" mount option
+mntopt=""
+_scratch_mkfs -O casefold -C utf8 >> $seqres.full
+_try_scratch_mount "-o lookup_mode=auto"
+if [ $? == 0 ]; then
+	mntopt="-o lookup_mode=auto"
+	_scratch_unmount
+fi
+
 check_lookup()
 {
 	local nolinear_lookup=$1
@@ -30,7 +39,7 @@ check_lookup()
 	local redheart=$dir/$'\u2764\ufe0f'
 
 	_scratch_mkfs -O casefold -C utf8 >> $seqres.full
-	_scratch_mount
+	_scratch_mount $mntopt
 
 	mkdir $dir
 	$F2FS_IO_PROG setflags casefold $dir >> $seqres.full
@@ -52,7 +61,7 @@ check_lookup()
 
 	$F2FS_INJECT_PROG --dent --mb d_hash --nid $ino --val 0x9a2ea068 $SCRATCH_DEV >> $seqres.full
 
-	_scratch_mount
+	_scratch_mount $mntopt
 	if [ $nolinear_lookup == "1" ]; then
 		[ -f $redheart ] && _fail "red heart file should not exist"
 	else
Signature · 1 line
2.40.1
#1 lore raw
Quoted 12 lines · Chao Yu

w/ below change [1], f2fs will enable lookup_mode=perf by default, it will change f2fs dirent lookup method from linear based lookup to hash based lookup.

So that, f2fs will ignore sb.s_encoding_flags by default, which is not compatible w/ f2fs/012 testcase, in where it will control lookup method by configuring this flag w/ fsck.f2fs.

To avoid failure of f2fs/012, let's check whether f2fs has supported "lookup_mode=auto" mount option, mount w/ the option if it can, otherwise, don't.

Quoted 5 lines

[1] https://lore.kernel.org/linux-f2fs-devel/[email protected]

---

With this patch, I always get below error:

f2fs/012 2s ... - output mismatch (see /root/git/xfstests/results//f2fs/012.out.bad)
--- tests/f2fs/012.out 2025-07-21 13:33:12.379585206 +0800
+++ /root/git/xfstests/results//f2fs/012.out.bad 2025-08-15 23:51:54.156835560 +0800
@@ -1,2 +1,4 @@
QA output created by 012
+mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/sda6, missing codepage or helper program, or other error.
+ dmesg(1) may have more information after failed mount system call.
Silence is golden
...
(Run 'diff -u /root/git/xfstests/tests/f2fs/012.out /root/git/xfstests/results//f2fs/012.out.bad' to see the entire diff)

Then test passed without this patch:

f2fs/012 2s ... 3s
Ran: f2fs/012
Passed all 1 tests

Quoted 44 lines
 tests/f2fs/012 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tests/f2fs/012 +11 -2
index b3df9a8f..15fc8f0c 100755
@@ -22,6 +22,15 @@ _require_scratch_nocheck
 _require_command "$F2FS_IO_PROG" f2fs_io
 _require_command "$F2FS_INJECT_PROG" inject.f2fs
 
+#check whether f2fs supports "lookup_mode=x" mount option
+mntopt=""
+_scratch_mkfs -O casefold -C utf8 >> $seqres.full
+_try_scratch_mount "-o lookup_mode=auto"
+if [ $? == 0 ]; then
+	mntopt="-o lookup_mode=auto"
+	_scratch_unmount
+fi
+
 check_lookup()
 {
 	local nolinear_lookup=$1
@@ -30,7 +39,7 @@ check_lookup()
 	local redheart=$dir/$'\u2764\ufe0f'
 
 	_scratch_mkfs -O casefold -C utf8 >> $seqres.full
-	_scratch_mount
+	_scratch_mount $mntopt
 
 	mkdir $dir
 	$F2FS_IO_PROG setflags casefold $dir >> $seqres.full
@@ -52,7 +61,7 @@ check_lookup()
 
 	$F2FS_INJECT_PROG --dent --mb d_hash --nid $ino --val 0x9a2ea068 $SCRATCH_DEV >> $seqres.full
 
-	_scratch_mount
+	_scratch_mount $mntopt
 	if [ $nolinear_lookup == "1" ]; then
 		[ -f $redheart ] && _fail "red heart file should not exist"
 	else
Signature · 1 line
2.40.1
author
#2 lore raw
Quoted 32 lines · Zorro Lang
Quoted 12 lines · Chao Yu

w/ below change [1], f2fs will enable lookup_mode=perf by default, it will change f2fs dirent lookup method from linear based lookup to hash based lookup.

So that, f2fs will ignore sb.s_encoding_flags by default, which is not compatible w/ f2fs/012 testcase, in where it will control lookup method by configuring this flag w/ fsck.f2fs.

To avoid failure of f2fs/012, let's check whether f2fs has supported "lookup_mode=auto" mount option, mount w/ the option if it can, otherwise, don't.

Quoted 5 lines

[1] https://lore.kernel.org/linux-f2fs-devel/[email protected]

---

With this patch, I always get below error:

f2fs/012 2s ... - output mismatch (see /root/git/xfstests/results//f2fs/012.out.bad)
--- tests/f2fs/012.out 2025-07-21 13:33:12.379585206 +0800
+++ /root/git/xfstests/results//f2fs/012.out.bad 2025-08-15 23:51:54.156835560 +0800
@@ -1,2 +1,4 @@
QA output created by 012
+mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/sda6, missing codepage or helper program, or other error.
+ dmesg(1) may have more information after failed mount system call.
Silence is golden
...
(Run 'diff -u /root/git/xfstests/tests/f2fs/012.out /root/git/xfstests/results//f2fs/012.out.bad' to see the entire diff)

Quoted 1 line

Then test passed without this patch:

Sorry, I thought I've checked the case that kernel doesn't support lookup_mode=x mount option.

Quoted 17 lines

f2fs/012 2s ... 3s
Ran: f2fs/012
Passed all 1 tests

Quoted 11 lines
  tests/f2fs/012 | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)
tests/f2fs/012 +0 -0
index b3df9a8f..15fc8f0c 100755
@@ -22,6 +22,15 @@ _require_scratch_nocheck
  _require_command "$F2FS_IO_PROG" f2fs_io
  _require_command "$F2FS_INJECT_PROG" inject.f2fs
 
Quoted 4 lines

tests/f2fs/012 _require_scratch_nocheck · line 28

Quoted 4 lines
tests/f2fs/012 +4 -0
+#check whether f2fs supports "lookup_mode=x" mount option
+mntopt=""
+_scratch_mkfs -O casefold -C utf8 >> $seqres.full
+_try_scratch_mount "-o lookup_mode=auto"

We need to ignore the error from _try_scratch_mount ... here, let me fix it.

Thanks,

Quoted 30 lines
Quoted 29 lines
tests/f2fs/012 +7 -2
+if [ $? == 0 ]; then
+	mntopt="-o lookup_mode=auto"
+	_scratch_unmount
+fi
+
  check_lookup()
  {
  	local nolinear_lookup=$1
@@ -30,7 +39,7 @@ check_lookup()
  	local redheart=$dir/$'\u2764\ufe0f'
 
  	_scratch_mkfs -O casefold -C utf8 >> $seqres.full
-	_scratch_mount
+	_scratch_mount $mntopt
 
  	mkdir $dir
  	$F2FS_IO_PROG setflags casefold $dir >> $seqres.full
@@ -52,7 +61,7 @@ check_lookup()
 
  	$F2FS_INJECT_PROG --dent --mb d_hash --nid $ino --val 0x9a2ea068 $SCRATCH_DEV >> $seqres.full
 
-	_scratch_mount
+	_scratch_mount $mntopt
  	if [ $nolinear_lookup == "1" ]; then
  		[ -f $redheart ] && _fail "red heart file should not exist"
  	else
Signature · 1 line
2.40.1