new file mode 100755
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test
+#
+# Test for mount option max_dir_size_kb
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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
+tmp=/tmp/$$
+
+dir1=$SCRATCH_MNT/dir1.$seq
+dir2=$dir1/dir2.$seq
+testfile=$SCRATCH_MNT/testfile
+
+echo "QA output created by $seq"
+echo "Silence is golden"
+rm -f $seqres.full
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+
+# real QA test starts here
+
+_supported_fs ext4
+_supported_os Linux
+_require_scratch
+_require_loop
+
+
+# filter expected output with ENOSPC error
+filter_enospc()
+{
+ sed -e "/^.*No space left on device$/d"
+}
+
+# $1 - expected limit after filling
+# $2 - where to create
+create_items()
+{
+ limit=$1
+ dir=$2
+ MAX_INUM=$((limit * 1024 * 3 / 24))
+ for i in $(seq 0 $MAX_INUM); do
+ touch $dir/$i 2>&1 | filter_enospc
+ if [ ${PIPESTATUS[0]} -ne 0 ]; then
+ break
+ fi
+ done
+ size=$(stat -c %s $dir)
+ size=$((size / 1024))
+ if [ $size -gt $limit ]; then
+ echo "FAIL! expected dir size: $limit, actually: $size"
+ fi
+}
+
+# $1 - low directory limit value
+# $2 - high directory limit value
+# $3 - mkfs options
+run_test()
+{
+ LIMIT1=$1
+ LIMIT2=$2
+ MKFS_OPT=$3
+
+ _scratch_mkfs $MKFS_OPT >>$seqres.full 2>&1
+ _scratch_mount -o max_dir_size_kb=$LIMIT1
+ mkdir $dir1
+
+ # Exceed with low limit
+ create_items $LIMIT1 $dir1
+
+ # Exceed with the same limit after remount
+ _scratch_mount "-o remount,max_dir_size_kb=$LIMIT1"
+ create_items $LIMIT1 $dir1
+
+ # Exceed with high limit after remount
+ _scratch_mount "-o remount,max_dir_size_kb=$LIMIT2"
+ create_items $LIMIT2 $dir1
+
+ # Exceed with low limit after remount
+ _scratch_mount "-o remount,max_dir_size_kb=$LIMIT1"
+ create_items $LIMIT2 $dir1
+
+ # Exceed limits of two test dirs resided on different fs,
+ # second fs is mounted on nested test dir of the first fs
+ rm -fr $dir1/*
+ rmdir $dir1
+ mkdir -p $dir2
+ touch $testfile
+ MKFS_OPTIONS="-F $MKFS_OPT"
+ _mkfs_dev $testfile 4m
+ _mount -o loop,max_dir_size_kb=$LIMIT2 $testfile $dir2
+ create_items $LIMIT1 $dir1
+ create_items $LIMIT2 $dir2
+ _scratch_mount "-o remount,max_dir_size_kb=$LIMIT2"
+ _mount -o remount,max_dir_size_kb=$LIMIT1 $testfile $dir2
+ create_items $LIMIT2 $dir1
+ create_items $LIMIT2 $dir2
+
+ umount -d $dir2
+ _scratch_unmount >/dev/null 2>&1
+
+}
+
+run_test 8 16
+run_test 4 32 "-O ^dir_index"
+run_test 5 11 "-b 1024"
+
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,2 @@
+QA output created by 005
+Silence is golden