Skip to contentSkip to conversation

overlay/072: test for whiteout inode sharing

PATCH Superseded Chengguang Xu 2 participants 4 messages Apr 14, 2020

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 overlay/072: test for whiteout inode sharing

This is a test for whiteout inode sharing feature.

---
v1->v2:
- Address Amir's comments in v1.

 common/module         |   9 +++
 tests/overlay/072     | 148 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 4 files changed, 160 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
common/module +9 -0
index 39e4e793..148e8c8f 100644
@@ -81,3 +81,12 @@ _get_fs_module_param()
 {
 	cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
 }
+ # Set the value of a filesystem module parameter
+ # at /sys/module/$FSTYP/parameters/$PARAM
+ #
+ # Usage example:
+ #   _set_fs_module_param param value
+ _set_fs_module_param()
+{
+	echo ${2} > /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
+}
tests/overlay/072 new file +148 -0

148 lines not on this page · raw message

tests/overlay/072.out new file +2 -0
new file mode 100644
index 00000000..590bbc6c
@@ -0,0 +1,2 @@
+QA output created by 072
+Silence is golden
tests/overlay/group +1 -0
index 43ad8a52..8b2276f1 100644
@@ -74,3 +74,4 @@
 069 auto quick copyup hardlink exportfs nested nonsamefs
 070 auto quick copyup redirect nested
 071 auto quick copyup redirect nested nonsamefs
+072 auto quick whiteout
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Chengguang Xu

This is a test for whiteout inode sharing feature.

---
v1->v2:
- Address Amir's comments in v1.

Looks good. Some nits.
With those fixed you may add:

Quoted 45 lines
 common/module         |   9 +++
 tests/overlay/072     | 148 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 4 files changed, 160 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
common/module +9 -0
index 39e4e793..148e8c8f 100644
@@ -81,3 +81,12 @@ _get_fs_module_param()
 {
        cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
 }
+ # Set the value of a filesystem module parameter
+ # at /sys/module/$FSTYP/parameters/$PARAM
+ #
+ # Usage example:
+ #   _set_fs_module_param param value
+ _set_fs_module_param()
+{
+       echo ${2} > /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
+}
tests/overlay/072 new file +13 -0
new file mode 100755
index 00000000..e1244394
@@ -0,0 +1,148 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 072
+#
+# This is a test for whiteout inode sharing feature.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+

tests/overlay/072 line 23

Quoted 10 lines
tests/overlay/072 new file +10 -0
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+       _set_fs_module_param $param_name $orig_param_value

verify orig_param_value is not empty

tests/overlay/072 line 36

Quoted 13 lines
tests/overlay/072 new file +13 -0
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_test

test partition not used

Quoted 13 lines
tests/overlay/072 new file +13 -0
+_require_scratch
+
+param_name="whiteout_link_max"
+
+# Check overlayfs module param(whiteout_link_max)
+check_whiteout_link_max()
+{
+       orig_param_value=`_get_fs_module_param ${param_name}`
+       if [ -z ${orig_param_value} ]; then
+               _notrun "${FSTYP} does not support whiteout inode sharing"
+       fi
+}
+

tests/overlay/072 line 59

