Skip to contentSkip to conversation

common/rc: support f2fs in _mkfs_dev()

PATCH Superseded Chao Yu 2 participants 6 messages Dec 23, 2024 – Dec 28, 2024

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH v3 1/2 common/rc: support f2fs in _mkfs_dev()

Then, f2fs/* testcases can use this wrapped common helper instead of raw codes.

---
v3:
- adapt _mkfs_dev() to support f2fs, preparing for following use in f2fs/008.

 common/rc | 3 +++
 1 file changed, 3 insertions(+)
common/rc +3 -0
index 7b5bc0b4..ecac2de8 100644
@@ -833,6 +833,9 @@ _try_mkfs_dev()
     ext2|ext3|ext4)
 	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $*
 	;;
+    f2fs)
+	$MKFS_PROG -t $FSTYP -- -f $MKFS_OPTIONS $*
+	;;
     xfs)
 	$MKFS_PROG -t $FSTYP -- -f $MKFS_OPTIONS $*
 	;;
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH v3 2/2 f2fs/008: test snapshot creation/deletion on lvm device

This patch introduce a regression testcase to check whether f2fs can handle discard correctly once underlying lvm device changes to not support discard after user creates snapshot on it.

Related bug was fixed by commit bc8aeb04fd80 ("f2fs: fix to drop all discards after creating snapshot on lvm device")

Cc Jaegeuk Kim <[email protected]>

---
v3:
- rebase to last for-next branch
- update according to Zorro's comments.

 tests/f2fs/008     | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/008.out |  2 ++
 2 files changed, 59 insertions(+)
 create mode 100755 tests/f2fs/008
 create mode 100644 tests/f2fs/008.out
tests/f2fs/008 new file +57 -0
new file mode 100755
index 00000000..b85e321c
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/008
+#
+# This is a regression test to check whether f2fs can handle
+# discard correctly once underlying lvm device changes to not
+# support discard after user creates snapshot on it.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit bc8aeb04fd80 \
+        "f2fs: fix to drop all discards after creating snapshot on lvm device"
+
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$seq
+vgname=vg_$seq
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	_unmount $SCRATCH_MNT >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+	_udev_wait --removed /dev/mapper/$vgname-$lvname
+	cd /
+	rm -f $tmp.*
+}
+
+$LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG lvcreate -L 1024m -n $lvname $vgname >>$seqres.full 2>&1
+_udev_wait /dev/mapper/$vgname-$lvname
+
+_mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+_mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm -f $testfile
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/008.out new file +2 -0
new file mode 100644
index 00000000..dd68d5a4
@@ -0,0 +1,2 @@
+QA output created by 008
+Silence is golden
Signature · 1 line
2.40.1
#2 lore raw

Re: [PATCH v3 2/2] f2fs/008: test snapshot creation/deletion on lvm device

Quoted 56 lines · Chao Yu

This patch introduce a regression testcase to check whether f2fs can handle discard correctly once underlying lvm device changes to not support discard after user creates snapshot on it.

Related bug was fixed by commit bc8aeb04fd80 ("f2fs: fix to drop all discards after creating snapshot on lvm device")

Cc Jaegeuk Kim <[email protected]>

---
v3:
- rebase to last for-next branch
- update according to Zorro's comments.

 tests/f2fs/008     | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/008.out |  2 ++
 2 files changed, 59 insertions(+)
 create mode 100755 tests/f2fs/008
 create mode 100644 tests/f2fs/008.out
tests/f2fs/008 new file +30 -0
new file mode 100755
index 00000000..b85e321c
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/008
+#
+# This is a regression test to check whether f2fs can handle
+# discard correctly once underlying lvm device changes to not
+# support discard after user creates snapshot on it.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit bc8aeb04fd80 \
+        "f2fs: fix to drop all discards after creating snapshot on lvm device"
+
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$seq
+vgname=vg_$seq
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	_unmount $SCRATCH_MNT >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1

tests/f2fs/008 line 40

Quoted 10 lines
tests/f2fs/008 new file +10 -0
+	$LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+	_udev_wait --removed /dev/mapper/$vgname-$lvname
+	cd /
+	rm -f $tmp.*
+}
+
+$LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG lvcreate -L 1024m -n $lvname $vgname >>$seqres.full 2>&1

The lvcreate might be blocked by:
"WARNING: f2fs signature detected on /dev/vg_008/lv_008 at offset 1024. Wipe it? [y/n]:"

So better to use "lvcreate -y" or "yes | ...".

Thanks,
Zorro

Quoted 28 lines
tests/f2fs/008 new file +17 -0
+_udev_wait /dev/mapper/$vgname-$lvname
+
+_mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+_mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm -f $testfile
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/008.out new file +2 -0
new file mode 100644
index 00000000..dd68d5a4
@@ -0,0 +1,2 @@
+QA output created by 008
+Silence is golden
Signature · 1 line
2.40.1
author
#3 lore raw

Re: [PATCH v3 2/2] f2fs/008: test snapshot creation/deletion on lvm device

Quoted 62 lines · Zorro Lang
Quoted 61 lines · Chao Yu

This patch introduce a regression testcase to check whether f2fs can handle discard correctly once underlying lvm device changes to not support discard after user creates snapshot on it.

Related bug was fixed by commit bc8aeb04fd80 ("f2fs: fix to drop all discards after creating snapshot on lvm device")

Cc Jaegeuk Kim <[email protected]>

---
v3:
- rebase to last for-next branch
- update according to Zorro's comments.

  tests/f2fs/008     | 57 ++++++++++++++++++++++++++++++++++++++++++++++
  tests/f2fs/008.out |  2 ++
  2 files changed, 59 insertions(+)

create mode 100755 tests/f2fs/008
create mode 100644 tests/f2fs/008.out

tests/f2fs/008 new file +35 -0
new file mode 100755
index 00000000..b85e321c
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/008
+#
+# This is a regression test to check whether f2fs can handle
+# discard correctly once underlying lvm device changes to not
+# support discard after user creates snapshot on it.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit bc8aeb04fd80 \
+        "f2fs: fix to drop all discards after creating snapshot on lvm device"
+
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$seq
+vgname=vg_$seq
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	_unmount $SCRATCH_MNT >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+	_udev_wait --removed /dev/mapper/$vgname-$lvname
+	cd /
+	rm -f $tmp.*
Quoted 8 lines

tests/f2fs/008 line 40

Quoted 5 lines
tests/f2fs/008 new file +5 -0
+}
+
+$LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG lvcreate -L 1024m -n $lvname $vgname >>$seqres.full 2>&1

The lvcreate might be blocked by:
"WARNING: f2fs signature detected on /dev/vg_008/lv_008 at offset 1024. Wipe it? [y/n]:"

Oh, I didn't encounter this... is it due to I use low version lvm tool?

lvm version
LVM version: 2.03.11(2) (2021-01-08)
Library version: 1.02.175 (2021-01-08)
Driver version: 4.48.0

Quoted 2 lines

So better to use "lvcreate -y" or "yes | ...".

Sure.

Thanks,

Quoted 33 lines

Thanks,
Zorro

Quoted 28 lines
tests/f2fs/008 new file +17 -0
+_udev_wait /dev/mapper/$vgname-$lvname
+
+_mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+_mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm -f $testfile
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/008.out new file +2 -0
new file mode 100644
index 00000000..dd68d5a4
@@ -0,0 +1,2 @@
+QA output created by 008
+Silence is golden
Signature · 1 line
2.40.1
#4 lore raw

Re: [PATCH v3 2/2] f2fs/008: test snapshot creation/deletion on lvm device

Quoted 72 lines · Chao Yu
Quoted 62 lines · Zorro Lang
Quoted 61 lines · Chao Yu

This patch introduce a regression testcase to check whether f2fs can handle discard correctly once underlying lvm device changes to not support discard after user creates snapshot on it.

Related bug was fixed by commit bc8aeb04fd80 ("f2fs: fix to drop all discards after creating snapshot on lvm device")

Cc Jaegeuk Kim <[email protected]>

---
v3:
- rebase to last for-next branch
- update according to Zorro's comments.

  tests/f2fs/008     | 57 ++++++++++++++++++++++++++++++++++++++++++++++
  tests/f2fs/008.out |  2 ++
  2 files changed, 59 insertions(+)

create mode 100755 tests/f2fs/008
create mode 100644 tests/f2fs/008.out

tests/f2fs/008 new file +35 -0
new file mode 100755
index 00000000..b85e321c
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/008
+#
+# This is a regression test to check whether f2fs can handle
+# discard correctly once underlying lvm device changes to not
+# support discard after user creates snapshot on it.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit bc8aeb04fd80 \
+        "f2fs: fix to drop all discards after creating snapshot on lvm device"
+
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$seq
+vgname=vg_$seq
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	_unmount $SCRATCH_MNT >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+	_udev_wait --removed /dev/mapper/$vgname-$lvname
+	cd /
+	rm -f $tmp.*
Quoted 8 lines

tests/f2fs/008 line 40

Quoted 5 lines
tests/f2fs/008 new file +5 -0
+}
+
+$LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG lvcreate -L 1024m -n $lvname $vgname >>$seqres.full 2>&1

The lvcreate might be blocked by:
"WARNING: f2fs signature detected on /dev/vg_008/lv_008 at offset 1024. Wipe it? [y/n]:"

Quoted 1 line

Oh, I didn't encounter this... is it due to I use low version lvm tool?

I tried to run this test twice, the second test hang there, then I found it.

Quoted 8 lines

lvm version
LVM version: 2.03.11(2) (2021-01-08)
Library version: 1.02.175 (2021-01-08)
Driver version: 4.48.0

Quoted 2 lines

So better to use "lvcreate -y" or "yes | ...".

lvcreate -y is good, but I'm not sure which lvm version starts to support this option. So the "yes | ..." might have better compatibility.

Thanks,
Zorro

Quoted 39 lines

Sure.

Thanks,

Quoted 33 lines

Thanks,
Zorro

Quoted 28 lines
tests/f2fs/008 new file +17 -0
+_udev_wait /dev/mapper/$vgname-$lvname
+
+_mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+_mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm -f $testfile
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/008.out new file +2 -0
new file mode 100644
index 00000000..dd68d5a4
@@ -0,0 +1,2 @@
+QA output created by 008
+Silence is golden
Signature · 1 line
2.40.1
author
#5 lore raw

Re: [PATCH v3 2/2] f2fs/008: test snapshot creation/deletion on lvm device

Quoted 73 lines · Zorro Lang
Quoted 72 lines · Chao Yu
Quoted 70 lines · Zorro Lang
Quoted 56 lines · Chao Yu

This patch introduce a regression testcase to check whether f2fs can handle discard correctly once underlying lvm device changes to not support discard after user creates snapshot on it.

Related bug was fixed by commit bc8aeb04fd80 ("f2fs: fix to drop all discards after creating snapshot on lvm device")

Cc Jaegeuk Kim <[email protected]>

---
v3:
- rebase to last for-next branch
- update according to Zorro's comments.

   tests/f2fs/008     | 57 ++++++++++++++++++++++++++++++++++++++++++++++
   tests/f2fs/008.out |  2 ++
   2 files changed, 59 insertions(+)

create mode 100755 tests/f2fs/008
create mode 100644 tests/f2fs/008.out

tests/f2fs/008 new file +30 -0
new file mode 100755
index 00000000..b85e321c
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo.  All Rights Reserved.
+#
+# FS QA Test No. f2fs/008
+#
+# This is a regression test to check whether f2fs can handle
+# discard correctly once underlying lvm device changes to not
+# support discard after user creates snapshot on it.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit bc8aeb04fd80 \
+        "f2fs: fix to drop all discards after creating snapshot on lvm device"
+
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$seq
+vgname=vg_$seq
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	_unmount $SCRATCH_MNT >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -ff /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1

tests/f2fs/008 line 40

Quoted 10 lines
tests/f2fs/008 new file +10 -0
+	$LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+	_udev_wait --removed /dev/mapper/$vgname-$lvname
+	cd /
+	rm -f $tmp.*
+}
+
+$LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
+$LVM_PROG lvcreate -L 1024m -n $lvname $vgname >>$seqres.full 2>&1

The lvcreate might be blocked by:

    "WARNING: f2fs signature detected on /dev/vg_008/lv_008 at offset 1024. Wipe it? [y/n]:"
Quoted 3 lines
Quoted 1 line

Oh, I didn't encounter this... is it due to I use low version lvm tool?

I tried to run this test twice, the second test hang there, then I found it.

I tested such case as well, but it didn't hang the testcase.

Quoted 8 lines
Quoted 8 lines

lvm version
LVM version: 2.03.11(2) (2021-01-08)
Library version: 1.02.175 (2021-01-08)
Driver version: 4.48.0

Quoted 1 line
Quoted 4 lines
Quoted 1 line
Quoted 1 line

So better to use "lvcreate -y" or "yes | ...".

lvcreate -y is good, but I'm not sure which lvm version starts to support this option. So the "yes | ..." might have better compatibility.

Alright...

Thanks,

Quoted 44 lines

Thanks,
Zorro

Quoted 39 lines

Sure.

Thanks,

Quoted 33 lines

Thanks,
Zorro

Quoted 28 lines
tests/f2fs/008 new file +17 -0
+_udev_wait /dev/mapper/$vgname-$lvname
+
+_mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+_mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm -f $testfile
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+
+echo "Silence is golden"
+
+status=0
+exit
tests/f2fs/008.out new file +2 -0
new file mode 100644
index 00000000..dd68d5a4
@@ -0,0 +1,2 @@
+QA output created by 008
+Silence is golden
Signature · 1 line
2.40.1