Skip to contentSkip to conversation

overlay/072: test for whiteout inode sharing

PATCH In review Chengguang Xu 5 participants 11 messages May 6, 2020 – May 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v4 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

v2->v3:
- Address Amir's comments in v2

v3->v4:
- Fix test case based on latest kernel patch(removed module param)
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7

 tests/overlay/072     | 106 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
tests/overlay/072 new file +106 -0
new file mode 100755
index 00000000..fc847092
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 072
+#
+# Test whiteout inode sharing functionality.
+#
+# A "whiteout" is an object that has special meaning in overlayfs.
+# A whiteout on an upper layer will effectively hide a matching file
+# in the lower layer, making it appear as if the file didn't exist.
+#
+# Whiteout inode sharing means multiple whiteout objects will share
+# one inode in upper layer, without this feature every whiteout object
+# will consume one inode in upper layer.
+
+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
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# 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_scratch
+
+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 ${1}`; do
+		touch $lowerdir/file${name} &>/dev/null
+	done
+}
+
+# Delete all copy-uped files in upperdir.
+make_whiteout_files()
+{
+	rm -f $SCRATCH_MNT/* &>/dev/null
+}
+
+# Check link count of whiteout files.
+# Arguments:
+# $1: Testing file number
+# $2: Expected link count
+check_whiteout_files()
+{
+	for name in `seq ${1}`; 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
+		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: Testing file number
+# $2: Expected link count
+run_test_case()
+{
+	_scratch_mkfs
+	make_lower_files ${1}
+	_scratch_mount
+	make_whiteout_files
+	check_whiteout_files ${1} ${2}
+	_scratch_unmount
+}
+
+#Test case
+file_count=10
+link_count=11
+run_test_case $file_count $link_count
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
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 v4 1/1
#1 lore raw
Quoted 4 lines · Chengguang Xu

This is a test for whiteout inode sharing feature.

Quoted 151 lines

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

v2->v3:
- Address Amir's comments in v2

v3->v4:
- Fix test case based on latest kernel patch(removed module param)
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7

 tests/overlay/072     | 106 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/072.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/overlay/072
 create mode 100644 tests/overlay/072.out
tests/overlay/072 new file +106 -0
new file mode 100755
index 00000000..fc847092
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 072
+#
+# Test whiteout inode sharing functionality.
+#
+# A "whiteout" is an object that has special meaning in overlayfs.
+# A whiteout on an upper layer will effectively hide a matching file
+# in the lower layer, making it appear as if the file didn't exist.
+#
+# Whiteout inode sharing means multiple whiteout objects will share
+# one inode in upper layer, without this feature every whiteout object
+# will consume one inode in upper layer.
+
+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
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# 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_scratch
+
+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 ${1}`; do
+               touch $lowerdir/file${name} &>/dev/null
+       done
+}
+
+# Delete all copy-uped files in upperdir.
+make_whiteout_files()
+{
+       rm -f $SCRATCH_MNT/* &>/dev/null
+}
+
+# Check link count of whiteout files.
+# Arguments:
+# $1: Testing file number
+# $2: Expected link count
+check_whiteout_files()
+{
+       for name in `seq ${1}`; 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
+               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: Testing file number
+# $2: Expected link count
+run_test_case()
+{
+       _scratch_mkfs
+       make_lower_files ${1}
+       _scratch_mount
+       make_whiteout_files
+       check_whiteout_files ${1} ${2}
+       _scratch_unmount
+}
+
+#Test case
+file_count=10
+link_count=11
+run_test_case $file_count $link_count
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
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 -1
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
--

2.20.1

#2 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

In reply to Chengguang Xu
Quoted 60 lines · Chengguang Xu

This is a test for whiteout inode sharing feature.

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

v2->v3:
- Address Amir's comments in v2

v3->v4:
- Fix test case based on latest kernel patch(removed module param)
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7

 tests/overlay/073     | 106 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/073.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/overlay/073
 create mode 100644 tests/overlay/073.out
tests/overlay/073 new file +33 -0
new file mode 100755
index 00000000..fc847092
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 073
+#
+# Test whiteout inode sharing functionality.
+#
+# A "whiteout" is an object that has special meaning in overlayfs.
+# A whiteout on an upper layer will effectively hide a matching file
+# in the lower layer, making it appear as if the file didn't exist.
+#
+# Whiteout inode sharing means multiple whiteout objects will share
+# one inode in upper layer, without this feature every whiteout object
+# will consume one inode in upper layer.
+
+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
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks

tests/overlay/073 line 43

Quoted 10 lines
tests/overlay/073 new file +10 -0
+. ./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_scratch

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

Thanks,
Eryu

Quoted 83 lines
tests/overlay/073 new file +63 -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 ${1}`; do
+		touch $lowerdir/file${name} &>/dev/null
+	done
+}
+
+# Delete all copy-uped files in upperdir.
+make_whiteout_files()
+{
+	rm -f $SCRATCH_MNT/* &>/dev/null
+}
+
+# Check link count of whiteout files.
+# Arguments:
+# $1: Testing file number
+# $2: Expected link count
+check_whiteout_files()
+{
+	for name in `seq ${1}`; 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
+		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: Testing file number
+# $2: Expected link count
+run_test_case()
+{
+	_scratch_mkfs
+	make_lower_files ${1}
+	_scratch_mount
+	make_whiteout_files
+	check_whiteout_files ${1} ${2}
+	_scratch_unmount
+}
+
+#Test case
+file_count=10
+link_count=11
+run_test_case $file_count $link_count
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/overlay/073.out new file +2 -0
new file mode 100644
index 00000000..590bbc6c
@@ -0,0 +1,2 @@
+QA output created by 073
+Silence is golden
tests/overlay/group +1 -0
index 43ad8a52..8b2276f1 100644
@@ -74,3 +74,4 @@
 070 auto quick copyup redirect nested
 071 auto quick copyup redirect nested nonsamefs
 072 auto quick copyup hardlink
+073 auto quick whiteout
Signature · 1 line
2.20.1
#3 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

---- 在 星期日, 2020-05-10 23:50:37 Eryu Guan <[email protected]> 撰写 ----

Quoted 67 lines · Chengguang Xu
Quoted 66 lines

This is a test for whiteout inode sharing feature.

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

v2->v3:
- Address Amir's comments in v2

v3->v4:
- Fix test case based on latest kernel patch(removed module param)
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7

 tests/overlay/073     | 106 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/073.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/overlay/073
 create mode 100644 tests/overlay/073.out
tests/overlay/073 new file +39 -0
new file mode 100755
index 00000000..fc847092
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 073
+#
+# Test whiteout inode sharing functionality.
+#
+# A "whiteout" is an object that has special meaning in overlayfs.
+# A whiteout on an upper layer will effectively hide a matching file
+# in the lower layer, making it appear as if the file didn't exist.
+#
+# Whiteout inode sharing means multiple whiteout objects will share
+# one inode in upper layer, without this feature every whiteout object
+# will consume one inode in upper layer.
+
+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
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
Quoted 8 lines

tests/overlay/073 line 43

Quoted 4 lines
tests/overlay/073 new file +4 -0
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

Thanks,
cgxu

#4 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 77 lines · Chengguang Xu

---- 在 星期日, 2020-05-10 23:50:37 Eryu Guan <[email protected]> 撰写 ----

Quoted 67 lines · Chengguang Xu
Quoted 66 lines

This is a test for whiteout inode sharing feature.

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

v2->v3:
- Address Amir's comments in v2

v3->v4:
- Fix test case based on latest kernel patch(removed module param)
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git/commit/?h=overlayfs-next&id=4e49695244661568130bfefcb6143dd1eaa3d8e7

 tests/overlay/073     | 106 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/073.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/overlay/073
 create mode 100644 tests/overlay/073.out
tests/overlay/073 new file +39 -0
new file mode 100755
index 00000000..fc847092
@@ -0,0 +1,106 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Chengguang Xu <[email protected]>.
+# All Rights Reserved.
+#
+# FS QA Test 073
+#
+# Test whiteout inode sharing functionality.
+#
+# A "whiteout" is an object that has special meaning in overlayfs.
+# A whiteout on an upper layer will effectively hide a matching file
+# in the lower layer, making it appear as if the file didn't exist.
+#
+# Whiteout inode sharing means multiple whiteout objects will share
+# one inode in upper layer, without this feature every whiteout object
+# will consume one inode in upper layer.
+
+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
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
Quoted 8 lines

tests/overlay/073 line 43

Quoted 4 lines
tests/overlay/073 new file +4 -0
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

Quoted 1 line

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

Thanks,
Eryu

#5 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

I've got a few.
1. LTP has the concept of require minimum kernel version.
This would mean that functionality will be not be tested if feature is backported to old kernels.
2. We could add to overlayfs advertising of supported features, like /sys/fs/ext4/features/, but it already does "advertise" the configurable features at /sys/module/overlay/parameters/, and we were already asking the question during patch review:
/* Is there a reason anyone would want not to share whiteouts? */ ofs->share_whiteout = true;
and we left the answer to "later" time.

So a simple solution would be to add the module parameter (without adding a mount option), because:
- It doesn't hurt (?)
- Somebody may end up using it, for some reason we did not think of
- We can use it in test to require the feature

The one non-trivial thing that this will require is to add Documentation of the module parameter in the section about Whiteouts and opaque directories.

Thanks,
Amir.

#6 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 22 lines · Amir Goldstein
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

I've got a few.
1. LTP has the concept of require minimum kernel version.
This would mean that functionality will be not be tested if feature is backported to old kernels.
2. We could add to overlayfs advertising of supported features, like /sys/fs/ext4/features/, but it already does "advertise" the configurable features at /sys/module/overlay/parameters/, and we were already asking the question during patch review:
/* Is there a reason anyone would want not to share whiteouts? */ ofs->share_whiteout = true;
and we left the answer to "later" time.

Quoted 5 lines

So a simple solution would be to add the module parameter (without adding a mount option), because:
- It doesn't hurt (?)
- Somebody may end up using it, for some reason we did not think of
- We can use it in test to require the feature

Yeah, I think that works. And I see that ext4 and btrfs both have a /sys/fs/<fs>/features directory and list supported features there, is this something overlay could do? Or is this basically the same thing as what you proposed?

Thanks,
Eryu

Quoted 6 lines

The one non-trivial thing that this will require is to add Documentation of the module parameter in the section about Whiteouts and opaque directories.

Thanks,
Amir.

#7 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

---- 在 星期三, 2020-05-13 09:10:19 Eryu Guan <[email protected]> 撰写 ----

Quoted 29 lines · Amir Goldstein
Quoted 22 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

I've got a few.
1. LTP has the concept of require minimum kernel version.
This would mean that functionality will be not be tested if feature is backported to old kernels.
2. We could add to overlayfs advertising of supported features, like /sys/fs/ext4/features/, but it already does "advertise" the configurable features at /sys/module/overlay/parameters/, and we were already asking the question during patch review:
/* Is there a reason anyone would want not to share whiteouts? */ ofs->share_whiteout = true;
and we left the answer to "later" time.

Quoted 5 lines

So a simple solution would be to add the module parameter (without adding a mount option), because:
- It doesn't hurt (?)
- Somebody may end up using it, for some reason we did not think of
- We can use it in test to require the feature

Quoted 5 lines

Yeah, I think that works. And I see that ext4 and btrfs both have a /sys/fs/<fs>/features directory and list supported features there, is this something overlay could do? Or is this basically the same thing as what you proposed?

IMO, for those features which don't need to change module param, maybe feature list is more suitable.

Thanks,
cgxu

#8 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 31 lines · Chengguang Xu

---- 在 星期三, 2020-05-13 09:10:19 Eryu Guan <[email protected]> 撰写 ----

Quoted 29 lines · Amir Goldstein
Quoted 27 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

I've got a few.
1. LTP has the concept of require minimum kernel version.
This would mean that functionality will be not be tested if feature is backported to old kernels.
2. We could add to overlayfs advertising of supported features, like /sys/fs/ext4/features/, but it already does "advertise" the configurable features at /sys/module/overlay/parameters/, and we were already asking the question during patch review:
/* Is there a reason anyone would want not to share whiteouts? */ ofs->share_whiteout = true;
and we left the answer to "later" time.

So a simple solution would be to add the module parameter (without adding a mount option), because:
- It doesn't hurt (?)
- Somebody may end up using it, for some reason we did not think of
- We can use it in test to require the feature

Quoted 9 lines
Quoted 5 lines

Yeah, I think that works. And I see that ext4 and btrfs both have a /sys/fs/<fs>/features directory and list supported features there, is this something overlay could do? Or is this basically the same thing as what you proposed?

IMO, for those features which don't need to change module param, maybe feature list is more suitable.

I suppose it is more suitable, but since at the moment there is only one(?) such feature and there is an open question whether it should or should not be configurable, I myself would have taken the easy path, but Miklos often has a different perspective on these sort of things...

Thanks,
Amir.

#9 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 39 lines · Amir Goldstein
Quoted 37 lines · Chengguang Xu

---- 在 星期三, 2020-05-13 09:10:19 Eryu Guan <[email protected]> 撰写 ----

Quoted 34 lines · Amir Goldstein
Quoted 22 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I see no feature detection logic, so test just fails on old kernels without this feature? I tried with v5.7-r4 kernel, test fails because each whiteout file has only one hardlink.

That's true.

I'd like to see it _notrun on old kernels where the feature is not available. But that seems hard to do.. Do you have any better ideas?

I've got a few.
1. LTP has the concept of require minimum kernel version.
This would mean that functionality will be not be tested if feature is backported to old kernels.
2. We could add to overlayfs advertising of supported features, like /sys/fs/ext4/features/, but it already does "advertise" the configurable features at /sys/module/overlay/parameters/, and we were already asking the question during patch review:
/* Is there a reason anyone would want not to share whiteouts? */ ofs->share_whiteout = true;
and we left the answer to "later" time.

Quoted 5 lines

So a simple solution would be to add the module parameter (without adding a mount option), because:
- It doesn't hurt (?)
- Somebody may end up using it, for some reason we did not think of
- We can use it in test to require the feature

Yeah, I think that works. And I see that ext4 and btrfs both have a /sys/fs/<fs>/features directory and list supported features there, is this something overlay could do? Or is this basically the same thing as what you proposed?

Quoted 8 lines
Quoted 3 lines

IMO, for those features which don't need to change module param, maybe feature list is more suitable.

I suppose it is more suitable, but since at the moment there is only one(?) such feature and there is an open question whether it should or should not be configurable, I myself would have taken the easy path, but Miklos often has a different perspective on these sort of things...

What exactly are we testing?

Hard linked whiteouts are an optimization, not something to be relied on in any case. The test should succeed even if overlayfs decides for some reason not to share the inode.

Thanks,
Miklos

#10 lore raw

Re: [PATCH v4] overlay: test for whiteout inode sharing

Quoted 7 lines
Quoted 4 lines

I suppose it is more suitable, but since at the moment there is only one(?) such feature and there is an open question whether it should or should not be configurable, I myself would have taken the easy path, but Miklos often has a different perspective on these sort of things...

What exactly are we testing?

What are testing against silent regressions.
If some change breaks whiteout share we won't know about it without a test.

Quoted 4 lines

Hard linked whiteouts are an optimization, not something to be relied on in any case. The test should succeed even if overlayfs decides for some reason not to share the inode.

The best practice would be to ask overlay if feature is supported in the kernel AND make sure that overlay mount did not disable it on a specific instance (because of upper fs capabilities). That is what _check_overlay_feature does for "features" that have both module param AND a mount option.

If overlay says that the feature is expected to be enabled on the instance, we check correctness of the feature. Otherwise, we report that "feature" is not supported on this instance.

Thanks,
Amir.