From 89c5292ce9899f079ca9a2994bc220f04c188c58 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Fri, 9 Mar 2018 13:25:07 +0800 Subject: [PATCH] LU-10794 lfs: make quota work for grace time Following commit: LU-10011 utils: refactor lfs quota codes Introduce a regression which will make 'lfs quota -t' will output nothing, fix this bug and also add a test case in sanity-quota.sh in case it is broken in the future again. Test-Parameters: trivial testlist=sanity-quota Lustre-change: https://review.whamcloud.com/31606 Lustre-commit: 630cd4953daa876697f1aed4eb3819d60d0e2d17 Change-Id: I2063552505cf07464d9924f66c29fc2504bc56ce Signed-off-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/31873 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond --- lustre/tests/sanity-quota.sh | 19 +++++++++++++++++++ lustre/utils/lfs.c | 7 ++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 32a92eb..02603ec 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -2934,6 +2934,25 @@ test_53() { } run_test 53 "Project inherit attribute could be cleared" +test_56 () { + setup_quota_test || error "setup quota failed with $?" + + set_ost_qtype $QTYPE || error "enable ost quota failed" + quota_init + + $LFS setquota -t -u -b 10 -i 10 $DIR || + erro "failed to set grace time for usr quota" + grace_time=$($LFS quota -t -u $DIR | grep "Block grace time:" | + awk '{print $4 $8}') + if [ "x$grace_time" != "x10s;10s" ]; then + $LFS quota -t -u $DIR + error "expected grace time: 10s;10s, got:$grace_time" + fi + + cleanup_quota_test +} +run_test 56 "lfs quota -t should work well" + quota_fini() { do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 77d7f45..d51f24d 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -4226,6 +4226,7 @@ quota_type: if (rc1 && !rc) rc = rc1; } + return rc; /* lfs quota -u username /path/to/lustre/mount */ } else if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) { /* options should be followed by u/g-name and mntpoint */ @@ -4257,14 +4258,14 @@ quota_type: return CMD_HELP; } } - mnt = argv[optind]; - rc = get_print_quota(mnt, name, &qctl, verbose, quiet, - human_readable); } else if (optind + 1 != argc || qctl.qc_type == ALLQUOTA) { fprintf(stderr, "error: missing quota info argument(s)\n"); return CMD_HELP; } + mnt = argv[optind]; + rc = get_print_quota(mnt, name, &qctl, verbose, quiet, + human_readable); return rc; } #endif /* HAVE_SYS_QUOTA_H! */ -- 1.8.3.1