unsigned long long stripe_size, int stripe_offset,
int stripe_count, int stripe_pattern, char *pool_name);
int llapi_poollist(const char *name);
+int llapi_get_poolbuf(const char *name, char **buf,
+ char ***poolist, int *poolcount);
int llapi_get_poollist(const char *name, char **poollist, int list_size,
char *buffer, int buffer_size);
int llapi_get_poolmembers(const char *poolname, char **members, int list_size,
}
run_test 73 "default limits at OST Pool Quotas"
+test_74()
+{
+ local global_limit=200 # 200M
+ local limit=10 # 10M
+ local limit2=50 # 50M
+ local qpool="qpool1"
+ local qpool2="qpool2"
+ local tmp=0
+
+ mds_supports_qp
+ setup_quota_test || error "setup quota failed with $?"
+ stack_trap cleanup_quota_test EXIT
+
+ # enable ost quota
+ set_ost_qtype $QTYPE || error "enable ost quota failed"
+
+ $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
+ error "set user quota failed"
+
+ pool_add $qpool || error "pool_add failed"
+ pool_add_targets $qpool 0 1 ||
+ error "pool_add_targets failed"
+
+ $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
+ error "set user quota failed"
+
+ pool_add $qpool2 || error "pool_add failed"
+ pool_add_targets $qpool2 1 1 ||
+ error "pool_add_targets failed"
+
+ $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
+ error "set user quota failed"
+
+ tmp=$(getquota -u $TSTUSR global bhardlimit)
+ [ $tmp -eq $((global_limit * 1024)) ] ||
+ error "wrong global limit $global_limit"
+
+ tmp=$(getquota -u $TSTUSR global bhardlimit $qpool)
+ [ $tmp -eq $((limit * 1024)) ] || error "wrong limit $tmp for $qpool"
+
+ tmp=$(getquota -u $TSTUSR global bhardlimit $qpool2)
+ [ $tmp -eq $((limit2 * 1024)) ] || error "wrong limit $tmp for $qpool2"
+
+ # check limits in pools
+ tmp=$($LFS quota -u $TSTUSR --pool $DIR | \
+ grep -A4 $qpool | awk 'NR == 4{print $4}')
+ echo "pool limit for $qpool $tmp"
+ [ $tmp -eq $((limit * 1024)) ] || error "wrong limit:tmp for $qpool"
+ tmp=$($LFS quota -u $TSTUSR --pool $DIR | \
+ grep -A4 $qpool2 | awk 'NR == 4{print $4}')
+ echo "pool limit for $qpool2 $tmp"
+ [ $tmp -eq $((limit2 * 1024)) ] || error "wrong limit:$tmp for $qpool2"
+}
+run_test 74 "check quota pools per user"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) \
bool human_readable = false;
bool show_default = false;
int qtype;
+ bool show_pools = false;
struct option long_opts[] = {
- { .val = LFS_POOL_OPT, .name = "pool", .has_arg = required_argument },
+ { .val = LFS_POOL_OPT, .name = "pool", .has_arg = optional_argument },
{ .name = NULL } };
+ char **poollist = NULL;
+ char *buf = NULL;
+ int poolcount, i;
qctl = calloc(1, sizeof(*qctl) + LOV_MAXPOOLNAME + 1);
if (!qctl)
human_readable = true;
break;
case LFS_POOL_OPT:
- if (lfs_verify_poolarg(optarg)) {
- rc = -1;
- goto out;
+ if ((!optarg) && (argv[optind] != NULL) &&
+ (argv[optind][0] != '-') &&
+ (argv[optind][0] != '/')) {
+ optarg = argv[optind++];
+ if (lfs_verify_poolarg(optarg)) {
+ rc = -EINVAL;
+ goto out;
+ }
+ strncpy(qctl->qc_poolname, optarg,
+ LOV_MAXPOOLNAME);
+ if (qctl->qc_cmd == LUSTRE_Q_GETINFO)
+ qctl->qc_cmd = LUSTRE_Q_GETINFOPOOL;
+ else
+ qctl->qc_cmd = LUSTRE_Q_GETQUOTAPOOL;
+ break;
}
- strncpy(qctl->qc_poolname, optarg, LOV_MAXPOOLNAME);
- qctl->qc_cmd = qctl->qc_cmd == LUSTRE_Q_GETINFO ?
- LUSTRE_Q_GETINFOPOOL :
- LUSTRE_Q_GETQUOTAPOOL;
+
+ /* optarg is NULL */
+ show_pools = true;
+ qctl->qc_cmd = LUSTRE_Q_GETQUOTAPOOL;
break;
default:
fprintf(stderr, "%s quota: unrecognized option '%s'\n",
}
mnt = argv[optind];
+ if (show_pools) {
+ char *p;
+
+ i = 0;
+ rc = llapi_get_poolbuf(mnt, &buf, &poollist, &poolcount);
+ if (rc)
+ goto out;
+
+ for (i = 0; i < poolcount; i++) {
+ p = memchr(poollist[i], '.', MAXNAMLEN);
+ if (!p) {
+ fprintf(stderr, "bad string format %.*s\n",
+ MAXNAMLEN, poollist[i]);
+ rc = -EINVAL;
+ goto out;
+ }
+ p++;
+ printf("Quotas for pool: %s\n", p);
+ strncpy(qctl->qc_poolname, p, LOV_MAXPOOLNAME);
+ rc = get_print_quota(mnt, name, qctl, verbose, quiet,
+ human_readable, show_default);
+ if (rc)
+ break;
+ }
+ goto out;
+ }
+
rc = get_print_quota(mnt, name, qctl, verbose, quiet,
human_readable, show_default);
out:
+ free(buf);
free(qctl);
return rc;
}
/* wrapper for lfs.c and obd.c */
int llapi_poollist(const char *name)
{
+ int poolcount, rc, i;
+ char *buf, **pools;
+
+ rc = llapi_get_poolbuf(name, &buf, &pools, &poolcount);
+ if (rc)
+ return rc;
+
+ for (i = 0; i < poolcount; i++)
+ llapi_printf(LLAPI_MSG_NORMAL, "%s\n", pools[i]);
+ free(buf);
+
+ return 0;
+}
+
+/**
+ * Get buffer that holds uuids and the list of pools in a filesystem.
+ *
+ * \param name filesystem name or path
+ * \param buf bufffer that has to be freed if function returns 0
+ * \param pools pointer to the list of pools in buffer
+ * \param poolcount number of pools
+ *
+ * \return 0 when found at least 1 pool, i.e. poolcount > 0
+ * \retval -error failure
+ */
+int llapi_get_poolbuf(const char *name, char **buf,
+ char ***pools, int *poolcount)
+{
/*
* list of pool names (assume that pool count is smaller
* than OST count)
char **list, *buffer = NULL, *fsname = (char *)name;
char *poolname = NULL, *tmp = NULL, data[16];
enum param_filter type = FILTER_BY_PATH;
- int obdcount, bufsize, rc, nb, i;
+ int obdcount, bufsize, rc, nb;
if (name == NULL)
return -EINVAL;
goto retry_get_pools;
}
- for (i = 0; i < nb; i++)
- llapi_printf(LLAPI_MSG_NORMAL, "%s\n", list[i]);
rc = (nb < 0 ? nb : 0);
+ if (!rc) {
+ *buf = buffer;
+ *pools = list;
+ *poolcount = nb;
+ }
err:
- if (buffer)
+ /* Don't free buffer, it will be used later */
+ if (rc && buffer)
free(buffer);
if (fsname != NULL && type == FILTER_BY_FS_NAME)
free(fsname);