From: Frederick Dilger Date: Thu, 31 Oct 2024 20:30:00 +0000 (-0600) Subject: LU-18079 tests: updating getquota() in sanity-quota X-Git-Tag: 2.16.52~10 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=f37e9527ef80ffcadcc849980d56ec83b039679e;p=fs%2Flustre-release.git LU-18079 tests: updating getquota() in sanity-quota Updating getquota() in sanity-quota to use the new column parsing options rather than parsing the entire output based on argument offset which could break if the column order or argument number was changed. Updated lfs-quota.1 man page to include long options. Signed-off-by: Frederick Dilger Change-Id: I922a9c0c869ba18029d682220a38b2e0e0cdd91d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56231 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- diff --git a/lustre/doc/lfs-quota.1 b/lustre/doc/lfs-quota.1 index 5f59a5f..4ce0a6c 100644 --- a/lustre/doc/lfs-quota.1 +++ b/lustre/doc/lfs-quota.1 @@ -3,40 +3,43 @@ lfs-quota \- display quota limits and status for users, groups, or projects. .SH SYNOPSIS .SY "lfs quota" -.RB [ -q ] -.RB [ -v ] -.RB [ -h ] -.RB [ -o +.RB [ -q | --quiet ] +.RB [ -v | --verbose ] +.RB [ -h | --human-readable ] +.RB [ -o | --ost .IR OBD_UUID | OST_IDX -.RB "| " -m +.RB "| " -m | --mdt .IR MDT_IDX ] -.RB [ -u +.RB [ -u | --user .IR USER " |" -.BI "-g " GROUP -.RB "| " -p +.BI -g | --group GROUP +.BR "| " -p | --projid .IR PROJID ] .RB [ --pool .IR OST_POOL_NAME ] .EX -.RB [ --filesystem | --mount-point ] .RB [ --blocks | --busage | --space ] .RB [ --block-softlimit | --bsoftlimit ] .RB [ --block-hardlimit | --bhardlimit ] .RB [ --block-grace | --bgrace | --btime ] +.RB [ --filesystem | --mount-point ] .RB [ --inodes | --iusage ] .RB [ --inode-softlimit | --isoftlimit ] .RB [ --inode-hardlimit | --ihardlimit ] .RB [ --inode-grace | --igrace | --itime ] .EE .RI [ MOUNT_POINT " ...]" -.SY -.BR "lfs quota " [ -hq "] {" -U | -G | -P } +.SY "lfs quota" +.BR [ -hq ] +.RB { -U | --default-usr | -G | --default-grp | -P | --default-prj } .RI [ MOUNT_POINT " ...]" -.SY -.BR "lfs quota " -t " {" -u | -g | -p } +.SY "lfs quota" +.B -t | --times +.RB { -u | -g | -p } .RI [ MOUNT_POINT " ...]" -.SY -.BR "lfs quota " -a " {" -u | -g | -p } +.SY "lfs quota" +.B -a | --all +.RB { -u | -g | -p } .RI [ MOUNT_POINT " ...]" .YS .SH DESCRIPTION @@ -66,10 +69,10 @@ which specify units of 2^10, 2^20, 2^30, 2^40, 2^50 and 2^60 bytes, respectively. Time values will use the "XXwXXdXXhXXmXXs" format, which specifies weeks, days, hours, minutes, seconds. .TP -.BR --blocks | --busage | --space +.BR --blocks | --busage | --space | --kbytes Print only the -.B kbytes -column representing the block usage space. +.BR kbytes / usage +column representing the block space usage. If other column options are specified, all specified columns will be printed. .TP .BR --block-softlimit | --bsoftlimit @@ -96,10 +99,13 @@ Print only the column representing either the mount point or device name. If other column options are specified, all specified columns will be printed. .TP -.BR --inodes | --iusage +.BR -g | --group " {" \fIGROUP | \fIGID } +Display quota information for group name \fIGROUP\fR or numeric \fIGID\fR. +.TP +.BR --inodes | --iusage | --files Print only the .B files -column representing the inodes. +column representing the number of inodes used. If other column options are specified, all specified columns will be printed. .TP .BR --inode-softlimit | --isoftlimit diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index ac61d46..cf834c1 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -11528,39 +11528,29 @@ change_project() { # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace \ # getquota() { - local spec + local type=$1 + local id=$2 local uuid + local spec=$4 + local pool=$5 local pool_arg sync_all_data > /dev/null 2>&1 || true - [ "$#" != 4 -a "$#" != 5 ] && + [[ "$#" != 4 && "$#" != 5 ]] && error "getquota: wrong number of arguments: $#" - [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] && + [[ "$type" != "-u" && "$type" != "-g" && "$type" != "-p" ]] && error "getquota: wrong u/g/p specifier $1 passed" - uuid="$3" - - case "$4" in - curspace) spec=1;; - bsoftlimit) spec=2;; - bhardlimit) spec=3;; - bgrace) spec=4;; - curinodes) spec=5;; - isoftlimit) spec=6;; - ihardlimit) spec=7;; - igrace) spec=8;; - *) error "unknown quota parameter $4";; - esac - - [ ! -z "$5" ] && pool_arg="--pool $5 " - [ "$uuid" = "global" ] && uuid=$DIR + [[ "$spec" =~ "curspace" ]] && spec="space" + [[ "$spec" =~ "curinode" ]] && spec="inodes" + [[ ! -z "$pool" ]] && pool_arg="--pool $pool " + [[ "$3" =~ "OST" ]] && uuid="--ost $(echo "$3" | tail -c 4) " + [[ "$3" =~ "MDT" ]] && uuid="--mdt $(echo "$3" | tail -c 4) " - $LFS quota -v "$1" "$2" $pool_arg $DIR 1>&2 - $LFS quota -v "$1" "$2" $pool_arg $DIR | - awk 'BEGIN { num='$spec' } { if ($1 ~ "'$uuid'") \ - { if (NF == 1) { getline } else { num++ } ; print $num;} }' \ - | tr -d "*" + echo -n "$type $id $uuid $spec:" 1>&2 + $LFS quota -q $uuid --$spec "$type" "$id" $pool_arg$DIR | tr -d "*" 1>&2 + $LFS quota -q $uuid --$spec "$type" "$id" $pool_arg$DIR | tr -d "*" } # set mdt quota type diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index e5b4ccd..066d0a1 100755 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -9982,13 +9982,12 @@ static int lfs_quota(int argc, char **argv) .name = "busage", .has_arg = no_argument }, { .val = LFS_QUOTA_SPACE_OPT, .name = "space", .has_arg = no_argument }, - { .val = 'b', - .name = "block-softlimit", .has_arg = no_argument }, - { .val = 'b', - .name = "bsoftlimit", .has_arg = no_argument }, + { .val = LFS_QUOTA_SPACE_OPT, + .name = "kbytes", .has_arg = no_argument }, + { .val = 'b', .name = "block-softlimit", .has_arg = no_argument }, + { .val = 'b', .name = "bsoftlimit", .has_arg = no_argument }, { .val = 'b', .name = "bquota", .has_arg = no_argument }, - { .val = 'B', - .name = "block-hardlimit", .has_arg = no_argument }, + { .val = 'B', .name = "block-hardlimit", .has_arg = no_argument }, { .val = 'B', .name = "bhardlimit", .has_arg = no_argument }, { .val = 'B', .name = "blimit", .has_arg = no_argument }, { .val = LFS_QUOTA_BGRACE_OPT, @@ -10001,6 +10000,8 @@ static int lfs_quota(int argc, char **argv) .name = "inodes", .has_arg = no_argument }, { .val = LFS_QUOTA_INODES_OPT, .name = "iusage", .has_arg = no_argument }, + { .val = LFS_QUOTA_INODES_OPT, + .name = "files", .has_arg = no_argument }, { .val = LFS_QUOTA_ISOFTLIMIT_OPT, .name = "inode-softlimit", .has_arg = no_argument }, { .val = LFS_QUOTA_ISOFTLIMIT_OPT,