From 1df4557b5506ff670c6ea599955f36b1cd20e9a2 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Thu, 26 Jul 2012 04:32:58 -0400 Subject: [PATCH] LU-1676 quota: missing vfs_dq_init() in write path Calling vfs_dq_init() in the osd_write_commit(), otherwise space won't be accounted for the existing inode. Signed-off-by: Niu Yawei Change-Id: I9671ee9865449dd298139d7668ab17d3d58f8866 Reviewed-on: http://review.whamcloud.com/3476 Reviewed-by: Johann Lombardi Tested-by: Hudson Tested-by: Maloo Reviewed-by: Mike Pershin --- lustre/osd-ldiskfs/osd_io.c | 1 + lustre/tests/sanity-quota.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 4b50e5a..35e08f8 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -692,6 +692,7 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, osd_init_iobuf(osd, iobuf, 1); isize = i_size_read(inode); + ll_vfs_dq_init(inode); for (i = 0; i < npages; i++) { if (lnb[i].rc == -ENOSPC && diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 2de459f..43e81de 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -2395,6 +2395,22 @@ test_35() { 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 if=/dev/zero of=$DIR/$tdir/$tfile bs=$((BLK_SZ * BLK_CNT)) \ + count=1 seek=1 conv=fsync 2>/dev/null || error "write failed" + sync; sync_all_data; + + 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 ============================" -- 1.8.3.1