fstests: generic test for NFS handles
v2 cover fstests: generic test for NFS handles
Hi Eryu,
Changes since v1:
- Build time checks for open_by_handle_at()
- Update docs
- Improve usage and commit messages
- Remove unused program open_unlink
- Squash _require_exportfs into patch 3
- Change test to run on $TEST_DIR/$seq-dir
Amir Goldstein (4):
fstests: remove IRIX test program open_unlink src/open_by_handle: program to exercise open_by_handle_at() syscall src/open_by_handle: flexible usage options
fstests: add generic test for file handles
.gitignore | 1 + aclocal.m4 | 15 +++ common/rc | 10 ++ configure.ac | 1 + doc/auxiliary-programs.txt | 16 ++- doc/requirement-checking.txt | 7 ++ include/builddefs.in | 1 + src/Makefile | 7 +- src/open_by_handle.c | 261 +++++++++++++++++++++++++++++++++++++++++++ src/open_unlink.c | 147 ------------------------ tests/generic/426 | 74 ++++++++++++ tests/generic/426.out | 2 + tests/generic/group | 1 + 13 files changed, 390 insertions(+), 153 deletions(-) create mode 100644 src/open_by_handle.c delete mode 100644 src/open_unlink.c create mode 100755 tests/generic/426 create mode 100644 tests/generic/426.out
Signature · 1 line
2.7.4
PATCH v2 1/4 fstests: remove IRIX test program open_unlink
It does not seem to be used by any test.
--- src/Makefile | 3 -- src/open_unlink.c | 147 ------------------------------------------------------ 2 files changed, 150 deletions(-) delete mode 100644 src/open_unlink.c
src/Makefile +0 -3
@@ -40,14 +40,11 @@ ifeq ($(HAVE_FALLOCATE), true) LCFLAGS += -DHAVE_FALLOCATE endif -IRIX_TARGETS = open_unlink - ifeq ($(PKG_PLATFORM),linux) TARGETS += $(LINUX_TARGETS) endif ifeq ($(PKG_PLATFORM),irix) -TARGETS += $(IRIX_TARGETS) LLDLIBS += -lgen endif
src/open_unlink.c deleted +0 -147
147 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/4 src/open_by_handle: program to exercise open_by_handle_at() syscall
In reply to Amir GoldsteinThis is a clone of src/stale_handle.c test that uses generic open_by_handle_at() syscall instead of the xfs specific ioctl.
No test is using this program yet.
--- .gitignore | 1 + aclocal.m4 | 15 ++++++ configure.ac | 1 + include/builddefs.in | 1 + src/Makefile | 4 ++ src/open_by_handle.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+) create mode 100644 src/open_by_handle.c
.gitignore +1 -0
@@ -80,6 +80,7 @@ /src/multi_open_unlink /src/nametest /src/nsexec +/src/open_by_handle /src/permname /src/preallo_rw_pattern_reader /src/preallo_rw_pattern_writer
aclocal.m4 +15 -0
@@ -37,6 +37,21 @@ AC_DEFUN([AC_PACKAGE_WANT_FALLOCATE], [ have_fallocate=false; AC_MSG_RESULT(no) ]) AC_SUBST(have_fallocate) ]) + +AC_DEFUN([AC_PACKAGE_WANT_OPEN_BY_HANDLE_AT], + [ AC_MSG_CHECKING([for open_by_handle_at]) + AC_TRY_LINK([ +#define _GNU_SOURCE +#include <fcntl.h> + ], + [ + struct file_handle fh; + open_by_handle_at(0, &fh, 0); + ], + [ have_open_by_handle_at=true; AC_MSG_RESULT(yes) ], + [ have_open_by_handle_at=false; AC_MSG_RESULT(no) ]) + AC_SUBST(have_open_by_handle_at) + ]) m4_include([m4/multilib.m4]) m4_include([m4/package_acldev.m4]) m4_include([m4/package_aiodev.m4])
configure.ac +1 -0
@@ -75,6 +75,7 @@ in AC_PACKAGE_WANT_DMAPI AC_PACKAGE_WANT_LINUX_FIEMAP_H AC_PACKAGE_WANT_FALLOCATE + AC_PACKAGE_WANT_OPEN_BY_HANDLE_AT AC_PACKAGE_WANT_LINUX_PRCTL_H AC_PACKAGE_WANT_LINUX_FS_H AC_PACKAGE_WANT_SSL
include/builddefs.in +1 -0
@@ -61,6 +61,7 @@ ENABLE_SHARED = @enable_shared@ HAVE_DB = @have_db@ HAVE_AIO = @have_aio@ HAVE_FALLOCATE = @have_fallocate@ +HAVE_OPEN_BY_HANDLE_AT = @have_open_by_handle_at@ HAVE_SSL = @have_ssl@ HAVE_DMAPI = @have_dmapi@ HAVE_ATTR_LIST = @have_attr_list@
src/Makefile +4 -0
@@ -36,6 +36,10 @@ ifeq ($(HAVE_FIEMAP), true) LINUX_TARGETS += fiemap-tester endif +ifeq ($(HAVE_OPEN_BY_HANDLE_AT), true) +LINUX_TARGETS += open_by_handle +endif + ifeq ($(HAVE_FALLOCATE), true) LCFLAGS += -DHAVE_FALLOCATE endif
src/open_by_handle.c new file +143 -0
143 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/4 src/open_by_handle: flexible usage options
In reply to Amir GoldsteinMore usage options for testing open_by_handle, which are needed for testing stable handles across copy up in overlayfs.
usage: open_by_handle [-c|-l|-u|-d] <test_dir> [num_files]
Examples:
1. Create test set of N files and try to get their NFS handles:
open_by_handle -c <test_dir> [N]
This is used by new helper _require_exportfs() to check if filesystem supports exportfs
2. Get file handles for existing test set, drop caches and try to open all files by handle:
open_by_handle <test_dir> [N]
3. Get file handles for existing test set, unlink all test files, drop caches, try to open all files by handle and expect ESTALE:
open_by_handle -d <test_dir> [N]
4. Get file handles for existing test set, hardlink all test files, then unlink the original files, drop caches and try to open all files by handle (should work):
open_by_handle -l <test_dir> [N]
open_by_handle -u <test_dir> [N]
This test is done with 2 invocations of the program, first to hardlink (-l) and then to unlink the originals (-u), because we would like to be able to perform the hardlinks on overlay lower layer and unlink on upper layer.
NOTE that open_by_handle -u doesn't check if the files are hardlinked, it just assumes that they are. If they are not then the test will fail, because file handles would be stale.
--- common/rc | 10 +++ doc/auxiliary-programs.txt | 16 ++++- doc/requirement-checking.txt | 7 ++ src/open_by_handle.c | 156 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 167 insertions(+), 22 deletions(-)
common/rc +10 -0
@@ -2857,6 +2857,16 @@ _require_freeze() [ $result -eq 0 ] || _notrun "$FSTYP does not support freezing" } +# Does NFS export work on this fs? +_require_exportfs() +{ + _require_test_program "open_by_handle" + mkdir -p "$TEST_DIR"/exportfs_test + $here/src/open_by_handle -c "$TEST_DIR"/exportfs_test 2>&1 \ + || _notrun "$FSTYP does not support NFS export" +} + + # Does shutdown work on this fs? _require_scratch_shutdown() {
doc/auxiliary-programs.txt +13 -3
@@ -15,9 +15,10 @@ note the dependency with: Contents: - - af_unix -- Create an AF_UNIX socket - - stat_test -- statx syscall exercise - - xfs_io -- General I/O operation exercise + - af_unix -- Create an AF_UNIX socket + - open_by_handle -- open_by_handle_at syscall exercise + - stat_test -- statx syscall exercise + - xfs_io -- General I/O operation exercise ==================
@@ -28,6 +29,15 @@ af_unix The af_unix program creates an AF_UNIX socket at the given location. +open_by_handle + + The open_by_handle program exercises the open_by_handle_at() system + call. It can check if file handles are valid or stale after certain + filesystem operations. + + See also: + _require_exportfs + stat_test The stat_test program is primarily designed to exercise the statx()
doc/requirement-checking.txt +7 -0
@@ -15,6 +15,7 @@ they have. This is done with _require_<xxx> macros, which may take parameters. (2) Filesystem capability requirements. _require_chattr <letters> + _require_exportfs (3) System call requirements.
@@ -86,6 +87,12 @@ _require_chattr <letters> tests to see if setting the append-only and immutable attributes on a file (chattr +a +i) is supported. +_require_exportfs + + The test requires that the $TEST_DEV filesystem supports NFS export. + The test also requires the use of the open_by_handle_at() system call and + will be skipped if it isn't available in the kernel. + ======================== SYSTEM CALL REQUIREMENTS
src/open_by_handle.c +137 -19
231 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 4/4 fstests: add generic test for file handles
In reply to Amir GoldsteinCloned from xfs specific test xfs/238, which checks stale file handles of deleted files.
This test uses the generic open_by_handle_at() syscall and also tests for non-stale file handles of linked files.
--- tests/generic/426 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/426.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/426 create mode 100644 tests/generic/426.out
tests/generic/426 new file +74 -0
@@ -0,0 +1,74 @@ +#! /bin/bash +# FS QA Test No. 426 +# +# Check stale handles pointing to unlinked files +# and non-stale handles pointing to linked files +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +# _require_exportfs already requires open_by_handle, but let's not count on it +_require_test_program "open_by_handle" +_require_exportfs + +numfiles=1024 +testdir=$TEST_DIR/$seq-dir +mkdir -p $testdir + +# Check stale handles to deleted files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle -d $testdir $numfiles + +# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfiles + +echo "Silence is golden" +status=$? +exit
tests/generic/426.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 426 +Silence is golden
tests/generic/group +1 -0
@@ -428,3 +428,4 @@ 423 auto quick 424 auto quick 425 auto quick attr +426 auto quick exportfs
Signature · 1 line
2.7.4
Re: [PATCH v2 4/4] fstests: add generic test for file handles
Quoted 81 lines · Amir Goldstein
Cloned from xfs specific test xfs/238, which checks stale file handles of deleted files.
This test uses the generic
open_by_handle_at()syscall and also tests for non-stale file handles of linked files.Signed-off-by Amir Goldstein <[email protected]>--- tests/generic/426 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/426.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/426 create mode 100644 tests/generic/426.outtests/generic/426 new file +60
-0@@ -0,0 +1,74 @@ +#! /bin/bash +# FS QA Test No. 426 +# +# Check stale handles pointing to unlinked files +# and non-stale handles pointing to linked files +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +# _require_exportfs already requires open_by_handle, but let's not count on it +_require_test_program "open_by_handle" +_require_exportfs + +numfiles=1024 +testdir=$TEST_DIR/$seq-dir +mkdir -p $testdir + +# Check stale handles to deleted files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles
tests/generic/426 line 70
Quoted 10 lines
tests/generic/426 new file +10
-0+src/open_by_handle -d $testdir $numfiles + +# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfiles
This last test still depends on test files created in the second test implicitly. Forgot to update this part?
# Check non-stale handles to files that were hardlinked and original deleted rm -f $testdir/*
src/open_by_handle -c $testdir $numfiles
src/open_by_handle -l $testdir $numfiles
src/open_by_handle -u $testdir $numfiles
tests/generic/426 line 73
Quoted 3 lines
tests/generic/426 new file +3
-0+ +echo "Silence is golden" +status=$?
$? is always 0 after echo. And any test failure could break golden image, I think status can be set to 0 unconditionally.
Thanks,
Eryu
Quoted 21 lines
tests/generic/426 new file +1
-0+exittests/generic/426.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 426 +Silence is goldentests/generic/group +1
-0@@ -428,3 +428,4 @@ 423 auto quick 424 auto quick 425 auto quick attr +426 auto quick exportfsSignature · 1 line
2.7.4
Re: [PATCH v2 4/4] fstests: add generic test for file handles
Quoted 87 lines · Eryu Guan
Quoted 86 lines · Amir Goldstein
Cloned from xfs specific test xfs/238, which checks stale file handles of deleted files.
This test uses the generic
open_by_handle_at()syscall and also tests for non-stale file handles of linked files.Signed-off-by Amir Goldstein <[email protected]>--- tests/generic/426 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/426.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/426 create mode 100644 tests/generic/426.outtests/generic/426 new file +65
-0@@ -0,0 +1,74 @@ +#! /bin/bash +# FS QA Test No. 426 +# +# Check stale handles pointing to unlinked files +# and non-stale handles pointing to linked files +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +# _require_exportfs already requires open_by_handle, but let's not count on it +_require_test_program "open_by_handle" +_require_exportfs + +numfiles=1024 +testdir=$TEST_DIR/$seq-dir +mkdir -p $testdir + +# Check stale handles to deleted files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle -d $testdir $numfiles + +# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles
Quoted 8 lines
tests/generic/426 line 70
Quoted 5 lines
tests/generic/426 new file +5
-0+src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfilesThis last test still depends on test files created in the second test implicitly. Forgot to update this part?
Intentional.
It's the intended usage to create a test set with -c (imagine this is going to done on lower layer)
then link the test set with -l (imagine this on either lower or overlay) then unlink the test set with -u (imagine this on overlay).
So as a rule of thumb, rm -f is only added as extra safety before a src/open_by_handle -c line
Quoted 7 lines
# Check non-stale handles to files that were hardlinked and original deleted rm -f $testdir/*
src/open_by_handle -c $testdir $numfiles
src/open_by_handle -l $testdir $numfiles
src/open_by_handle -u $testdir $numfiles
Quoted 7 lines
tests/generic/426 line 73
Quoted 3 lines
tests/generic/426 new file +3
-0+ +echo "Silence is golden" +status=$?$? is always 0 after echo. And any test failure could break golden image, I think status can be set to 0 unconditionally.
Indeed. a combination of copy&paste from xfs/238 and me moving Silence is golden to end. Let me know if you want me to re-post for this
Re: [PATCH v2 4/4] fstests: add generic test for file handles
On Thu, Apr 20, 2017 at 09:34:48AM +0300, Amir Goldstein wrote:
..
Quoted 12 lines
Quoted 11 lines
tests/generic/426 line 70
Quoted 8 lines
tests/generic/426 new file +8
-0+# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfilesThis last test still depends on test files created in the second test implicitly. Forgot to update this part?
Quoted 5 lines
Intentional.
It's the intended usage to create a test set with -c (imagine this is going to done on lower layer)
then link the test set with -l (imagine this on either lower or overlay) then unlink the test set with -u (imagine this on overlay).
Yeah, that makes more sense in an overlay-specific test & operating on multiple layers. But I don't see the point in this generic test by doing so, as all these operations are clearly done on the same layer. So I think adding "rm -f" and "-c" run in this test won't change test behavior, but could avoid the implicit dependency.
Anyway, at least this is worth some comments on the implicit dependency.
Quoted 19 lines
So as a rule of thumb, rm -f is only added as extra safety before a src/open_by_handle -c line
Quoted 7 lines
# Check non-stale handles to files that were hardlinked and original deleted rm -f $testdir/*
src/open_by_handle -c $testdir $numfiles
src/open_by_handle -l $testdir $numfiles
src/open_by_handle -u $testdir $numfilesQuoted 7 lines
tests/generic/426 line 73
Quoted 3 lines
tests/generic/426 new file +3
-0+ +echo "Silence is golden" +status=$?$? is always 0 after echo. And any test failure could break golden image, I think status can be set to 0 unconditionally.
Quoted 2 lines
Indeed. a combination of copy&paste from xfs/238 and me moving Silence is golden to end. Let me know if you want me to re-post for this
I can fix this status issue, but seems you need to re-post anyway to add more comments or empty $testdir before each test :)
Thanks,
Eryu
Re: [PATCH v2 4/4] fstests: add generic test for file handles
Quoted 20 lines · Eryu Guan
On Thu, Apr 20, 2017 at 09:34:48AM +0300, Amir Goldstein wrote:
..Quoted 12 lines
Quoted 11 lines
tests/generic/426 line 70
Quoted 8 lines
tests/generic/426 new file +8
-0+# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfilesThis last test still depends on test files created in the second test implicitly. Forgot to update this part?
Quoted 5 lines
Intentional.
It's the intended usage to create a test set with -c (imagine this is going to done on lower layer)
then link the test set with -l (imagine this on either lower or overlay) then unlink the test set with -u (imagine this on overlay).
Quoted 6 lines
Yeah, that makes more sense in an overlay-specific test & operating on multiple layers. But I don't see the point in this generic test by doing so, as all these operations are clearly done on the same layer. So I think adding "rm -f" and "-c" run in this test won't change test behavior, but could avoid the implicit dependency.
You are right. It wont change the test.
Quoted 2 lines
Anyway, at least this is worth some comments on the implicit dependency.
I'll take the easier choice ;-)
Quoted 27 lines
Quoted 19 lines
So as a rule of thumb, rm -f is only added as extra safety before a src/open_by_handle -c line
Quoted 7 lines
# Check non-stale handles to files that were hardlinked and original deleted rm -f $testdir/*
src/open_by_handle -c $testdir $numfiles
src/open_by_handle -l $testdir $numfiles
src/open_by_handle -u $testdir $numfilesQuoted 7 lines
tests/generic/426 line 73
Quoted 3 lines
tests/generic/426 new file +3
-0+ +echo "Silence is golden" +status=$?$? is always 0 after echo. And any test failure could break golden image, I think status can be set to 0 unconditionally.
Quoted 2 lines
Indeed. a combination of copy&paste from xfs/238 and me moving Silence is golden to end. Let me know if you want me to re-post for this
I can fix this status issue, but seems you need to re-post anyway to add more comments or empty $testdir before each test :)
Thanks,
Eryu
PATCH v3 4/4 fstests: add generic test for file handles
In reply to Amir GoldsteinCloned from xfs specific test xfs/238, which checks stale file handles of deleted files.
This test uses the generic open_by_handle_at() syscall and also tests for non-stale file handles of linked files.
--- tests/generic/426 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/426.out | 2 ++ tests/generic/group | 1 + 3 files changed, 79 insertions(+) create mode 100755 tests/generic/426 create mode 100644 tests/generic/426.out
Eryu,
Avoiding unneeded spam to the list,
here is a re-send of the last patch with your requested fixes.
Thanks,
Amir.
tests/generic/426 new file +76 -0
@@ -0,0 +1,76 @@ +#! /bin/bash +# FS QA Test No. 426 +# +# Check stale handles pointing to unlinked files +# and non-stale handles pointing to linked files +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +# _require_exportfs already requires open_by_handle, but let's not count on it +_require_test_program "open_by_handle" +_require_exportfs + +numfiles=1024 +testdir=$TEST_DIR/$seq-dir +mkdir -p $testdir + +# Check stale handles to deleted files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle -d $testdir $numfiles + +# Check non-stale handles to linked files +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle $testdir $numfiles + +# Check non-stale handles to files that were hardlinked and original deleted +rm -f $testdir/* +src/open_by_handle -c $testdir $numfiles +src/open_by_handle -l $testdir $numfiles +src/open_by_handle -u $testdir $numfiles + +echo "Silence is golden" +status=0 +exit
tests/generic/426.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 426 +Silence is golden
tests/generic/group +1 -0
@@ -428,3 +428,4 @@ 423 auto quick 424 auto quick 425 auto quick attr +426 auto quick exportfs
Signature · 1 line
2.7.4
Re: [PATCH v2 2/4] src/open_by_handle: program to exercise open_by_handle_at() syscall
In reply to Amir GoldsteinHi, Amir:
src/open_by_handle.c line 122
Quoted 11 lines
src/open_by_handle.c new file +11
-0+/* +* now drop the caches so that unlinked inodes are reclaimed and +* buftarg page cache is emptied so that the inode cluster has to be +* fetched from disk again for the open_by_handle() call. +*/ + ret =system ("echo 3 > /proc/sys/vm/drop_caches" ); +if (ret <0 ) { +perror ("drop_caches" ); +return EXIT_FAILURE ; + } +
The original value of /proc/sys/vm/drop_caches is 0 in my rpi3. After this test, it turns to 3. Is it necessary to restore it ?
Signature · 2 lines
Cheers, Rock