- echo "Write file..."
- $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$BLK_SZ \
- count=$BLK_CNT oflag=sync 2>/dev/null || error "write failed"
-
- echo "Save disk usage before restart"
- ORIG_USR_SPACE=`getquota -u $TSTID global curspace`
- [ $ORIG_USR_SPACE -eq 0 ] && \
- error "Used space for user $TSTID is 0, expected $BLK_CNT"
- ORIG_USR_INODES=`getquota -u $TSTID global curinodes`
- [ $ORIG_USR_INODES -eq 0 ] && \
- error "Used inodes for user $TSTID is 0, expected 1"
- ORIG_GRP_SPACE=`getquota -g $TSTID global curspace`
- [ $ORIG_GRP_SPACE -eq 0 ] && \
- error "Used space for group $TSTID is 0, expected $BLK_CNT"
- ORIG_GRP_INODES=`getquota -g $TSTID global curinodes`
- [ $ORIG_GRP_INODES -eq 0 ] && \
- error "Used inodes for group $TSTID is 0, expected 1"
-
- log "Restart..."
- local ORIG_REFORMAT=$REFORMAT
- REFORMAT=""
- cleanup_and_setup_lustre
- REFORMAT=$ORIG_REFORMAT
- quota_init
-
- echo "Verify disk usage after restart"
- USED=`getquota -u $TSTID global curspace`
- [ $USED -eq $ORIG_USR_SPACE ] || \
- error "Used space for user $TSTID changed from " \
- "$ORIG_USR_SPACE to $USED"
- USED=`getquota -u $TSTID global curinodes`
- [ $USED -eq $ORIG_USR_INODES ] || \
- error "Used inodes for user $TSTID changed from " \
- "$ORIG_USR_INODES to $USED"
- USED=`getquota -g $TSTID global curspace`
- [ $USED -eq $ORIG_GRP_SPACE ] || \
- error "Used space for group $TSTID changed from " \
- "$ORIG_GRP_SPACE to $USED"
- USED=`getquota -g $TSTID global curinodes`
- [ $USED -eq $ORIG_GRP_INODES ] || \
- error "Used inodes for group $TSTID changed from " \
- "$ORIG_GRP_INODES to $USED"
-
- cleanup_quota_test
-}
-run_test 35 "usage is still accessible across reboot ============================"
+ echo "Write file..."
+ $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
+ error "write failed"
+ cancel_lru_locks osc
+ sync; sync_all_data || true
+
+ echo "Save disk usage before restart"
+ local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
+ [ $ORIG_USR_SPACE -eq 0 ] &&
+ error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
+ local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
+ [ $ORIG_USR_INODES -eq 0 ] &&
+ error "Used inodes for user $TSTID is 0, expected 1"
+ echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
+ local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
+ [ $ORIG_GRP_SPACE -eq 0 ] &&
+ error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
+ local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
+ [ $ORIG_GRP_INODES -eq 0 ] &&
+ error "Used inodes for group $TSTID is 0, expected 1"
+ echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
+
+ log "Restart..."
+ local ORIG_REFORMAT=$REFORMAT
+ REFORMAT=""
+ cleanup_and_setup_lustre
+ REFORMAT=$ORIG_REFORMAT
+ quota_init
+
+ echo "Verify disk usage after restart"
+ local USED=$(getquota -u $TSTID global curspace)
+ [ $USED -eq $ORIG_USR_SPACE ] ||
+ error "Used space for user $TSTID changed from " \
+ "$ORIG_USR_SPACE to $USED"
+ USED=$(getquota -u $TSTID global curinodes)
+ [ $USED -eq $ORIG_USR_INODES ] ||
+ error "Used inodes for user $TSTID changed from " \
+ "$ORIG_USR_INODES to $USED"
+ USED=$(getquota -g $TSTID global curspace)
+ [ $USED -eq $ORIG_GRP_SPACE ] ||
+ error "Used space for group $TSTID changed from " \
+ "$ORIG_GRP_SPACE to $USED"
+ USED=$(getquota -g $TSTID global curinodes)
+ [ $USED -eq $ORIG_GRP_INODES ] ||
+ error "Used inodes for group $TSTID changed from " \
+ "$ORIG_GRP_INODES to $USED"
+
+ # check if the vfs_dq_init() is called before writing
+ echo "Append to the same file..."
+ $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
+ error "write failed"
+ cancel_lru_locks osc
+ sync; sync_all_data || true
+
+ echo "Verify space usage is increased"
+ USED=$(getquota -u $TSTID global curspace)
+ [ $USED -gt $ORIG_USR_SPACE ] ||
+ error "Used space for user $TSTID isn't increased" \
+ "orig:$ORIG_USR_SPACE, now:$USED"
+ USED=$(getquota -g $TSTID global curspace)
+ [ $USED -gt $ORIG_GRP_SPACE ] ||
+ error "Used space for group $TSTID isn't increased" \
+ "orig:$ORIG_GRP_SPACE, now:$USED"
+
+ cleanup_quota_test
+}
+run_test 35 "Usage is still accessible across reboot"
+
+# chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE
+# LU-5006
+test_37() {
+ setup_quota_test
+ trap cleanup_quota_test EXIT
+
+ # make sure the system is clean
+ local USED=$(getquota -u $TSTID global curspace)
+ [ $USED -ne 0 ] &&
+ error "Used space ($USED) for user $TSTID isn't 0."
+
+ # create file with MDS_OPEN_DELAY_CREATE flag
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile ||
+ error "Create file failed"
+ # write to file
+ dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 conv=notrunc \
+ oflag=sync || error "Write file failed"
+ # chown to the file
+ chown $TSTID $DIR/$tdir/$tfile || error "Chown to file failed"
+
+ # wait for setattr on objects finished..."
+ wait_delete_completed