+run_test 233a "checking that OBF of the FS root succeeds"
+
+test_233b() {
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
+ { skip "Need MDS version at least 2.5.90"; return; }
+
+ local fid=$($LFS path2fid $MOUNT/.lustre)
+ stat $MOUNT/.lustre/fid/$fid > /dev/null ||
+ error "cannot access $MOUNT/.lustre using its FID '$fid'"
+
+ fid=$($LFS path2fid $MOUNT/.lustre/fid)
+ stat $MOUNT/.lustre/fid/$fid > /dev/null ||
+ error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
+}
+run_test 233b "checking that OBF of the FS .lustre succeeds"
+
+test_234() {
+ local p="$TMP/sanityN-$TESTNAME.parameters"
+ save_lustre_params client "llite.*.xattr_cache" > $p
+ lctl set_param llite.*.xattr_cache 1 ||
+ { skip "xattr cache is not supported"; return 0; }
+
+ mkdir -p $DIR/$tdir || error "mkdir failed"
+ touch $DIR/$tdir/$tfile || error "touch failed"
+ # OBD_FAIL_LLITE_XATTR_ENOMEM
+ $LCTL set_param fail_loc=0x1405
+ if [ ! -f /etc/SuSE-release ]; then
+ # attr pre-2.4.44-7 had a bug with rc
+ # LU-3703 - SLES clients have older attr
+ getfattr -n user.attr $DIR/$tdir/$tfile &&
+ error "getfattr should have failed with ENOMEM"
+ fi
+ $LCTL set_param fail_loc=0x0
+ rm -rf $DIR/$tdir
+
+ restore_lustre_params < $p
+ rm -f $p
+}
+run_test 234 "xattr cache should not crash on ENOMEM"
+
+test_235() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
+ skip "Need MDS version at least 2.4.52" && return
+ flock_deadlock $DIR/$tfile
+ local RC=$?
+ case $RC in
+ 0)
+ ;;
+ 124) error "process hangs on a deadlock"
+ ;;
+ *) error "error executing flock_deadlock $DIR/$tfile"
+ ;;
+ esac
+}
+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 -c1 $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 = $?"
+ local fd=$(free_fd)
+ local cmd="exec $fd<>$file2"
+ eval $cmd
+ rm $file2
+ $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
+ error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
+ cmd="exec $fd>&-"
+ eval $cmd
+ cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
+
+ #cleanup
+ rm -rf $DIR/$tdir
+}
+run_test 236 "Layout swap on open unlinked file"
+
+# test to verify file handle related system calls
+# (name_to_handle_at/open_by_handle_at)
+# The new system calls are supported in glibc >= 2.14.
+
+test_237() {
+ echo "Test file_handle syscalls" > $DIR/$tfile
+ check_fhandle_syscalls $DIR/$tfile ||
+ error "check_fhandle_syscalls failed"
+}
+run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
+
+# LU-4659 linkea consistency
+test_238() {
+ touch $DIR/$tfile
+ ln $DIR/$tfile $DIR/$tfile.lnk
+ touch $DIR/$tfile.new
+ mv $DIR/$tfile.new $DIR/$tfile
+ local fid1=$(lfs path2fid $DIR/$tfile)
+ local fid2=$(lfs path2fid $DIR/$tfile.lnk)
+ local path1=$(lfs fid2path $FSNAME $fid1)
+ [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
+ local path2=$(lfs fid2path $FSNAME $fid2)
+ [ $tfile.lnk == $path2 ] ||
+ error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
+ rm -f $DIR/$tfile*
+}
+run_test 238 "Verify linkea consistency"
+
+test_striped_dir() {
+ local mdt_index=$1
+ local stripe_count
+ local stripe_index
+
+ mkdir -p $DIR/$tdir
+ $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+
+ stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
+ if [ "$stripe_count" != "2" ]; then
+ error "stripe_count is $stripe_count, expect 2"
+ fi
+
+ stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
+ if [ "$stripe_index" != "$mdt_index" ]; then
+ error "stripe_index is $stripe_index, expect $mdt_index"
+ fi
+
+ [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
+ error "nlink error after create striped dir"
+
+ mkdir $DIR/$tdir/striped_dir/a
+ mkdir $DIR/$tdir/striped_dir/b
+
+ stat $DIR/$tdir/striped_dir/a ||
+ error "create dir under striped dir failed"
+ stat $DIR/$tdir/striped_dir/b ||
+ error "create dir under striped dir failed"
+
+ [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
+ error "nlink error after mkdir"
+
+ rmdir $DIR/$tdir/striped_dir/a
+ [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
+ error "nlink error after rmdir"
+
+ rmdir $DIR/$tdir/striped_dir/b
+ [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
+ error "nlink error after rmdir"
+
+ rmdir $DIR/$tdir/striped_dir ||
+ error "rmdir striped dir error"
+ true
+}
+
+test_300a() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+ test_striped_dir 0 || error "failed on striped dir on MDT0"
+ test_striped_dir 1 || error "failed on striped dir on MDT0"
+}
+run_test 300a "basic striped dir sanity test"
+
+test_300b() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local i
+ local mtime1
+ local mtime2
+ local mtime3
+
+ test_mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+ for ((i=0; i<10; i++)); do
+ mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
+ sleep 1
+ touch $DIR/$tdir/striped_dir/file_$i ||
+ error "touch error $i"
+ mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
+ [ $mtime1 -eq $mtime2 ] &&
+ error "mtime not change after create"
+ sleep 1
+ rm -f $DIR/$tdir/striped_dir/file_$i ||
+ error "unlink error $i"
+ mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
+ [ $mtime2 -eq $mtime3 ] &&
+ error "mtime did not change after unlink"
+ done
+ true
+}
+run_test 300b "check ctime/mtime for striped dir"
+
+test_300c() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local file_count
+
+ mkdir -p $DIR/$tdir
+ $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
+ error "chown striped dir failed"
+
+ $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
+ error "create 5k files failed"
+
+ file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
+
+ [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
+
+ rm -rf $DIR/$tdir
+}
+run_test 300c "chown && check ls under striped directory"
+
+test_300d() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local stripe_count
+ local file
+
+ mkdir -p $DIR/$tdir
+ $SETSTRIPE -c 2 $DIR/$tdir
+
+ #local striped directory
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+ createmany -o $DIR/$tdir/striped_dir/f 10 ||
+ error "create 10 files failed"
+
+ #remote striped directory
+ $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
+ error "set striped dir error"
+ createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
+ error "create 10 files failed"
+
+ for file in $(find $DIR/$tdir); do
+ stripe_count=$($GETSTRIPE -c $file)
+ [ $stripe_count -eq 2 ] ||
+ error "wrong stripe $stripe_count for $file"
+ done
+
+ rm -rf $DIR/$tdir
+}
+run_test 300d "check default stripe under striped directory"
+
+test_300e() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local stripe_count
+ local file
+
+ mkdir -p $DIR/$tdir
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+
+ touch $DIR/$tdir/striped_dir/a
+ touch $DIR/$tdir/striped_dir/b
+ touch $DIR/$tdir/striped_dir/c
+
+ mkdir $DIR/$tdir/striped_dir/dir_a
+ mkdir $DIR/$tdir/striped_dir/dir_b
+ mkdir $DIR/$tdir/striped_dir/dir_c
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
+ error "set striped dir under striped dir error"
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
+ error "set striped dir under striped dir error"
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
+ error "set striped dir under striped dir error"
+
+ mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
+ error "rename file under striped dir should fail"
+
+ mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
+ error "rename dir under striped dir should fail"
+
+ mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
+ error "rename dir under different stripes should fail"
+
+ mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
+ error "rename file under striped dir should succeed"
+
+ mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
+ error "rename dir under striped dir should succeed"
+
+ rm -rf $DIR/$tdir
+}
+run_test 300e "check rename under striped directory"
+
+test_300f() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local stripe_count
+ local file
+
+ rm -rf $DIR/$tdir
+ mkdir -p $DIR/$tdir
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+ error "set striped dir error"
+
+ $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
+ error "set striped dir error"
+
+ touch $DIR/$tdir/striped_dir/a
+ mkdir $DIR/$tdir/striped_dir/dir_a
+ $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
+ error "create striped dir under striped dir fails"
+
+ touch $DIR/$tdir/striped_dir1/b
+ mkdir $DIR/$tdir/striped_dir1/dir_b
+ $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
+ error "create striped dir under striped dir fails"
+
+ mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
+ error "rename file under different striped dir should fail"
+
+ mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
+ error "rename dir under different striped dir should fail"
+
+ mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
+ error "rename striped dir under diff striped dir should fail"
+
+ mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
+ error "rename file under diff striped dirs fails"
+
+ mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
+ error "rename dir under diff striped dirs fails"
+
+ rm -rf $DIR/$tdir
+}
+run_test 300f "check rename cross striped directory"