From 478eaff73639c49dbb138268439c5ac635f9f554 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Tue, 18 Sep 2012 03:01:27 -0400 Subject: [PATCH] LU-1842 quota: lfs quota commands - Removed 'lfs quotachown' & 'lfs quotainv'; - For 'lfs quotacheck', 'lfs quotaon' & 'lfs quotaoff', print proper message when -EOPNOTSUPP returned from 2.4 server; - Updated man page for lfs quota commands; - Removed quotainv from test_15 of s-q; Signed-off-by: Johann Lombardi Signed-off-by: Niu Yawei Change-Id: I89e6d1e981640ab0f62e10bc5a91946c78644cc3 Reviewed-on: http://review.whamcloud.com/4022 Reviewed-by: Fan Yong Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/doc/lfs.1 | 22 +++----- lustre/doc/llapi_quotactl.3 | 4 +- lustre/tests/sanity-quota.sh | 3 -- lustre/utils/lfs.c | 120 +++++++++++-------------------------------- 4 files changed, 39 insertions(+), 110 deletions(-) diff --git a/lustre/doc/lfs.1 b/lustre/doc/lfs.1 index 4e703e8..dac6685 100644 --- a/lustre/doc/lfs.1 +++ b/lustre/doc/lfs.1 @@ -48,14 +48,10 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the .br .B lfs quotacheck [-ug] .br -.B lfs quotachown [-i] -.br .B lfs quotaon [-ugf] .br .B lfs quotaoff [-ug] .br -.B lfs quotainv [-ug] [-f] -.br .B lfs setquota <-u|--user|-g|--group> \fB[--block-softlimit ] \fB[--block-hardlimit ] @@ -211,20 +207,14 @@ To display disk usage and limits, either for the full filesystem, or for objects .B quota -t <-u|-g> To display block and inode grace times for user (-u) or group (-g) quotas .TP -.B quotachown -To change files' owner and group on OSTs of the specified filesystem -.TP -.B quotacheck [-ugf] -To scan the specified filesystem for disk usage, and create or update quota files. Options specify quota for users (-u) groups (-g) and force (-f) -.TP -.B quotaon [-ugf] -To turn filesystem quotas on. Options specify quota for users (-u) groups (-g) and force (-f) +.B quotacheck [-ugf] (deprecated as of 2.4.0) +To scan the specified filesystem for disk usage, and create or update quota files. Options specify quota for users (-u) groups (-g) and force (-f). Not useful anymore with servers >= 2.4.0 since space accounting is always turned on. .TP -.B quotaoff [-ugf] -To turn filesystem quotas off. Options specify quota for users (-u) groups (-g) and force (-f) +.B quotaon [-ugf] (deprecated as of 2.4.0) +To turn filesystem quotas on. Options specify quota for users (-u) groups (-g) and force (-f). Not used anymore in lustre 2.4.0 where quota enforcement must be enabled via conf_param (e.g. lctl conf_param ${FSNAME}.quota.=) .TP -.B quotainv [-ug] [-f] -Clear quota files (administrative quota files if used without -f, operational quota files otherwise), all of their quota entries, for (-u) users or (-g) groups; after quotainv one must use quotacheck before using quotas. DO NOT USE THIS COMMAND UNLESS YOU REALLY KNOW WHAT IT DOES. IT IS MAINLY FOR INTERNAL PURPOSES. +.B quotaoff [-ugf] (deprecated as of 2.4.0) +To turn filesystem quotas off. Options specify quota for users (-u) groups (-g) and force (-f). Not used anymore in lustre 2.4.0 where quota enforcement can be turned off (for inode or block) by running the following command on the MGS: lctl conf_param ${FSNAME}.quota.="" .TP .B setquota <-u|-g> ||| [--block-softlimit ] [--block-hardlimit ] [--inode-softlimit ] [--inode-hardlimit ] To set filesystem quotas for users or groups. Limits can be specified with -b, -k, -m, -g, -t, -p suffixes which specify units of 1, 2^10, 2^20, 2^30, 2^40 and 2^50 accordingly. Block limits unit is kilobyte (1024) by default and block limits are always kilobyte-grained (even if specified in bytes), see EXAMPLES diff --git a/lustre/doc/llapi_quotactl.3 b/lustre/doc/llapi_quotactl.3 index dc15a78..15f0050 100644 --- a/lustre/doc/llapi_quotactl.3 +++ b/lustre/doc/llapi_quotactl.3 @@ -64,7 +64,7 @@ or .IR qc_id . .TP 15 .SB LUSTRE_Q_QUOTAON -Turn on quotas for a Lustre filesystem. +Turn on quotas for a Lustre filesystem. Deprecated as of 2.4.0. .I qc_type is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quotas). The quota files must exist; they are normally created with the @@ -74,7 +74,7 @@ call. This call is restricted to the super-user. .TP .SB LUSTRE_Q_QUOTAOFF -Turn off quotas for a Lustre filesystem. +Turn off quotas for a Lustre filesystem. Deprecated as of 2.4.0. .I qc_type is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quotas). diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 43e81de..24c6882 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -1254,9 +1254,6 @@ test_15(){ error "fail to set version for ost$j" done - echo "invalidating quota files" - $LFS quotainv -ug $DIR - $LFS quotainv -ugf $DIR $LFS quotacheck -ug $DIR } run_test_with_stat 15 "set block quota more than 4T ===" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 851fb6f..2b60ec4 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -88,13 +88,11 @@ static int lfs_df(int argc, char **argv); static int lfs_getname(int argc, char **argv); static int lfs_check(int argc, char **argv); #ifdef HAVE_SYS_QUOTA_H -static int lfs_quotachown(int argc, char **argv); static int lfs_quotacheck(int argc, char **argv); static int lfs_quotaon(int argc, char **argv); static int lfs_quotaoff(int argc, char **argv); static int lfs_setquota(int argc, char **argv); static int lfs_quota(int argc, char **argv); -static int lfs_quotainv(int argc, char **argv); #endif static int lfs_flushctx(int argc, char **argv); static int lfs_join(int argc, char **argv); @@ -175,23 +173,20 @@ command_t cmdlist[] = { "[for specified path only]\n" "Usage: getname [-h]|[path ...] "}, #ifdef HAVE_SYS_QUOTA_H - {"quotachown",lfs_quotachown, 0, - "Change files' owner or group on the specified filesystem.\n" - "usage: quotachown [-i] \n" - "\t-i: ignore error if file is not exist\n"}, {"quotacheck", lfs_quotacheck, 0, "Scan the specified filesystem for disk usage, and create,\n" - "or update quota files.\n" + "or update quota files. Deprecated as of 2.4.0.\n" "usage: quotacheck [ -ug ] "}, - {"quotaon", lfs_quotaon, 0, "Turn filesystem quotas on.\n" + {"quotaon", lfs_quotaon, 0, "Turn filesystem" + " quotas on. Deprecated as of 2.4.0.\n" "usage: quotaon [ -ugf ] "}, - {"quotaoff", lfs_quotaoff, 0, "Turn filesystem quotas off.\n" + {"quotaoff", lfs_quotaoff, 0, "Turn filesystem" + " quotas off. Deprecated as of 2.4.0.\n" "usage: quotaoff [ -ug ] "}, {"setquota", lfs_setquota, 0, "Set filesystem quotas.\n" "usage: setquota <-u|-g> |||\n" " -b -B \n" " -i -I \n" - " setquota -t <-u|-g> \n" " setquota <-u|--user|-g|--group> |||\n" " [--block-softlimit ]\n" " [--block-hardlimit ]\n" @@ -208,8 +203,6 @@ command_t cmdlist[] = { "usage: quota [-q] [-v] [-o |-i |-I ]\n" " [<-u|-g> |||] \n" " quota [-o |-i |-I ] -t <-u|-g> "}, - {"quotainv", lfs_quotainv, 0, "Invalidate quota data.\n" - "usage: quotainv [-u|-g] "}, #endif {"flushctx", lfs_flushctx, 0, "Flush security context for current user.\n" "usage: flushctx [-k] [mountpoint...]"}, @@ -1446,32 +1439,6 @@ static int lfs_join(int argc, char **argv) } #ifdef HAVE_SYS_QUOTA_H -static int lfs_quotachown(int argc, char **argv) -{ - - int c,rc; - int flag = 0; - - optind = 0; - while ((c = getopt(argc, argv, "i")) != -1) { - switch (c) { - case 'i': - flag++; - break; - default: - fprintf(stderr, "error: %s: option '-%c' " - "unrecognized\n", argv[0], c); - return CMD_HELP; - } - } - if (optind == argc) - return CMD_HELP; - rc = llapi_quotachown(argv[optind], flag); - if(rc) - fprintf(stderr,"error: change file owner/group failed.\n"); - return rc; -} - static int lfs_quotacheck(int argc, char **argv) { int c, check_type = 0; @@ -1510,7 +1477,14 @@ static int lfs_quotacheck(int argc, char **argv) mnt = argv[optind]; rc = llapi_quotacheck(mnt, check_type); - if (rc) { + if (rc == -EOPNOTSUPP) { + fprintf(stderr, "error: quotacheck not supported by the quota " + "master.\nPlease note that quotacheck is deprecated as " + "of lustre 2.4.0 since space accounting is always " + "enabled.\nFilesystems not formatted with 2.4 utils or " + "beyond can be upgraded with tunefs.lustre --quota.\n"); + return rc; + } else if (rc) { fprintf(stderr, "quotacheck failed: %s\n", strerror(-rc)); return rc; } @@ -1582,7 +1556,16 @@ static int lfs_quotaon(int argc, char **argv) rc = llapi_quotactl(mnt, &qctl); if (rc) { - if (rc == -EALREADY) { + if (rc == -EOPNOTSUPP) { + fprintf(stderr, "error: quotaon not supported by the " + "quota master.\nPlease note that quotaon/off is" + " deprecated as of lustre 2.4.0.\nQuota " + "enforcement should now be enabled on the MGS " + "via:\nmgs# lctl conf_param ${FSNAME}.quota." + "=\n(ost for block quota, mdt " + "for inode quota, u for user and g for group" + "\n"); + } else if (rc == -EALREADY) { rc = 0; } else if (rc == -ENOENT) { fprintf(stderr, "error: cannot find quota database, " @@ -1638,7 +1621,14 @@ static int lfs_quotaoff(int argc, char **argv) rc = llapi_quotactl(mnt, &qctl); if (rc) { - if (rc == -EALREADY) { + if (rc == -EOPNOTSUPP) { + fprintf(stderr, "error: quotaoff not supported by the " + "quota master.\nPlease note that quotaon/off is" + " deprecated as of lustre 2.4.0.\nQuota " + "enforcement can be disabled on the MGS via:\n" + "mgs# lctl conf_param ${FSNAME}.quota." + "=\"\"\n"); + } else if (rc == -EALREADY) { rc = 0; } else { if (*obd_type) @@ -1652,54 +1642,6 @@ static int lfs_quotaoff(int argc, char **argv) return rc; } -static int lfs_quotainv(int argc, char **argv) -{ - int c; - char *mnt; - struct if_quotactl qctl; - int rc; - - memset(&qctl, 0, sizeof(qctl)); - qctl.qc_cmd = LUSTRE_Q_INVALIDATE; - - optind = 0; - while ((c = getopt(argc, argv, "fgu")) != -1) { - switch (c) { - case 'u': - qctl.qc_type |= 0x01; - break; - case 'g': - qctl.qc_type |= 0x02; - break; - case 'f': - qctl.qc_cmd = LUSTRE_Q_FINVALIDATE; - break; - default: - fprintf(stderr, "error: %s: option '-%c' " - "unrecognized\n", argv[0], c); - return CMD_HELP; - } - } - - if (qctl.qc_type) - qctl.qc_type--; - else /* by default, invalidate quota for both user & group */ - qctl.qc_type = 0x02; - - if (argc == optind) - return CMD_HELP; - - mnt = argv[optind]; - - rc = llapi_quotactl(mnt, &qctl); - if (rc) { - fprintf(stderr, "quotainv failed: %s\n", strerror(-rc)); - return rc; - } - - return 0; -} - #define ARG2INT(nr, str, msg) \ do { \ char *endp; \ -- 1.8.3.1