src/open_by_handle: flexible usage options

More 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.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Amir Goldstein
2017-04-19 19:29:18 +03:00
committed by Eryu Guan
parent b34b378566
commit 5210726732
4 changed files with 168 additions and 23 deletions
+13 -3
View File
@@ -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()
+7
View File
@@ -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