#define LUSTRE_Q_SETQUOTAPOOL 0x800010 /* set user pool quota */
#define LUSTRE_Q_GETINFOPOOL 0x800011 /* get pool quota info */
#define LUSTRE_Q_SETINFOPOOL 0x800012 /* set pool quota info */
+#define LUSTRE_Q_GETDEFAULT_POOL 0x800013 /* get default pool quota*/
+#define LUSTRE_Q_SETDEFAULT_POOL 0x800014 /* set default pool quota */
/* In the current Lustre implementation, the grace time is either the time
* or the timestamp to be used after some quota ID exceeds the soft limt,
* 48 bits should be enough, its high 16 bits can be used as quota flags.
(cmd == LUSTRE_Q_GETQUOTAPOOL || \
cmd == LUSTRE_Q_SETQUOTAPOOL || \
cmd == LUSTRE_Q_SETINFOPOOL || \
- cmd == LUSTRE_Q_GETINFOPOOL)
+ cmd == LUSTRE_Q_GETINFOPOOL || \
+ cmd == LUSTRE_Q_SETDEFAULT_POOL || \
+ cmd == LUSTRE_Q_GETDEFAULT_POOL)
#define ALLQUOTA 255 /* set all quota */
static inline const char *qtype_name(int qtype)
case LUSTRE_Q_SETDEFAULT:
case LUSTRE_Q_SETQUOTAPOOL:
case LUSTRE_Q_SETINFOPOOL:
+ case LUSTRE_Q_SETDEFAULT_POOL:
if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
break;
case Q_GETQUOTA:
case LUSTRE_Q_GETDEFAULT:
case LUSTRE_Q_GETQUOTAPOOL:
+ case LUSTRE_Q_GETDEFAULT_POOL:
if (check_owner(type, id) &&
(!capable(CAP_SYS_ADMIN)))
RETURN(-EPERM);
case LUSTRE_Q_SETDEFAULT:
case LUSTRE_Q_SETQUOTAPOOL:
case LUSTRE_Q_SETINFOPOOL:
+ case LUSTRE_Q_SETDEFAULT_POOL:
if (!nodemap_can_setquota(nodemap))
GOTO(out_nodemap, rc = -EPERM);
/* fallthrough */
case LUSTRE_Q_GETDEFAULT:
case LUSTRE_Q_GETQUOTAPOOL:
case LUSTRE_Q_GETINFOPOOL:
+ case LUSTRE_Q_GETDEFAULT_POOL:
if (qmt == NULL)
GOTO(out_nodemap, rc = -EOPNOTSUPP);
/* slave quotactl */
case LUSTRE_Q_GETQUOTAPOOL:
case LUSTRE_Q_SETINFOPOOL:
case LUSTRE_Q_GETINFOPOOL:
+ case LUSTRE_Q_SETDEFAULT_POOL:
+ case LUSTRE_Q_GETDEFAULT_POOL:
/* forward quotactl request to QMT */
rc = qmt_hdls.qmth_quotactl(tsi->tsi_env, qmt, oqctl);
break;
__u64 ver;
bool dirtied = false;
int rc = 0;
- int need_id_notify = 0;
+ bool need_id_notify = false;
ENTRY;
/* need to write back to global quota file? */
quota_set:
/* recompute qunit in case it was never initialized */
if (qmt_revalidate(env, lqe))
- need_id_notify = 1;
+ need_id_notify = true;
/* clear grace time */
if (lqe->lqe_softlimit == 0 ||
/* compute new qunit value now that we have modified the quota
* settings or clear/set edquot flag if needed */
- if (qmt_adjust_qunit(env, lqe) || qmt_adjust_edquot(lqe, now))
- need_id_notify |= 1;
+ need_id_notify |= qmt_adjust_qunit(env, lqe);
+ need_id_notify |= qmt_adjust_edquot(lqe, now);
}
EXIT;
out:
LQUOTA_DEBUG(lqe, "notify all lqe with default quota");
iter_data.qeid_env = env;
iter_data.qeid_qmt = qmt;
- cfs_hash_for_each_safe(lqe->lqe_site->lqs_hash,
+ cfs_hash_for_each(lqe->lqe_site->lqs_hash,
qmt_entry_iter_cb, &iter_data);
/* Always notify slaves with default values. Don't
* care about overhead as will be sent only not changed
* values(see qmt_id_lock_cb for details).*/
- need_id_notify = 1;
+ need_id_notify = true;
}
- if (need_id_notify && !is_updated)
+ if (need_id_notify)
qmt_set_id_notify(env, qmt, lqe);
}
break;
case LUSTRE_Q_GETDEFAULT:
+ case LUSTRE_Q_GETDEFAULT_POOL:
is_default = true;
/* fallthrough */
break;
case LUSTRE_Q_SETDEFAULT:
+ case LUSTRE_Q_SETDEFAULT_POOL:
is_default = true;
/* fallthrough */
RETURN(ERR_PTR(-ENOENT));
}
- CDEBUG(D_QUOTA, "type %d name %p index %d\n",
- rtype, pool_name, idx);
+ CDEBUG(D_QUOTA, "type %d name %s index %d\n",
+ rtype, pool_name ?: "<none>", idx);
/* Now just find a pool with correct type in a list. Further we need
* to go through the list and find a pool that includes requested OST
* or MDT. Possibly this would return a list of pools that includes
skip "Not supported before 2.11.51."
local qtype=$1
- local qpool=$2
+ local qres_type=$2
local qid=$TSTUSR
local qprjid=$TSTPRJID
local qdtype="-U"
local qh="-B"
local LIMIT=20480 #20M disk space
local TESTFILE="$DIR/$tdir/$tfile-0"
+ local $qpool_cmd
[ $qtype == "-p" ] && ! is_project_quota_supported &&
echo "Project quota is not supported" && return 0
qid=$qprjid
}
- [ $qpool == "meta" ] && {
+ [ $qres_type == "meta" ] && {
LIMIT=10240 #10K inodes
qs="-i"
qh="-I"
}
+ [ ! -z "$3" ] && {
+ qpool_cmd="--pool $3"
+ # pool quotas don't work properly without global limit
+ $LFS setquota $qtype $qid -B1T -b1T $DIR ||
+ error "set global limit failed"
+ }
setup_quota_test || error "setup quota failed with $?"
- trap cleanup_quota_test EXIT
+ stack_trap cleanup_quota_test EXIT
quota_init
set_ost_qtype $QTYPE || error "enable ost quota failed"
log "set to use default quota"
- $LFS setquota $qtype $qid -d $DIR ||
+ $LFS setquota $qtype $qid -d $qpool_cmd $DIR ||
error "set $qid to use default quota failed"
log "set default quota"
- $LFS setquota $qdtype $qs ${LIMIT} $qh ${LIMIT} $DIR ||
+ $LFS setquota $qdtype $qpool_cmd $qs ${LIMIT} $qh ${LIMIT} $DIR ||
error "set $qid default quota failed"
log "get default quota"
$LFS quota $qdtype $DIR || error "get default quota failed"
- if [ $qpool == "data" ]; then
- local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
- awk '{print $2}')
+ if [ $qres_type == "data" ]; then
+ local SLIMIT=$($LFS quota $qpool_cmd $qdtype $DIR | \
+ grep "$MOUNT" | awk '{print $2}')
[ $SLIMIT -eq $LIMIT ] ||
error "the returned default quota is wrong"
else
local USED=$(getquota $qtype $qid global curspace)
[ $USED -ne 0 ] && error "Used space for $qid isn't 0."
- $LFS setstripe $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
+ $LFS setstripe $TESTFILE -c 1 $qpool_cmd ||
+ error "setstripe $TESTFILE failed"
chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
[ $qtype == "-p" ] && change_project -sp $TSTPRJID $DIR/$tdir
log "Test not out of quota"
- if [ $qpool == "data" ]; then
+ if [ $qres_type == "data" ]; then
$RUNAS $DD of=$TESTFILE count=$((LIMIT/2 >> 10)) oflag=sync ||
quota_error $qtype $qid "write failed, expect succeed"
else
cancel_lru_locks osc
cancel_lru_locks mdc
sync; sync_all_data || true
- if [ $qpool == "data" ]; then
+ if [ $qres_type == "data" ]; then
$RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
quota_error $qtype $qid "write succeed, expect EDQUOT"
else
unlinkmany $TESTFILE $((LIMIT*2))
fi
+ rm -f $TESTFILE
+ $LFS setstripe $TESTFILE -c 1 $qpool_cmd ||
+ error "setstripe $TESTFILE failed"
+ chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
+
log "Increase default quota"
# LU-4505: sleep 5 seconds to enable quota acquire
sleep 5
# increase default quota
- $LFS setquota $qdtype $qs $((LIMIT*3)) $qh $((LIMIT*3)) $DIR ||
- error "set default quota failed"
+ $LFS setquota $qdtype $qpool_cmd $qs $((LIMIT*3)) \
+ $qh $((LIMIT*3)) $DIR || error "set default quota failed"
cancel_lru_locks osc
cancel_lru_locks mdc
sync; sync_all_data || true
- if [ $qpool == "data" ]; then
+ if [ $qres_type == "data" ]; then
$RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
quota_error $qtype $qid "write failed, expect succeed"
else
fi
log "Set quota to override default quota"
- $LFS setquota $qtype $qid $qs ${LIMIT} $qh ${LIMIT} $DIR ||
+ $LFS setquota $qtype $qid $qpool_cmd $qs ${LIMIT} $qh ${LIMIT} $DIR ||
error "set $qid quota failed"
cancel_lru_locks osc
cancel_lru_locks mdc
sync; sync_all_data || true
- if [ $qpool == "data" ]; then
+ if [ $qres_type == "data" ]; then
$RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
quota_error $qtype $qid "write succeed, expect EQUOT"
else
# LU-4505: sleep 5 seconds to enable quota acquire
sleep 5
- $LFS setquota $qtype $qid -d $DIR ||
+ $LFS setquota $qtype $qid -d $qpool_cmd $DIR ||
error "set $qid to use default quota failed"
cancel_lru_locks osc
cancel_lru_locks mdc
sync; sync_all_data || true
- if [ $qpool == "data" ]; then
+ if [ $qres_type == "data" ]; then
$RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
quota_error $qtype $qid "write failed, expect succeed"
else
rm -f $TESTFILE
wait_delete_completed || error "wait_delete_completed failed"
sync_all_data || true
- $LFS setquota $qdtype -b 0 -B 0 -i 0 -I 0 $DIR ||
+
+ $LFS setquota $qdtype $qpool_cmd $qs 0 $qh 0 $DIR ||
error "reset default quota failed"
- $LFS setquota $qtype $qid -b 0 -B 0 -i 0 -I 0 $DIR ||
+ $LFS setquota $qtype $qid $qpool_cmd $qs 0 $qh 0 $DIR ||
error "reset quota failed"
cleanup_quota_test
}
run_test 72 "lfs quota --pool prints only pool's OSTs"
+test_73()
+{
+ local qpool="qpool1"
+
+ mds_supports_qp
+
+ pool_add $qpool || error "pool_add failed"
+ pool_add_targets $qpool 0 $((OSTCOUNT - 1)) ||
+ error "pool_add_targets failed"
+
+ test_default_quota "-u" "data" "qpool1"
+}
+run_test 73 "default limits at OST Pool Quotas"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
case LFS_POOL_OPT:
if (lfs_verify_poolarg(optarg))
return -1;
- fprintf(stdout,
- "Trying to set grace for pool %s\n", optarg);
strncpy(qctl->qc_poolname, optarg, LOV_MAXPOOLNAME);
qctl->qc_cmd = LUSTRE_Q_SETINFOPOOL;
break;
rc = -1;
goto out;
}
- fprintf(stdout,
- "Trying to set quota for pool %s\n", optarg);
strncpy(qctl->qc_poolname, optarg, LOV_MAXPOOLNAME);
- qctl->qc_cmd = LUSTRE_Q_SETQUOTAPOOL;
+ qctl->qc_cmd = qctl->qc_cmd == LUSTRE_Q_SETDEFAULT ?
+ LUSTRE_Q_SETDEFAULT_POOL :
+ LUSTRE_Q_SETQUOTAPOOL;
break;
default:
fprintf(stderr,
dqb->dqb_itime = 0;
dqb->dqb_btime = 0;
dqb->dqb_valid |= QIF_LIMITS | QIF_TIMES;
+ /* do not set inode limits for Pool Quotas */
+ if (qctl->qc_cmd == LUSTRE_Q_SETDEFAULT_POOL)
+ dqb->dqb_valid ^= QIF_ILIMITS | QIF_ITIME;
} else if ((!(limit_mask & BHLIMIT) ^ !(limit_mask & BSLIMIT)) ||
(!(limit_mask & IHLIMIT) ^ !(limit_mask & ISLIMIT))) {
/* sigh, we can't just set blimits/ilimits */
if (qctl->qc_cmd == LUSTRE_Q_GETQUOTA || qctl->qc_cmd == Q_GETOQUOTA ||
qctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL ||
- qctl->qc_cmd == LUSTRE_Q_GETDEFAULT) {
+ qctl->qc_cmd == LUSTRE_Q_GETDEFAULT ||
+ qctl->qc_cmd == LUSTRE_Q_GETDEFAULT_POOL) {
int bover = 0, iover = 0;
struct obd_dqblk *dqb = &qctl->qc_dqblk;
char numbuf[3][STRBUF_LEN];
if ((qctl->qc_cmd == LUSTRE_Q_GETQUOTA ||
qctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL ||
+ qctl->qc_cmd == LUSTRE_Q_GETDEFAULT_POOL ||
qctl->qc_cmd == LUSTRE_Q_GETDEFAULT) && !quiet)
print_quota_title(name, qctl, human_readable, show_default);
}
} else {
qctl->qc_valid = QC_GENERAL;
- qctl->qc_cmd = LUSTRE_Q_GETDEFAULT;
+ qctl->qc_cmd = qctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL ?
+ LUSTRE_Q_GETDEFAULT_POOL :
+ LUSTRE_Q_GETDEFAULT;
qctl->qc_id = 0;
}