+# Quota reintegration (Transfer index in multiple bulks)
+test_7d(){
+ local TESTFILE=$DIR/$tdir/$tfile
+ local TESTFILE1="$DIR/$tdir/$tfile"-1
+ local limit=20 #20M
+
+ setup_quota_test
+ trap cleanup_quota_test EXIT
+
+ set_ost_qtype "none" || error "disable ost quota failed"
+ $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
+ error "set quota for $TSTUSR failed"
+ $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
+ error "set quota for $TSTUSR2 failed"
+
+ #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
+ lustre_fail mds 0x608 0
+
+ # enable quota to tirgger reintegration
+ set_ost_qtype "u" || error "enable ost quota failed"
+ wait_ost_reint "u" || error "reintegration failed"
+
+ lustre_fail mds 0
+
+ # hardlimit should have been fetched by slave during global
+ # reintegration, write will exceed quota
+ $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
+ quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
+
+ $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
+ quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
+
+ cleanup_quota_test
+ resetquota -u $TSTUSR
+ resetquota -u $TSTUSR2
+}
+run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
+
+# quota reintegration (inode limits)
+test_7e() {
+ [ "$MDSCOUNT" -lt "2" ] && skip "Required more MDTs" && return
+
+ local ilimit=$((1024 * 2)) # 2k inodes
+ local TESTFILE=$DIR/${tdir}-1/$tfile
+
+ setup_quota_test
+ trap cleanup_quota_test EXIT
+
+ # make sure the system is clean
+ local USED=$(getquota -u $TSTUSR global curinodes)
+ [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
+
+ # make sure no granted quota on mdt1
+ set_mdt_qtype "ug" || error "enable mdt quota failed"
+ resetquota -u $TSTUSR
+ set_mdt_qtype "none" || error "disable mdt quota failed"
+
+ local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
+ USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
+ [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
+ "$TSTUSR isn't 0."
+
+ echo "Stop mds${MDSCOUNT}..."
+ stop mds${MDSCOUNT}
+
+ echo "Enable quota & set quota limit for $TSTUSR"
+ set_mdt_qtype "ug" || error "enable mdt quota failed"
+ $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
+ error "set quota failed"
+
+ echo "Start mds${MDSCOUNT}..."
+ start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
+ quota_init
+
+ wait_mdt_reint "ug" || error "reintegration failed"
+
+ echo "create remote dir"
+ $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
+ error "create remote dir failed"
+ chmod 0777 $DIR/${tdir}-1
+
+ # hardlimit should have been fetched by slave during global
+ # reintegration, create will exceed quota
+ $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
+ quota_error u $TSTUSR "create succeeded, expect EDQUOT"
+
+ $RUNAS unlinkmany $TESTFILE $ilimit || "unlink files failed"
+ wait_delete_completed
+ sync_all_data || true
+
+ echo "Stop mds${MDSCOUNT}..."
+ stop mds${MDSCOUNT}
+
+ $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
+ error "clear quota failed"
+
+ echo "Start mds${MDSCOUNT}..."
+ start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
+ quota_init
+
+ wait_mdt_reint "ug" || error "reintegration failed"
+
+ # hardlimit should be cleared on slave during reintegration
+ $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
+ quota_error -u $TSTUSR "create failed, expect success"
+
+ $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || "unlink failed"
+ rmdir $DIR/${tdir}-1 || "unlink remote dir failed"
+
+ cleanup_quota_test
+ resetquota -u $TSTUSR
+}
+run_test 7e "Quota reintegration (inode limits)"
+