Quoted 10 lines
tests/overlay/072 new file +10 -0
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
+
+# Make some testing files in lowerdir.
+# Argument:
+# $1: Testing file number
+make_lower_files()
+{
+       for name in `seq -s' ' ${1}`

-s' ' not needed

tests/overlay/072 line 61

Quoted 2 lines
tests/overlay/072 new file +2 -0
+       do
+               touch $lowerdir/file${name} 1>&2 2>/dev/null

&>/dev/null

tests/overlay/072 line 68

Quoted 7 lines
tests/overlay/072 new file +7 -0
+       done
+}
+
+# Delete all copy-uped files in upperdir.
+make_whiteout_files()
+{
+       rm -f $SCRATCH_MNT/* 1>&2 2>/dev/null

&>/dev/null

tests/overlay/072 line 77

Quoted 9 lines
tests/overlay/072 new file +9 -0
+}
+
+# Check link count of whiteout files.
+# Arguments:
+# $1: Testing file number
+# $2: Expected link count
+check_whiteout_files()
+{
+       for name in `seq -s' ' ${1}`

-s' ' not needed

tests/overlay/072 line 85

Quoted 8 lines
tests/overlay/072 new file +8 -0
+       do
+               local real_count=`stat -c %h $upperdir/file${name} 2>/dev/null`
+               if [[ ${2} != $real_count ]]; then
+                       echo "Expected link count is ${2} but real count is $real_count, file name is file${name}"
+               fi
+       done
+       local tmpfile_count=`ls $workdir/work/\#* $workdir/index/\#* 2>/dev/null |wc -l 2>/dev/null`
+       if [[ -n $tmpfile_count && $tmpfile_count > 1 ]]; then

-n "$tmpfile_count" or you won't get desired outcome

Quoted 24 lines
tests/overlay/072 new file +24 -0
+               echo "There are more than one whiteout tmpfile in work/index dir!"
+               ls -l $workdir/work/\#* $workdir/index/\#* 2>/dev/null
+       fi
+}
+
+# Run test case with specific arguments.
+# Arguments:
+# $1: Maximum link count
+# $2: Testing file number
+# $3: Expected link count
+run_test_case()
+{
+       _scratch_mkfs
+       _set_fs_module_param $param_name ${1}
+       make_lower_files ${2}
+       _scratch_mount
+       make_whiteout_files
+       check_whiteout_files ${2} ${3}
+       _scratch_unmount
+}
+
+check_whiteout_link_max
+
+# Case1:

tests/overlay/072 line 119

Quoted 10 lines
tests/overlay/072 new file +10 -0
+# Setting whiteout_link_max=0 means whiteout files will not
+# share inode, each whiteout file will have it's own inode.
+
+link_max=0
+file_count=10
+link_count=1
+run_test_case $link_max $file_count $link_count
+
+# Case2:
+# Setting whiteout_link_max=0 means whiteout files will not

you mean whiteout_link_max=1

tests/overlay/072 line 128

Quoted 9 lines
tests/overlay/072 new file +9 -0
+# share inode, each whiteout file will have it's own inode.
+
+link_max=1
+file_count=10
+link_count=1
+run_test_case $link_max $file_count $link_count
+
+# Case3:
+# Setting whiteout_link_max>2 means whiteout files will share

you mean whiteout_link_max>1

tests/overlay/072 line 137

Quoted 9 lines
tests/overlay/072 new file +9 -0
+# inode and link count could up to whiteout_link_max.
+
+link_max=2
+file_count=10
+link_count=2
+run_test_case $link_max $file_count $link_count
+
+# Case4:
+# Setting whiteout_link_max>2 means whiteout files will share

you mean whiteout_link_max>1

Thanks,
Amir.

#2 lore raw

---- 在 星期二, 2020-04-14 11:22:26 Amir Goldstein <[email protected]> 撰写 ----

Quoted 63 lines · Chengguang Xu
Quoted 7 lines

This is a test for whiteout inode sharing feature.

---
v1->v2:
- Address Amir's comments in v1.

Looks good. Some nits.
With those fixed you may add:

Quoted 49 lines
 common/module         |   9 +++
 tests/overlay/072     | 148 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 4 files changed, 160 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
common/module +9 -0
index 39e4e793..148e8c8f 100644
@@ -81,3 +81,12 @@ _get_fs_module_param()
 {
        cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
 }
+ # Set the value of a filesystem module parameter
+ # at /sys/module/$FSTYP/parameters/$PARAM
+ #
+ # Usage example:
+ #   _set_fs_module_param param value
+ _set_fs_module_param()
+{
+       echo ${2} > /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
+}
tests/overlay/072 new file +17 -0
new file mode 100755
index 00000000..e1244394
@@ -0,0 +1,148 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 072
+#
+# This is a test for whiteout inode sharing feature.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
Quoted 9 lines

tests/overlay/072 line 23

Quoted 6 lines
tests/overlay/072 new file +6 -0
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+       _set_fs_module_param $param_name $orig_param_value

verify orig_param_value is not empty

I think if orig_param_value is empty, then test will be "not run" therefore _cleanup() will not be called.

Thanks,
cgxu

#3 lore raw
Quoted 75 lines · Chengguang Xu

---- 在 星期二, 2020-04-14 11:22:26 Amir Goldstein <[email protected]> 撰写 ----

Quoted 63 lines · Chengguang Xu
Quoted 7 lines

This is a test for whiteout inode sharing feature.

---
v1->v2:
- Address Amir's comments in v1.

Looks good. Some nits.
With those fixed you may add:

Quoted 49 lines
 common/module         |   9 +++
 tests/overlay/072     | 148 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 4 files changed, 160 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
common/module +9 -0
index 39e4e793..148e8c8f 100644
@@ -81,3 +81,12 @@ _get_fs_module_param()
 {
        cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
 }
+ # Set the value of a filesystem module parameter
+ # at /sys/module/$FSTYP/parameters/$PARAM
+ #
+ # Usage example:
+ #   _set_fs_module_param param value
+ _set_fs_module_param()
+{
+       echo ${2} > /sys/module/${FSTYP}/parameters/${1} 2>/dev/null
+}
tests/overlay/072 new file +17 -0
new file mode 100755
index 00000000..e1244394
@@ -0,0 +1,148 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 072
+#
+# This is a test for whiteout inode sharing feature.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
Quoted 9 lines

tests/overlay/072 line 23

Quoted 6 lines
tests/overlay/072 new file +6 -0
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+       _set_fs_module_param $param_name $orig_param_value

verify orig_param_value is not empty

Quoted 2 lines

I think if orig_param_value is empty, then test will be "not run" therefore _cleanup() will not be called.

_cleanup() is called also on exit 0 so also in case of _notrun

Thanks,
Amir.