Skip to contentSkip to conversation

f2fs/008: test snapshot creation/deletion on lvm device

PATCH Superseded Chao Yu 2 participants 3 messages Dec 2, 2024 – Dec 19, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 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]>
---
 tests/f2fs/008     | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/008.out |  2 ++
 2 files changed, 55 insertions(+)
 create mode 100755 tests/f2fs/008
 create mode 100644 tests/f2fs/008.out
tests/f2fs/008 new file +53 -0
new file mode 100755
index 00000000..a9a3f263
@@ -0,0 +1,53 @@
+#! /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_$sed
+vgname=vg_$Sseg
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
+	$LVM_PROG lvremove -f /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -f /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
+}
+
+$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
+
+$MKFS_F2FS_PROG /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 $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
+umount $SCRATCH_MNT
+
+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
#1 lore raw
Quoted 36 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]>
---
 tests/f2fs/008     | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/008.out |  2 ++
 2 files changed, 55 insertions(+)
 create mode 100755 tests/f2fs/008
 create mode 100644 tests/f2fs/008.out
tests/f2fs/008 new file +13 -0
new file mode 100755
index 00000000..a9a3f263
@@ -0,0 +1,53 @@
+#! /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

tests/f2fs/008 line 23

Quoted 10 lines
tests/f2fs/008 new file +10 -0
+
+_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_$sed
+vgname=vg_$Sseg

What's "$sed" and "$Sseg", I didn't find the definition of them.

tests/f2fs/008 line 27

Quoted 4 lines
tests/f2fs/008 new file +4 -0
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{

_unmount $SCRATCH_MNT >>$seqres.full 2>&1

for this test might be interrupted.

tests/f2fs/008 line 31

Quoted 4 lines
tests/f2fs/008 new file +4 -0
+	$LVM_PROG lvremove -f /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -f /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1

"-ff" might be better for cleanup.

According to 5f7a66b6dc4c ("fstests: use udevadm wait in preference to settle"), Dave recommend doing below command after above lines:

  _udev_wait --removed /dev/mapper/$vgname-$lvname

Then, don't forget the default cleanup steps:

cd /
rm -f $tmp.*

tests/f2fs/008 line 36

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

Also according to 5f7a66b6dc4c ("fstests: use udevadm wait in preference to settle"), Dave recommend using a:
_udev_wait /dev/mapper/$vgname-$lvname

tests/f2fs/008 line 38

Quoted 2 lines
tests/f2fs/008 new file +2 -0
+
+$MKFS_F2FS_PROG /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1

"-f" to force overwrite ? Or use _mkfs_dev? But _mkfs_dev doesn't has a f2f2 specific line, maybe you'd like to write one.

tests/f2fs/008 line 39

Quoted 1 line
tests/f2fs/008 new file +1 -0
+mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1

_mount

tests/f2fs/008 line 43

Quoted 4 lines
tests/f2fs/008 new file +4 -0
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm $testfile

"-f" ?

tests/f2fs/008 line 48

Quoted 5 lines
tests/f2fs/008 new file +5 -0
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+umount $SCRATCH_MNT

Move this line to _cleanup, to always try to do it before removing lvm.

Quoted 16 lines
tests/f2fs/008 new file +5 -0
+
+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
#2 lore raw
Quoted 41 lines · Zorro Lang
Quoted 40 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]>
---
  tests/f2fs/008     | 53 ++++++++++++++++++++++++++++++++++++++++++++++
  tests/f2fs/008.out |  2 ++
  2 files changed, 55 insertions(+)

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

tests/f2fs/008 new file +17 -0
new file mode 100755
index 00000000..a9a3f263
@@ -0,0 +1,53 @@
+#! /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"
+
Quoted 8 lines

tests/f2fs/008 line 23

Quoted 6 lines
tests/f2fs/008 new file +6 -0
+_require_scratch_nolvm
+_require_block_device $SCRATCH_DEV
+_require_command "$LVM_PROG" lvm
+
+lvname=lv_$sed
+vgname=vg_$Sseg

What's "$sed" and "$Sseg", I didn't find the definition of them.

Zorro,

Sorry, these are typos caused by copying codes, I have noticed this and fixed it in v2.

https://lore.kernel.org/fstests/[email protected]

Quoted 17 lines

tests/f2fs/008 line 27

Quoted 5 lines
tests/f2fs/008 new file +4 -0
+testfile=$SCRATCH_MNT/testfile
+
+_cleanup()
+{
   _unmount $SCRATCH_MNT >>$seqres.full 2>&1

for this test might be interrupted.

tests/f2fs/008 line 31

Quoted 4 lines
tests/f2fs/008 new file +4 -0
+	$LVM_PROG lvremove -f /dev/mapper/$lvname-snapshot $vgname >>$seqres.full 2>&1
+	$LVM_PROG lvremove -f /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+	$LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
+	$LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1

"-ff" might be better for cleanup.

Quoted 2 lines

According to 5f7a66b6dc4c ("fstests: use udevadm wait in preference to settle"), Dave recommend doing below command after above lines:

Thank you for this information. :)

Quoted 18 lines
   _udev_wait --removed /dev/mapper/$vgname-$lvname

Then, don't forget the default cleanup steps:

   cd /
   rm -f $tmp.*

tests/f2fs/008 line 36

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

Also according to 5f7a66b6dc4c ("fstests: use udevadm wait in preference to settle"), Dave recommend using a:
_udev_wait /dev/mapper/$vgname-$lvname

Quoted 5 lines

tests/f2fs/008 line 38

Quoted 2 lines
tests/f2fs/008 new file +2 -0
+
+$MKFS_F2FS_PROG /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1

"-f" to force overwrite ? Or use _mkfs_dev? But _mkfs_dev doesn't has a f2f2 specific line, maybe you'd like to write one.

Sure, maybe adapting f2fs in a separated patch, anyway, let me check this.

Quoted 12 lines

tests/f2fs/008 line 39

Quoted 2 lines
tests/f2fs/008 new file +1 -0
+mount -o discard /dev/mapper/$vgname-$lvname $SCRATCH_MNT >>$seqres.full 2>&1

_mount

tests/f2fs/008 line 43

Quoted 4 lines
tests/f2fs/008 new file +4 -0
+
+dd if=/dev/zero of=$testfile bs=1M count=20 >>$seqres.full 2>&1
+sync
+rm $testfile

"-f" ?

Quoted 7 lines

tests/f2fs/008 line 48

Quoted 5 lines
tests/f2fs/008 new file +5 -0
+sync
+
+# create a snapshot on lvm device
+$LVM_PROG lvcreate -L 1024m -s -n $lvname-snapshot /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
+umount $SCRATCH_MNT

Move this line to _cleanup, to always try to do it before removing lvm.

Will update in v3 according to all your comments.

Thanks,

Quoted 18 lines
Quoted 17 lines
tests/f2fs/008 new file +5 -0
+
+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