Whamcloud - gitweb
LU-2935 tests: Test for layout swap on open unlinked file 01/7301/5
authorSwapnil Pimpale <spimpale@ddn.com>
Mon, 12 Aug 2013 11:11:00 +0000 (16:41 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 11 Sep 2013 03:37:53 +0000 (03:37 +0000)
This regression test verifies that layout swap works correctly on an
open unlinked file

Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Change-Id: Ib0de7de21286c3c9b37625008432ffd080de589b
Reviewed-on: http://review.whamcloud.com/7301
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity.sh

index 311beef..c740e59 100644 (file)
@@ -11634,6 +11634,32 @@ test_235() {
 }
 run_test 235 "LU-1715: flock deadlock detection does not work properly"
 
 }
 run_test 235 "LU-1715: flock deadlock detection does not work properly"
 
+#LU-2935
+test_236() {
+       check_swap_layouts_support && return 0
+       test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+
+       local ref1=/etc/passwd
+       local ref2=/etc/group
+       local file1=$DIR/$tdir/f1
+       local file2=$DIR/$tdir/f2
+
+       $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
+       cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
+       $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
+       cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
+       exec {FD}<>$file2
+       rm $file2
+       $LFS swap_layouts $file1 /proc/self/fd/${FD} ||
+               error "cannot swap layouts of '$file1' and /proc/self/fd/${FD}"
+       exec {FD}>&-
+       cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
+
+       #cleanup
+       rm -rf $DIR/$tdir
+}
+run_test 236 "Layout swap on open unlinked file"
+
 #
 # tests that do cleanup/setup should be run at the end
 #
 #
 # tests that do cleanup/setup should be run at the end
 #