Overlayfs exportfs tests
v2 cover Overlayfs exportfs tests
Eryu,
This is the 2nd revision of test for overlayfs NFS export.
Changes since v1:
- Added new generic/exportfs test instead of changing existing test
- Addressed review comments on open_by_handle [-i|-o] patch
- Added the test that uses open_by_handle [-i|-o] in the same patch
- Split new overlay/exportfs tests to four tests, a pair of tests for samefs and a pair of tests for non-samefs configuration.
- For each configuration, one test requires and enables redirect_dir for directory rename test cases and both tests require and enable nfs_export feature.
The new overlay tests don't run on upstream kernel and pass with my overlayfs NFS export V3 branch [1]. You may want to wait with merging those tests until overlayfs NFS support is merged.
Merging patches 1-3 seems like a good idea to me regardless of overlayfs NFS export support.
Thanks,
Amir.
[1] https://github.com/amir73il/linux/commits/ovl-nfs-export-v3
Amir Goldstein (7):
open_by_handle: verify dir content only with -r flag generic/exportfs: golden output is not silent generic/exportfs: test decoding file handles after cycle mount
overlay: test encode/decode overlay file handles
overlay: test encode/decode of non-samefs overlay file handles
overlay: test encode/decode overlay file handles with renames
overlay: test encode/decode of non-samefs overlay file handles with
renames
src/open_by_handle.c | 143 ++++++++++++++++++++++------ tests/generic/426 | 1 - tests/generic/426.out | 1 - tests/generic/467 | 1 - tests/generic/467.out | 1 - tests/generic/477 | 107 +++++++++++++++++++++ tests/generic/477.out | 5 + tests/generic/group | 1 + tests/overlay/050 | 237 ++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/050.out | 31 ++++++ tests/overlay/051 | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/051.out | 31 ++++++ tests/overlay/052 | 183 ++++++++++++++++++++++++++++++++++++ tests/overlay/052.out | 22 +++++ tests/overlay/053 | 199 +++++++++++++++++++++++++++++++++++++++ tests/overlay/053.out | 22 +++++ tests/overlay/group | 4 + 17 files changed, 1208 insertions(+), 35 deletions(-) create mode 100755 tests/generic/477 create mode 100644 tests/generic/477.out create mode 100755 tests/overlay/050 create mode 100644 tests/overlay/050.out create mode 100755 tests/overlay/051 create mode 100644 tests/overlay/051.out create mode 100755 tests/overlay/052 create mode 100644 tests/overlay/052.out create mode 100755 tests/overlay/053 create mode 100644 tests/overlay/053.out
Signature · 1 line
2.7.4
PATCH v2 1/7 open_by_handle: verify dir content only with -r flag
Without -r flag file handles are opened, but file content is not read. Treat dir file hanldes, similarly. without -r flag, open dir file handle, but don't verify its content.
This is going to be used by tests for which dir content is changed between encode and decode of dir file handle.
--- src/open_by_handle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/open_by_handle.c +1 -1
@@ -412,7 +412,7 @@ int main(int argc, char **argv)if (!nlink) {printf ("open_by_handle(%s) opened an unlinked dir!\n" , dname);return EXIT_FAILURE ; - }else { + }else if (rd) {/* * Sanity check dir fd - expect to access orig file IFF * it was not unlinked nor renamed.
Signature · 1 line
2.7.4
PATCH v2 2/7 generic/exportfs: golden output is not silent
In reply to Amir Goldstein--- tests/generic/426 | 1 - tests/generic/426.out | 1 - tests/generic/467 | 1 - tests/generic/467.out | 1 - 4 files changed, 4 deletions(-)
tests/generic/426 +0 -1
@@ -90,6 +90,5 @@ create_test_files $testdir test_file_handles $testdir -l test_file_handles $testdir -u -echo "Silence is golden" status=0 exit
tests/generic/426.out +0 -1
@@ -3,4 +3,3 @@ test_file_handles TEST_DIR/426-dir -d test_file_handles TEST_DIR/426-dir test_file_handles TEST_DIR/426-dir -l test_file_handles TEST_DIR/426-dir -u -Silence is golden
tests/generic/467 +0 -1
@@ -114,6 +114,5 @@ mkdir -p $testdir.new mv $testdir/* $testdir.new/ test_file_handles $testdir.new -rp -echo "Silence is golden" status=0 exit
tests/generic/467.out +0 -1
@@ -7,4 +7,3 @@ test_file_handles TEST_DIR/467-dir -ur test_file_handles TEST_DIR/467-dir -mr test_file_handles TEST_DIR/467-dir.renamed -rp test_file_handles TEST_DIR/467-dir.new -rp -Silence is golden
Signature · 1 line
2.7.4
PATCH v2 3/7 generic/exportfs: test decoding file handles after cycle mount
In reply to Amir Goldsteinopen_by_handle can now store and load file handles from a file:
usage:
open_by_handle -p -o <handles_file> <test_dir> [N] open_by_handle -p -i <handles_file> <test_dir> [N]
Add a new generic/exportfs test to use these new options to test decoding file handles after cycle mount and after directory renames.
--- src/open_by_handle.c | 141 +++++++++++++++++++++++++++++++++++++++----------- tests/generic/477 | 107 ++++++++++++++++++++++++++++++++++++++ tests/generic/477.out | 5 ++ tests/generic/group | 1 + 4 files changed, 224 insertions(+), 30 deletions(-) create mode 100755 tests/generic/477 create mode 100644 tests/generic/477.out
src/open_by_handle.c +111 -30
@@ -27,7 +27,7 @@/* -usage: open_by_handle [-cludmrwapk] <test_dir> [num_files] +usage: open_by_handle [-cludmrwapk] [<-i|-o> <handles_file>] <test_dir> [num_files] Examples:
@@ -43,30 +43,36 @@ Examples: open_by_handle -p <test_dir> [N] -3. Get file handles for existing test set, write data to files, +3. Get file handles for existing test set and write them to a file. + Read file handles from file and open files by handle: + + open_by_handle -p -o <handles_file> <test_dir> [N] + open_by_handle -p -i <handles_file> <test_dir> [N] + +4. Get file handles for existing test set, write data to files, drop caches, open all files by handle, read and verify written data, write new data to file: open_by_handle -rwa <test_dir> [N] -4. Get file handles for existing test set, unlink all test files, +5. Get file handles for existing test set, unlink all test files, remove test_dir, drop caches, try to open all files by handle and expect ESTALE: open_by_handle -dp <test_dir> [N] -5. Get file handles for existing test set, keep open file handles for all +6. Get file handles for existing test set, keep open file handles for all test files, unlink all test files, drop caches and try to open all files by handle (should work): open_by_handle -dk <test_dir> [N] -6. Get file handles for existing test set, rename all test files, +7. Get file handles for existing test set, rename all test files, drop caches, try to open all files by handle (should work): open_by_handle -m <test_dir> [N] -7. Get file handles for existing test set, hardlink all test files, +8. 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):
@@ -103,7 +109,7 @@ struct handle {void usage (void ) { -fprintf (stderr,"usage: open_by_handle [-cludmrwapk] <test_dir> [num_files]\n" ); +fprintf (stderr,"usage: open_by_handle [-cludmrwapk] [<-i|-o> <handles_file>] <test_dir> [num_files]\n" );fprintf (stderr,"\n" );fprintf (stderr,"open_by_handle -c <test_dir> [N] - create N test files under test_dir, try to get file handles and exit\n" );fprintf (stderr,"open_by_handle <test_dir> [N] - get file handles of test files, drop caches and try to open by handle\n" );
@@ -116,6 +122,8 @@ void usage(void)fprintf (stderr,"open_by_handle -d <test_dir> [N] - unlink test files and hardlinks, drop caches and try to open by handle\n" );fprintf (stderr,"open_by_handle -m <test_dir> [N] - rename test files, drop caches and try to open by handle\n" );fprintf (stderr,"open_by_handle -p <test_dir> - create/delete and try to open by handle also test_dir itself\n" ); +fprintf (stderr,"open_by_handle -i <handles_file> <test_dir> [N] - read test files handles from file and try to open by handle\n" ); +fprintf (stderr,"open_by_handle -o <handles_file> <test_dir> [N] - get file handles of test files and write handles to file\n" );exit (EXIT_FAILURE ); }
@@ -131,15 +139,17 @@ int main(int argc, char **argv)char *test_dir;char *mount_dir;int mount_fd, mount_id; +char *infile, *outfile; +int in_fd =0 , out_fd =0 ;int numfiles =1 ;int create =0 , delete =0 , nlink =1 , move =0 ;int rd =0 , wr =0 , wrafter =0 , parent =0 ;int keepopen =0 ; -if (argc <2 || argc >4 ) +if (argc <2 )usage (); -while ((c =getopt (argc, argv,"cludmrwapk" )) !=-1 ) { +while ((c =getopt (argc, argv,"cludmrwapki:o:" )) !=-1 ) {switch (c) {case 'c' : create =1 ;
@@ -176,13 +186,29 @@ int main(int argc, char **argv)case 'k' : keepopen =1 ;break ; +case 'i' : + infile = optarg; + in_fd =open (infile,O_RDONLY ); +if (in_fd <0 ) { +perror (infile); +return EXIT_FAILURE ; + } +break ; +case 'o' : + outfile = optarg; + out_fd =creat (outfile,0644 ); +if (out_fd <0 ) { +perror (outfile); +return EXIT_FAILURE ; + } +break ;default :fprintf (stderr,"illegal option '%s'\n" , argv[optind]);case 'h' :usage (); } } -if (optind == argc || optind >2 ) +if (optind == argc)usage (); test_dir = argv[optind++];if (optind < argc)
@@ -192,12 +218,34 @@ int main(int argc, char **argv)usage (); } -if (parent) { +/* +* The way we determine the mount_dir to be used for mount_fd argument +* for open_by_handle_at() depends on other command line arguments: +* +* -p flag usually (see -i below) implies that test_dir is NOT a mount +* point, but a directory inside a mount point that we will create +* and/or encode/decode during the test, so we use test_dir's parent +* for mount_fd. Even when not creatig test_dir, if we would use +* test_dir as mount_fd, then drop_caches will not drop the test_dir +* dcache entry. +* +* If -p is not specified, we don't have a hint whether test_dir is a +* mount point or not, so we assume the worst case, that it is a +* mount point and therefore, we cannnot use parent as mount_fd, +* because parent may be on a differnt file system. +* +* -i flag, even with -p flag, implies that test_dir IS a mount point, +* because we are testing open by handle of dir, which may have been +* deleted or renamed and we are not creating nor encoding the +* directory file handle. -i flag is meant to be used for tests +* after encoding file handles and mount cycle the file system. If +* we would require the test to pass in with -ip the test_dir we +* want to decode and not the mount point, that would have populated +* the dentry cache and the use of -ip flag combination would not +* allow testing decode of dir file handle in cold dcache scenario. +*/ +if (parent && !in_fd) {strcpy (dname, test_dir); -/* -* -p flag implies that test_dir is NOT a mount point, -* so its parent can be used as mount_fd for open_by_handle_at. -*/ mount_dir =dirname (dname);if (create) ret =mkdir (test_dir,0700 );
@@ -241,15 +289,26 @@ int main(int argc, char **argv)/* sync to get the new inodes to hit the disk */ sync (); -/* create the handles */ +/* +* encode the file handles or read them from file (-i) and maybe store +* them to a file (-o). +*/ for (i=0 ; i < numfiles; i++) {sprintf (fname,"%s/file%06d" , test_dir, i); - handle[i].fh.handle_bytes =MAX_HANDLE_SZ ; - ret =name_to_handle_at (AT_FDCWD , fname, &handle[i].fh, &mount_id,0 ); -if (ret <0 ) { -strcat (fname,": name_to_handle" ); -perror (fname); -return EXIT_FAILURE ; +if (in_fd) { + ret =read (in_fd, (char *)&handle[i],sizeof (*handle)); +if (ret <sizeof (*handle)) { +fprintf (stderr,"failed reading file handle #%d from '%s'\n" , i, infile); +return EXIT_FAILURE ; + } + }else { + handle[i].fh.handle_bytes =MAX_HANDLE_SZ ; + ret =name_to_handle_at (AT_FDCWD , fname, &handle[i].fh, &mount_id,0 ); +if (ret <0 ) { +strcat (fname,": name_to_handle" ); +perror (fname); +return EXIT_FAILURE ; + } }if (keepopen) {/* Open without close to keep unlinked files around */
@@ -260,15 +319,37 @@ int main(int argc, char **argv)return EXIT_FAILURE ; } } +if (out_fd) { + ret =write (out_fd, (char *)&handle[i],sizeof (*handle)); +if (ret <sizeof (*handle)) { +fprintf (stderr,"failed writing file handle #%d to '%s'\n" , i, outfile); +return EXIT_FAILURE ; + } + } }if (parent) { - dir_handle.fh.handle_bytes =MAX_HANDLE_SZ ; - ret =name_to_handle_at (AT_FDCWD , test_dir, &dir_handle.fh, &mount_id,0 ); -if (ret <0 ) { -strcat (dname,": name_to_handle" ); -perror (dname); -return EXIT_FAILURE ; +if (in_fd) { + ret =read (in_fd, (char *)&dir_handle,sizeof (*handle)); +if (ret <sizeof (*handle)) { +fprintf (stderr,"failed reading dir file handle from '%s'\n" , infile); +return EXIT_FAILURE ; + } + }else { + dir_handle.fh.handle_bytes =MAX_HANDLE_SZ ; + ret =name_to_handle_at (AT_FDCWD , test_dir, &dir_handle.fh, &mount_id,0 ); +if (ret <0 ) { +strcat (dname,": name_to_handle" ); +perror (dname); +return EXIT_FAILURE ; + } + } +if (out_fd) { + ret =write (out_fd, (char *)&dir_handle,sizeof (*handle)); +if (ret <sizeof (*handle)) { +fprintf (stderr,"failed writing dir file handle to '%s'\n" , outfile); +return EXIT_FAILURE ; + } } }
@@ -289,8 +370,8 @@ int main(int argc, char **argv)close (fd); } -/* after creating test set only check that fs supports exportfs */ -if (create) +/* If creating test set or saving files handles, we are done */ +if (create || out_fd)return EXIT_SUCCESS ;/* hardlink the files */
tests/generic/477 new file +107 -0
107 lines not on this page · raw message
tests/generic/477.out new file +5 -0
@@ -0,0 +1,5 @@ +QA output created by 477 +test_file_handles after cycle mount +test_file_handles after rename parent +test_file_handles after rename grandparent +test_file_handles after move to new parent
tests/generic/group +1 -0
@@ -479,3 +479,4 @@ 474 auto quick shutdown metadata 475 shutdown auto log metadata 476 auto rw +477 auto quick exportfs
Signature · 1 line
2.7.4
PATCH v2 4/7 overlay: test encode/decode overlay file handles
In reply to Amir Goldstein- Check encode/write/decode/read content of lower/upper file handles
- Check encode/decode/write/read content of lower/upper file handles
- Check decode/read of unlinked lower/upper files and directories
- Check decode/read of lower file handles after copy up, link and unlink
This test requires and enables overlayfs NFS export support. NFS export support depends on and enables overlayfs index feature.
This test covers only encode/decode of file handles for overlayfs configuration of all layers on the same base fs.
--- tests/overlay/050 | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/050.out | 31 +++++++ tests/overlay/group | 1 + 3 files changed, 269 insertions(+) create mode 100755 tests/overlay/050 create mode 100644 tests/overlay/050.out
tests/overlay/050 new file +237 -0
@@ -0,0 +1,237 @@ +#! /bin/bash +# FS QA Test No. 050 +# +# Test encode/decode overlay file handles +# +# - Check encode/write/decode/read content of lower/upper file handles +# - Check encode/decode/write/read content of lower/upper file handles +# - Check decode/read of unlinked lower/upper files and directories +# - Check decode/read of lower file handles after copy up, link and unlink +# +# This test requires and enables overlayfs NFS export support. +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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 + +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export + +# All overlay dirs are on scratch partition +lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + + mkdir -p $dir + $here/src/open_by_handle -cp $dir $NUMFILES +} + +# Create hard links to test files +link_test_files() +{ + local dir=$1 + + $here/src/open_by_handle -l $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + local opt=$2 + + echo test_file_handles $dir $opt | _filter_scratch + $here/src/open_by_handle $opt $dir $NUMFILES +} + +# Re-create lower/upper/work dirs +create_dirs() +{ + _scratch_mkfs +} + +# Mount an overlay on $SCRATCH_MNT with all layers on scratch partition +mount_dirs() +{ + _scratch_mount -o nfs_export=on +} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper files and verify +# that handle encoded before copy up is decoded to upper after +# copy up. Verify reading data from file open by file handle +# and verify access_at() with dirfd open by file handle. +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir +# Check encode/decode of upper dir file handle +test_file_handles $SCRATCH_MNT/uppertestdir -p +# Check encode/write/decode/read/write of upper file handles +test_file_handles $SCRATCH_MNT/uppertestdir -wrap +# Check encode/decode of lower regular file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir +# Check encode/decode of lower dir file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir -p +# Check encode/write/decode/read/write of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir -wrap +unmount_dirs + +# Check copy up after encode/decode of lower/upper files +# (copy up of disconnected dentry to index dir) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode/write/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir -a +test_file_handles $SCRATCH_MNT/uppertestdir -r +# Check encode/decode/write/read of lower regular file handles +test_file_handles $SCRATCH_MNT/lowertestdir -a +test_file_handles $SCRATCH_MNT/lowertestdir -r +unmount_dirs + +# Check non-stale handles to unlinked but open lower/upper files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $upper/uppertestdir.rw +create_test_files $lower/lowertestdir +create_test_files $lower/lowertestdir.rw +mount_dirs +test_file_handles $SCRATCH_MNT/uppertestdir -dk +# Check encode/write/unlink/decode/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles $SCRATCH_MNT/lowertestdir -dk +# Check encode/write/unlink/decode/read of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir.rw -rwdk +unmount_dirs + +# Check stale handles of unlinked lower/upper files (nlink = 1,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode of upper file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -dp +# Check decode of lower file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -dp +unmount_dirs + +# Check non-stale file handles of linked lower/upper files (nlink = 1,2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after link (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir -wlr +# Check decode/read of upper file handles after link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -ur +# Check decode/read of lower file handles after copy up + link (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir -wlr +# Check decode/read of lower file handles after copy up + link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -ur +unmount_dirs + +# Check non-stale file handles of linked lower/upper hardlinks (nlink = 2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode/read of upper hardlink file handles after unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -wur +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode/read of lower hardlink file handles after copy up + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -wur +unmount_dirs + +# Check stale file handles of unlinked lower/upper hardlinks (nlink = 2,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode of upper hardlink file handles after 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -d +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode of lower hardlink file handles after copy up + 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -d +unmount_dirs + +# Check non-stale file handles of lower/upper renamed files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after rename in same upper parent +test_file_handles $SCRATCH_MNT/uppertestdir -wmr +# Check decode/read of lower file handles after copy up + rename in same merge parent +test_file_handles $SCRATCH_MNT/lowertestdir -wmr +unmount_dirs + +status=0 +exit
tests/overlay/050.out new file +31 -0
@@ -0,0 +1,31 @@ +QA output created by 050 +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -p +test_file_handles SCRATCH_MNT/uppertestdir -wrap +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -p +test_file_handles SCRATCH_MNT/lowertestdir -wrap +test_file_handles SCRATCH_MNT/uppertestdir -a +test_file_handles SCRATCH_MNT/uppertestdir -r +test_file_handles SCRATCH_MNT/lowertestdir -a +test_file_handles SCRATCH_MNT/lowertestdir -r +test_file_handles SCRATCH_MNT/uppertestdir -dk +test_file_handles SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/lowertestdir -dk +test_file_handles SCRATCH_MNT/lowertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/uppertestdir -dp +test_file_handles SCRATCH_MNT/lowertestdir -dp +test_file_handles SCRATCH_MNT/uppertestdir -wlr +test_file_handles SCRATCH_MNT/uppertestdir -ur +test_file_handles SCRATCH_MNT/lowertestdir -wlr +test_file_handles SCRATCH_MNT/lowertestdir -ur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -wur +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -wur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -d +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -d +test_file_handles SCRATCH_MNT/uppertestdir -wmr +test_file_handles SCRATCH_MNT/lowertestdir -wmr
tests/overlay/group +1 -0
@@ -49,3 +49,4 @@ 044 auto quick copyup hardlink nonsamefs 047 auto quick copyup hardlink 048 auto quick copyup hardlink +050 auto quick copyup hardlink exportfs
Signature · 1 line
2.7.4
PATCH v2 5/7 overlay: test encode/decode of non-samefs overlay file handles
In reply to Amir GoldsteinThis is a variant of overlay file handles test for an overlayfs that is composed of multiple lower layers not on the same underlying fs.
--- tests/overlay/051 | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/051.out | 31 ++++++ tests/overlay/group | 1 + 3 files changed, 286 insertions(+) create mode 100755 tests/overlay/051 create mode 100644 tests/overlay/051.out
tests/overlay/051 new file +254 -0
@@ -0,0 +1,254 @@ +#! /bin/bash +# FS QA Test No. 051 +# +# Test encode/decode overlay file handles for non-samefs. +# +# This is a variant of overlay file handles test for an overlayfs that is +# composed of multiple lower layers not on the same underlying fs. +# +# - Check encode/write/decode/read content of lower/upper file handles +# - Check encode/decode/write/read content of lower/upper file handles +# - Check decode/read of unlinked lower/upper files and directories +# - Check decode/read of lower file handles after copy up, link and unlink +# +# This test requires and enables overlayfs NFS export support. +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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.* + # Cleanup overlay scratch mount that is holding base test mount + # to prevent _check_test_fs and _test_umount from failing before + # _check_scratch_fs _scratch_umount + $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs overlay +_supported_os Linux +_require_test +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export + +# Lower is on test partition +lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq +# Upper/work are on scratch partition +middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + + mkdir -p $dir + $here/src/open_by_handle -cp $dir $NUMFILES +} + +# Create hard links to test files +link_test_files() +{ + local dir=$1 + + $here/src/open_by_handle -l $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + local opt=$2 + + echo test_file_handles $dir $opt | _filter_scratch + $here/src/open_by_handle $opt $dir $NUMFILES +} + +# Re-create lower/middle/upper/work dirs +create_dirs() +{ + # Create lower dir on test partition + rm -rf $lower + mkdir $lower + + # Create middle/upper/work dirs on scratch partition + _scratch_mkfs +} + +# Mount an overlay on $SCRATCH_MNT with lower layer on test partition +# and middle and upper layer on scratch partition +mount_dirs() +{ + _overlay_mount_dirs $middle:$lower $upper $work \ + $OVERLAY_MOUNT_OPTIONS $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper files and verify +# that handle encoded before copy up is decoded to upper after +# copy up. Verify reading data from file open by file handle +# and verify access_at() with dirfd open by file handle. +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir +# Check encode/decode of upper dir file handle +test_file_handles $SCRATCH_MNT/uppertestdir -p +# Check encode/write/decode/read/write of upper file handles +test_file_handles $SCRATCH_MNT/uppertestdir -wrap +# Check encode/decode of lower regular file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir +# Check encode/decode of lower dir file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir -p +# Check encode/write/decode/read/write of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir -wrap +unmount_dirs + +# Check copy up after encode/decode of lower/upper files +# (copy up of disconnected dentry to index dir) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode/write/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir -a +test_file_handles $SCRATCH_MNT/uppertestdir -r +# Check encode/decode/write/read of lower regular file handles +test_file_handles $SCRATCH_MNT/lowertestdir -a +test_file_handles $SCRATCH_MNT/lowertestdir -r +unmount_dirs + +# Check non-stale handles to unlinked but open lower/upper files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $upper/uppertestdir.rw +create_test_files $lower/lowertestdir +create_test_files $lower/lowertestdir.rw +mount_dirs +test_file_handles $SCRATCH_MNT/uppertestdir -dk +# Check encode/write/unlink/decode/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles $SCRATCH_MNT/lowertestdir -dk +# Check encode/write/unlink/decode/read of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir.rw -rwdk +unmount_dirs + +# Check stale handles of unlinked lower/upper files (nlink = 1,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode of upper file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -dp +# Check decode of lower file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -dp +unmount_dirs + +# Check non-stale file handles of linked lower/upper files (nlink = 1,2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after link (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir -wlr +# Check decode/read of upper file handles after link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -ur +# Check decode/read of lower file handles after copy up + link (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir -wlr +# Check decode/read of lower file handles after copy up + link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -ur +unmount_dirs + +# Check non-stale file handles of linked lower/upper hardlinks (nlink = 2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode/read of upper hardlink file handles after unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -wur +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode/read of lower hardlink file handles after copy up + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -wur +unmount_dirs + +# Check stale file handles of unlinked lower/upper hardlinks (nlink = 2,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode of upper hardlink file handles after 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -d +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode of lower hardlink file handles after copy up + 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -d +unmount_dirs + +# Check non-stale file handles of lower/upper renamed files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after rename in same upper parent +test_file_handles $SCRATCH_MNT/uppertestdir -wmr +# Check decode/read of lower file handles after copy up + rename in same merge parent +test_file_handles $SCRATCH_MNT/lowertestdir -wmr +unmount_dirs + +status=0 +exit
tests/overlay/051.out new file +31 -0
@@ -0,0 +1,31 @@ +QA output created by 051 +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -p +test_file_handles SCRATCH_MNT/uppertestdir -wrap +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -p +test_file_handles SCRATCH_MNT/lowertestdir -wrap +test_file_handles SCRATCH_MNT/uppertestdir -a +test_file_handles SCRATCH_MNT/uppertestdir -r +test_file_handles SCRATCH_MNT/lowertestdir -a +test_file_handles SCRATCH_MNT/lowertestdir -r +test_file_handles SCRATCH_MNT/uppertestdir -dk +test_file_handles SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/lowertestdir -dk +test_file_handles SCRATCH_MNT/lowertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/uppertestdir -dp +test_file_handles SCRATCH_MNT/lowertestdir -dp +test_file_handles SCRATCH_MNT/uppertestdir -wlr +test_file_handles SCRATCH_MNT/uppertestdir -ur +test_file_handles SCRATCH_MNT/lowertestdir -wlr +test_file_handles SCRATCH_MNT/lowertestdir -ur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -wur +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -wur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -d +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -d +test_file_handles SCRATCH_MNT/uppertestdir -wmr +test_file_handles SCRATCH_MNT/lowertestdir -wmr
tests/overlay/group +1 -0
@@ -50,3 +50,4 @@ 047 auto quick copyup hardlink 048 auto quick copyup hardlink 050 auto quick copyup hardlink exportfs +051 auto quick copyup hardlink exportfs nonsamefs
Signature · 1 line
2.7.4
PATCH v2 6/7 overlay: test encode/decode overlay file handles with renames
In reply to Amir Goldstein- Check decode/read of file handles after rename of parent
- Check decode/read of file handles after rename of grandparent
- Check decode/read of file handles after move to new parent
- Check encode/decode/read of file handles in non-upper overlay
This test requires and enables overlayfs NFS export support and merge dir rename support (redirect_dir).
NFS export support depends on and enables overlayfs index feature.
This test covers only encode/decode of file handles for overlayfs configuration of all layers on the same base fs.
--- tests/overlay/052 | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/052.out | 22 ++++++ tests/overlay/group | 1 + 3 files changed, 206 insertions(+) create mode 100755 tests/overlay/052 create mode 100644 tests/overlay/052.out
tests/overlay/052 new file +183 -0
@@ -0,0 +1,183 @@ +#! /bin/bash +# FS QA Test No. 052 +# +# Test encode/decode overlay file handles with renames +# +# - Check decode/read of file handles after rename of parent +# - Check decode/read of file handles after rename of grandparent +# - Check decode/read of file handles after move to new parent +# - Check encode/decode/read of file handles in non-upper overlay +# +# This test requires and enables overlayfs NFS export support and merge +# dir rename support (redirect_dir). +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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 + +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export +_require_scratch_feature redirect_dir + +# All overlay dirs are on scratch partition +lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER.2 +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + local opt=$2 + + mkdir -p $dir + $here/src/open_by_handle -cp $opt $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + shift + + echo test_file_handles $dir $* | _filter_scratch | \ + sed -e "s,$tmp\.,,g" + $here/src/open_by_handle $* $dir $NUMFILES +} + +# Re-create lower/middle/upper/work dirs +create_dirs() +{ + _scratch_mkfs + mkdir -p $middle +} + +# Mount an overlay on $SCRATCH_MNT with all layers on scratch partition +mount_dirs() +{ + _scratch_mount -o nfs_export=on,redirect_dir=on +} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper moved files +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +mkdir -p $lower/lowertestdir.lo $lower/lowertestdir.up $upper/uppertestdir.lo $upper/uppertestdir.up +mount_dirs +# Check encode/decode/read of lower/upper file handles after move to new upper testdir +test_file_handles $SCRATCH_MNT/uppertestdir -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir/* $SCRATCH_MNT/uppertestdir.up/ +mv $SCRATCH_MNT/lowertestdir/* $SCRATCH_MNT/uppertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after move to new merge testdir +test_file_handles $SCRATCH_MNT/uppertestdir.up -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/uppertestdir.lo -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir.up/* $SCRATCH_MNT/lowertestdir.up/ +mv $SCRATCH_MNT/uppertestdir.lo/* $SCRATCH_MNT/lowertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +unmount_dirs + +# Check non-stale file handles of lower/upper renamed dirs +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +create_test_files $upper/uppertestdir/subdir -w +create_test_files $lower/lowertestdir/subdir -w +mount_dirs +# Check encode/decode/read of lower/upper file handles after rename of testdir +test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after rename of testdir's parent +test_file_handles $SCRATCH_MNT/uppertestdir/subdir -p -o $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -p -o $tmp.lower_subdir_file_handles +# Rename pure upper dir +mv $SCRATCH_MNT/uppertestdir $SCRATCH_MNT/uppertestdir.new/ +# Copy up lower dir, index and rename +mv $SCRATCH_MNT/lowertestdir $SCRATCH_MNT/lowertestdir.new/ +# Check open, read and readdir from stored file handles +# (testdir argument is the mount point and NOT the dir +# we are trying to open by stored file handle) +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_subdir_file_handles +# Retry decoding lower subdir file handle when indexed testdir is in dcache +# (providing renamed testdir argument pins the indexed testdir to dcache) +test_file_handles $SCRATCH_MNT/lowertestdir.new -rp -i $tmp.lower_subdir_file_handles +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay. +# For non-upper overlay mount, nfs_export requires disabling redirect_dir. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$middle:$lower +test_file_handles $SCRATCH_MNT/lowertestdir -rp +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -rp +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay +# with non-indexed redirects from top lower layer to bottom lower layer. +# Overlay lookup cannot follow the redirect from $upper/lowertestdir.new to +# $lower/lowertestdir. Instead, we mount an overlay subtree rooted at these +# directories. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$upper/lowertestdir.new:$lower/lowertestdir +test_file_handles $SCRATCH_MNT -r +test_file_handles $SCRATCH_MNT/subdir -rp +unmount_dirs + +status=0 +exit
tests/overlay/052.out new file +22 -0
@@ -0,0 +1,22 @@ +QA output created by 052 +test_file_handles SCRATCH_MNT/uppertestdir -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.up -o upper_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.lo -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir -p -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -p -o lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir/subdir -p -o upper_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir/subdir -p -o lower_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir.new -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -rp +test_file_handles SCRATCH_MNT/lowertestdir/subdir -rp +test_file_handles SCRATCH_MNT -r +test_file_handles SCRATCH_MNT/subdir -rp
tests/overlay/group +1 -0
@@ -51,3 +51,4 @@ 048 auto quick copyup hardlink 050 auto quick copyup hardlink exportfs 051 auto quick copyup hardlink exportfs nonsamefs +052 auto quick copyup redirect exportfs
Signature · 1 line
2.7.4
PATCH v2 7/7 overlay: test encode/decode of non-samefs overlay file handles with renames
In reply to Amir GoldsteinThis is a variant of overlay file handles with renames test for an overlayfs that is composed of multiple lower layers not on the same underlying fs.
--- tests/overlay/053 | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/053.out | 22 ++++++ tests/overlay/group | 1 + 3 files changed, 222 insertions(+) create mode 100755 tests/overlay/053 create mode 100644 tests/overlay/053.out
tests/overlay/053 new file +199 -0
@@ -0,0 +1,199 @@ +#! /bin/bash +# FS QA Test No. 053 +# +# Test encode/decode of non-samefs overlay file handles with renames +# +# This is a variant of overlay file handles with renames test for an +# overlayfs that is composed of multiple lower layers not on the same +# underlying fs. +# +# - Check decode/read of file handles after rename of parent +# - Check decode/read of file handles after rename of grandparent +# - Check decode/read of file handles after move to new parent +# - Check encode/decode/read of file handles in non-upper overlay +# +# This test requires and enables overlayfs NFS export support and merge +# dir rename support (redirect_dir). +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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.* + # Cleanup overlay scratch mount that is holding base test mount + # to prevent _check_test_fs and _test_umount from failing before + # _check_scratch_fs _scratch_umount + $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs overlay +_supported_os Linux +_require_test +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export +_require_scratch_feature redirect_dir + +# Lower is on test partition +lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq +# Upper/work are on scratch partition +middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + local opt=$2 + + mkdir -p $dir + $here/src/open_by_handle -cp $opt $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + shift + + echo test_file_handles $dir $* | _filter_scratch | \ + sed -e "s,$tmp\.,,g" + $here/src/open_by_handle $* $dir $NUMFILES +} + +# Re-create lower/middle/upper/work dirs +create_dirs() +{ + # Create lower dir on test partition + rm -rf $lower + mkdir $lower + + # Create middle/upper/work dirs on scratch partition + _scratch_mkfs +} + +# Mount an overlay on $SCRATCH_MNT with lower layer on test partition +# and middle and upper layer on scratch partition +mount_dirs() +{ + _overlay_mount_dirs $middle:$lower $upper $work \ + $OVERLAY_MOUNT_OPTIONS $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper moved files +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +mkdir -p $lower/lowertestdir.lo $lower/lowertestdir.up $upper/uppertestdir.lo $upper/uppertestdir.up +mount_dirs +# Check encode/decode/read of lower/upper file handles after move to new upper testdir +test_file_handles $SCRATCH_MNT/uppertestdir -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir/* $SCRATCH_MNT/uppertestdir.up/ +mv $SCRATCH_MNT/lowertestdir/* $SCRATCH_MNT/uppertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after move to new merge testdir +test_file_handles $SCRATCH_MNT/uppertestdir.up -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/uppertestdir.lo -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir.up/* $SCRATCH_MNT/lowertestdir.up/ +mv $SCRATCH_MNT/uppertestdir.lo/* $SCRATCH_MNT/lowertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +unmount_dirs + +# Check non-stale file handles of lower/upper renamed dirs +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +create_test_files $upper/uppertestdir/subdir -w +create_test_files $lower/lowertestdir/subdir -w +mount_dirs +# Check encode/decode/read of lower/upper file handles after rename of testdir +test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after rename of testdir's parent +test_file_handles $SCRATCH_MNT/uppertestdir/subdir -p -o $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -p -o $tmp.lower_subdir_file_handles +# Rename pure upper dir +mv $SCRATCH_MNT/uppertestdir $SCRATCH_MNT/uppertestdir.new/ +# Copy up lower dir, index and rename +mv $SCRATCH_MNT/lowertestdir $SCRATCH_MNT/lowertestdir.new/ +# Check open, read and readdir from stored file handles +# (testdir argument is the mount point and NOT the dir +# we are trying to open by stored file handle) +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_subdir_file_handles +# Retry decoding lower subdir file handle when indexed testdir is in dcache +# (providing renamed testdir argument pins the indexed testdir to dcache) +test_file_handles $SCRATCH_MNT/lowertestdir.new -rp -i $tmp.lower_subdir_file_handles +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay. +# For non-upper overlay mount, nfs_export requires disabling redirect_dir. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$middle:$lower +test_file_handles $SCRATCH_MNT/lowertestdir -rp +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -rp +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay +# with non-indexed redirects from top lower layer to bottom lower layer. +# Overlay lookup cannot follow the redirect from $upper/lowertestdir.new to +# $lower/lowertestdir. Instead, we mount an overlay subtree rooted at these +# directories. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$upper/lowertestdir.new:$lower/lowertestdir +test_file_handles $SCRATCH_MNT -r +test_file_handles $SCRATCH_MNT/subdir -rp +unmount_dirs + +status=0 +exit
tests/overlay/053.out new file +22 -0
@@ -0,0 +1,22 @@ +QA output created by 053 +test_file_handles SCRATCH_MNT/uppertestdir -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.up -o upper_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.lo -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir -p -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -p -o lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir/subdir -p -o upper_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir/subdir -p -o lower_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir.new -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -rp +test_file_handles SCRATCH_MNT/lowertestdir/subdir -rp +test_file_handles SCRATCH_MNT -r +test_file_handles SCRATCH_MNT/subdir -rp
tests/overlay/group +1 -0
@@ -52,3 +52,4 @@ 050 auto quick copyup hardlink exportfs 051 auto quick copyup hardlink exportfs nonsamefs 052 auto quick copyup redirect exportfs +053 auto quick copyup redirect exportfs nonsamefs
Signature · 1 line
2.7.4
Quoted 14 lines · Amir Goldstein
Eryu,
This is the 2nd revision of test for overlayfs NFS export.
Changes since v1:
- Added new generic/exportfs test instead of changing existing test
- Addressed review comments onopen_by_handle[-i|-o] patch
- Added the test that usesopen_by_handle[-i|-o] in the same patch
- Split new overlay/exportfs tests to four tests, a pair of tests for samefs and a pair of tests for non-samefs configuration.
- For each configuration, one test requires and enablesredirect_dirfor directory rename test cases and both tests require and enablenfs_exportfeature.
Quoted 3 lines
The new overlay tests don't run on upstream kernel and pass with my overlayfs NFS export V3 branch [1]. You may want to wait with merging those tests until overlayfs NFS support is merged.
Yeah, I probably will wait and let the kernel patches go first. (And I'll go through the overlay specific patches later.)
Quoted 3 lines
Merging patches 1-3 seems like a good idea to me regardless of overlayfs NFS export support.
Patches 1-3 look good to me. One minor issue is that my compiler complained about "may be used uninitialized" on 'infile' and 'outfile'
open_by_handle.c:350:12: warning: 'outfile' may be used uninitialized in this function [-Wmaybe-uninitialized]
though I don't think we'll use them uninitialized in practice, I'd like to initialize them with NULL on commit.
Thanks for the revision!
Eryu
Quoted 26 lines · Eryu Guan
Quoted 14 lines · Amir Goldstein
Eryu,
This is the 2nd revision of test for overlayfs NFS export.
Changes since v1:
- Added new generic/exportfs test instead of changing existing test
- Addressed review comments onopen_by_handle[-i|-o] patch
- Added the test that usesopen_by_handle[-i|-o] in the same patch
- Split new overlay/exportfs tests to four tests, a pair of tests for samefs and a pair of tests for non-samefs configuration.
- For each configuration, one test requires and enablesredirect_dirfor directory rename test cases and both tests require and enablenfs_exportfeature.Quoted 3 lines
The new overlay tests don't run on upstream kernel and pass with my overlayfs NFS export V3 branch [1]. You may want to wait with merging those tests until overlayfs NFS support is merged.
Yeah, I probably will wait and let the kernel patches go first. (And I'll go through the overlay specific patches later.)
Quoted 3 lines
Merging patches 1-3 seems like a good idea to me regardless of overlayfs NFS export support.
Quoted 8 lines
Patches 1-3 look good to me. One minor issue is that my compiler complained about "may be used uninitialized" on 'infile' and 'outfile'
open_by_handle.c:350:12: warning: 'outfile' may be used uninitialized in this function [-Wmaybe-uninitialized]
though I don't think we'll use them uninitialized in practice, I'd like to initialize them with NULL on commit.
That sounds good.
Thanks,
Amir.
Re: [PATCH v2 5/7] overlay: test encode/decode of non-samefs overlay file handles
In reply to Amir GoldsteinQuoted 128 lines · Amir Goldstein
This is a variant of overlay file handles test for an overlayfs that is composed of multiple lower layers not on the same underlying fs.
Signed-off-by Amir Goldstein <[email protected]>--- tests/overlay/051 | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/051.out | 31 ++++++ tests/overlay/group | 1 + 3 files changed, 286 insertions(+) create mode 100755 tests/overlay/051 create mode 100644 tests/overlay/051.outtests/overlay/051 new file +110
-0@@ -0,0 +1,254 @@ +#! /bin/bash +# FS QA Test No. 051 +# +# Test encode/decode overlay file handles for non-samefs. +# +# This is a variant of overlay file handles test for an overlayfs that is +# composed of multiple lower layers not on the same underlying fs. +# +# - Check encode/write/decode/read content of lower/upper file handles +# - Check encode/decode/write/read content of lower/upper file handles +# - Check decode/read of unlinked lower/upper files and directories +# - Check decode/read of lower file handles after copy up, link and unlink +# +# This test requires and enables overlayfs NFS export support. +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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.* + # Cleanup overlay scratch mount that is holding base test mount + # to prevent _check_test_fs and _test_umount from failing before + # _check_scratch_fs _scratch_umount + $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs overlay +_supported_os Linux +_require_test +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export + +# Lower is on test partition +lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq +# Upper/work are on scratch partition +middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + + mkdir -p $dir + $here/src/open_by_handle -cp $dir $NUMFILES +} + +# Create hard links to test files +link_test_files() +{ + local dir=$1 + + $here/src/open_by_handle -l $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + local opt=$2 + + echo test_file_handles $dir $opt | _filter_scratch + $here/src/open_by_handle $opt $dir $NUMFILES +} + +# Re-create lower/middle/upper/work dirs +create_dirs() +{ + # Create lower dir on test partition + rm -rf $lower + mkdir $lower +
tests/overlay/051 line 120
Quoted 10 lines
tests/overlay/051 new file +10
-0+ # Create middle/upper/work dirs on scratch partition + _scratch_mkfs +} + +# Mount an overlay on $SCRATCH_MNT with lower layer on test partition +# and middle and upper layer on scratch partition +mount_dirs() +{ + _overlay_mount_dirs $middle:$lower $upper $work \ + $OVERLAY_MOUNT_OPTIONS $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
Found a bug in test when tested with NFS export disabled by default. should be:
+ _overlay_scratch_mount_dirs $middle:$lower $upper $work -o nfs_export=on
Quoted 184 lines
tests/overlay/051 new file +135
-0+} +} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper files and verify +# that handle encoded before copy up is decoded to upper after +# copy up. Verify reading data from file open by file handle +# and verify access_at() with dirfd open by file handle. +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir +# Check encode/decode of upper dir file handle +test_file_handles $SCRATCH_MNT/uppertestdir -p +# Check encode/write/decode/read/write of upper file handles +test_file_handles $SCRATCH_MNT/uppertestdir -wrap +# Check encode/decode of lower regular file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir +# Check encode/decode of lower dir file handles before copy up +test_file_handles $SCRATCH_MNT/lowertestdir -p +# Check encode/write/decode/read/write of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir -wrap +unmount_dirs + +# Check copy up after encode/decode of lower/upper files +# (copy up of disconnected dentry to index dir) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check encode/decode/write/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir -a +test_file_handles $SCRATCH_MNT/uppertestdir -r +# Check encode/decode/write/read of lower regular file handles +test_file_handles $SCRATCH_MNT/lowertestdir -a +test_file_handles $SCRATCH_MNT/lowertestdir -r +unmount_dirs + +# Check non-stale handles to unlinked but open lower/upper files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $upper/uppertestdir.rw +create_test_files $lower/lowertestdir +create_test_files $lower/lowertestdir.rw +mount_dirs +test_file_handles $SCRATCH_MNT/uppertestdir -dk +# Check encode/write/unlink/decode/read of upper regular file handles +test_file_handles $SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles $SCRATCH_MNT/lowertestdir -dk +# Check encode/write/unlink/decode/read of lower file handles across copy up +test_file_handles $SCRATCH_MNT/lowertestdir.rw -rwdk +unmount_dirs + +# Check stale handles of unlinked lower/upper files (nlink = 1,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode of upper file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -dp +# Check decode of lower file handles after unlink/rmdir (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -dp +unmount_dirs + +# Check non-stale file handles of linked lower/upper files (nlink = 1,2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after link (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir -wlr +# Check decode/read of upper file handles after link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -ur +# Check decode/read of lower file handles after copy up + link (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir -wlr +# Check decode/read of lower file handles after copy up + link + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -ur +unmount_dirs + +# Check non-stale file handles of linked lower/upper hardlinks (nlink = 2,1) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode/read of upper hardlink file handles after unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/uppertestdir -wur +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode/read of lower hardlink file handles after copy up + unlink (nlink == 1) +test_file_handles $SCRATCH_MNT/lowertestdir -wur +unmount_dirs + +# Check stale file handles of unlinked lower/upper hardlinks (nlink = 2,0) +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +# Create lower/upper hardlinks +link_test_files $lower/lowertestdir +link_test_files $upper/uppertestdir +mount_dirs +# Check encode/decode of upper hardlink file handles (nlink == 2) +test_file_handles $SCRATCH_MNT/uppertestdir +# Check decode of upper hardlink file handles after 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/uppertestdir -d +# Check encode/decode of lower hardlink file handles before copy up (nlink == 2) +test_file_handles $SCRATCH_MNT/lowertestdir +# Check decode of lower hardlink file handles after copy up + 2*unlink (nlink == 0) +test_file_handles $SCRATCH_MNT/lowertestdir -d +unmount_dirs + +# Check non-stale file handles of lower/upper renamed files +create_dirs +create_test_files $upper/uppertestdir +create_test_files $lower/lowertestdir +mount_dirs +# Check decode/read of upper file handles after rename in same upper parent +test_file_handles $SCRATCH_MNT/uppertestdir -wmr +# Check decode/read of lower file handles after copy up + rename in same merge parent +test_file_handles $SCRATCH_MNT/lowertestdir -wmr +unmount_dirs + +status=0 +exittests/overlay/051.out new file +31
-0@@ -0,0 +1,31 @@ +QA output created by 051 +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -p +test_file_handles SCRATCH_MNT/uppertestdir -wrap +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -p +test_file_handles SCRATCH_MNT/lowertestdir -wrap +test_file_handles SCRATCH_MNT/uppertestdir -a +test_file_handles SCRATCH_MNT/uppertestdir -r +test_file_handles SCRATCH_MNT/lowertestdir -a +test_file_handles SCRATCH_MNT/lowertestdir -r +test_file_handles SCRATCH_MNT/uppertestdir -dk +test_file_handles SCRATCH_MNT/uppertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/lowertestdir -dk +test_file_handles SCRATCH_MNT/lowertestdir.rw -rwdk +test_file_handles SCRATCH_MNT/uppertestdir -dp +test_file_handles SCRATCH_MNT/lowertestdir -dp +test_file_handles SCRATCH_MNT/uppertestdir -wlr +test_file_handles SCRATCH_MNT/uppertestdir -ur +test_file_handles SCRATCH_MNT/lowertestdir -wlr +test_file_handles SCRATCH_MNT/lowertestdir -ur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -wur +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -wur +test_file_handles SCRATCH_MNT/uppertestdir +test_file_handles SCRATCH_MNT/uppertestdir -d +test_file_handles SCRATCH_MNT/lowertestdir +test_file_handles SCRATCH_MNT/lowertestdir -d +test_file_handles SCRATCH_MNT/uppertestdir -wmr +test_file_handles SCRATCH_MNT/lowertestdir -wmrtests/overlay/group +1
-1@@ -50,3 +50,4 @@ 047 auto quick copyup hardlink 048 auto quick copyup hardlink 050 auto quick copyup hardlink exportfs +051 auto quick copyup hardlink exportfs nonsamefs --2.7.4
Re: [PATCH v2 7/7] overlay: test encode/decode of non-samefs overlay file handles with renames
In reply to Amir GoldsteinQuoted 126 lines · Amir Goldstein
This is a variant of overlay file handles with renames test for an overlayfs that is composed of multiple lower layers not on the same underlying fs.
Signed-off-by Amir Goldstein <[email protected]>--- tests/overlay/053 | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/053.out | 22 ++++++ tests/overlay/group | 1 + 3 files changed, 222 insertions(+) create mode 100755 tests/overlay/053 create mode 100644 tests/overlay/053.outtests/overlay/053 new file +107
-0@@ -0,0 +1,199 @@ +#! /bin/bash +# FS QA Test No. 053 +# +# Test encode/decode of non-samefs overlay file handles with renames +# +# This is a variant of overlay file handles with renames test for an +# overlayfs that is composed of multiple lower layers not on the same +# underlying fs. +# +# - Check decode/read of file handles after rename of parent +# - Check decode/read of file handles after rename of grandparent +# - Check decode/read of file handles after move to new parent +# - Check encode/decode/read of file handles in non-upper overlay +# +# This test requires and enables overlayfs NFS export support and merge +# dir rename support (redirect_dir). +# NFS export support depends on and enables overlayfs index feature. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 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.* + # Cleanup overlay scratch mount that is holding base test mount + # to prevent _check_test_fs and _test_umount from failing before + # _check_scratch_fs _scratch_umount + $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs overlay +_supported_os Linux +_require_test +_require_scratch +_require_test_program "open_by_handle" +_require_scratch_feature nfs_export +_require_scratch_feature redirect_dir + +# Lower is on test partition +lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq +# Upper/work are on scratch partition +middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +NUMFILES=1 + +# Create test dir and empty test files +create_test_files() +{ + local dir=$1 + local opt=$2 + + mkdir -p $dir + $here/src/open_by_handle -cp $opt $dir $NUMFILES +} + +# Test encode/decode file handles on overlay mount +test_file_handles() +{ + local dir=$1 + shift + + echo test_file_handles $dir $* | _filter_scratch | \ + sed -e "s,$tmp\.,,g" + $here/src/open_by_handle $* $dir $NUMFILES +} + +# Re-create lower/middle/upper/work dirs +create_dirs() +{ + # Create lower dir on test partition + rm -rf $lower + mkdir $lower +
tests/overlay/053 line 117
Quoted 10 lines
tests/overlay/053 new file +10
-0+ # Create middle/upper/work dirs on scratch partition + _scratch_mkfs +} + +# Mount an overlay on $SCRATCH_MNT with lower layer on test partition +# and middle and upper layer on scratch partition +mount_dirs() +{ + _overlay_mount_dirs $middle:$lower $upper $work \ + $OVERLAY_MOUNT_OPTIONS $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
Found a bug in test when tested with NFS export disabled by default. should be:
+ _overlay_scratch_mount_dirs $middle:$lower $upper $work -o nfs_export=on
Quoted 122 lines
tests/overlay/053 new file +82
-0+} + +# Unmount the overlay without unmounting base fs +unmount_dirs() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +# Check non-stale file handles of lower/upper moved files +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +mkdir -p $lower/lowertestdir.lo $lower/lowertestdir.up $upper/uppertestdir.lo $upper/uppertestdir.up +mount_dirs +# Check encode/decode/read of lower/upper file handles after move to new upper testdir +test_file_handles $SCRATCH_MNT/uppertestdir -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir/* $SCRATCH_MNT/uppertestdir.up/ +mv $SCRATCH_MNT/lowertestdir/* $SCRATCH_MNT/uppertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after move to new merge testdir +test_file_handles $SCRATCH_MNT/uppertestdir.up -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/uppertestdir.lo -o $tmp.lower_file_handles +mv $SCRATCH_MNT/uppertestdir.up/* $SCRATCH_MNT/lowertestdir.up/ +mv $SCRATCH_MNT/uppertestdir.lo/* $SCRATCH_MNT/lowertestdir.lo/ +# Check open and read from stored file handles +test_file_handles $SCRATCH_MNT -r -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -r -i $tmp.lower_file_handles +unmount_dirs + +# Check non-stale file handles of lower/upper renamed dirs +create_dirs +create_test_files $upper/uppertestdir -w +create_test_files $lower/lowertestdir -w +create_test_files $upper/uppertestdir/subdir -w +create_test_files $lower/lowertestdir/subdir -w +mount_dirs +# Check encode/decode/read of lower/upper file handles after rename of testdir +test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles +# Check encode/decode/read of lower/upper file handles after rename of testdir's parent +test_file_handles $SCRATCH_MNT/uppertestdir/subdir -p -o $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -p -o $tmp.lower_subdir_file_handles +# Rename pure upper dir +mv $SCRATCH_MNT/uppertestdir $SCRATCH_MNT/uppertestdir.new/ +# Copy up lower dir, index and rename +mv $SCRATCH_MNT/lowertestdir $SCRATCH_MNT/lowertestdir.new/ +# Check open, read and readdir from stored file handles +# (testdir argument is the mount point and NOT the dir +# we are trying to open by stored file handle) +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.upper_subdir_file_handles +test_file_handles $SCRATCH_MNT -rp -i $tmp.lower_subdir_file_handles +# Retry decoding lower subdir file handle when indexed testdir is in dcache +# (providing renamed testdir argument pins the indexed testdir to dcache) +test_file_handles $SCRATCH_MNT/lowertestdir.new -rp -i $tmp.lower_subdir_file_handles +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay. +# For non-upper overlay mount, nfs_export requires disabling redirect_dir. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$middle:$lower +test_file_handles $SCRATCH_MNT/lowertestdir -rp +test_file_handles $SCRATCH_MNT/lowertestdir/subdir -rp +unmount_dirs + +# Check encode/decode/read of lower file handles on lower layers only r/o overlay +# with non-indexed redirects from top lower layer to bottom lower layer. +# Overlay lookup cannot follow the redirect from $upper/lowertestdir.new to +# $lower/lowertestdir. Instead, we mount an overlay subtree rooted at these +# directories. +$MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o ro,redirect_dir=nofollow,lowerdir=$upper/lowertestdir.new:$lower/lowertestdir +test_file_handles $SCRATCH_MNT -r +test_file_handles $SCRATCH_MNT/subdir -rp +unmount_dirs + +status=0 +exittests/overlay/053.out new file +22
-0@@ -0,0 +1,22 @@ +QA output created by 053 +test_file_handles SCRATCH_MNT/uppertestdir -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.up -o upper_file_handles +test_file_handles SCRATCH_MNT/uppertestdir.lo -o lower_file_handles +test_file_handles SCRATCH_MNT -r -i upper_file_handles +test_file_handles SCRATCH_MNT -r -i lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir -p -o upper_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -p -o lower_file_handles +test_file_handles SCRATCH_MNT/uppertestdir/subdir -p -o upper_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir/subdir -p -o lower_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_file_handles +test_file_handles SCRATCH_MNT -rp -i upper_subdir_file_handles +test_file_handles SCRATCH_MNT -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir.new -rp -i lower_subdir_file_handles +test_file_handles SCRATCH_MNT/lowertestdir -rp +test_file_handles SCRATCH_MNT/lowertestdir/subdir -rp +test_file_handles SCRATCH_MNT -r +test_file_handles SCRATCH_MNT/subdir -rptests/overlay/group +1
-1@@ -52,3 +52,4 @@ 050 auto quick copyup hardlink exportfs 051 auto quick copyup hardlink exportfs nonsamefs 052 auto quick copyup redirect exportfs +053 auto quick copyup redirect exportfs nonsamefs --2.7.4