lqe->lqe_revoke_time = 0;
init_rwsem(&lqe->lqe_sem);
+ mutex_init(&lqe->lqe_glbl_data_lock);
}
/* Apply the default quota setting to the specified quota entry
int qmt_glb_write_lqes(const struct lu_env *env, struct thandle *th,
__u32 flags, __u64 *ver)
{
- int i, rc;
- rc = 0;
+ int i, rc = 0;
for (i = 0; i < qti_lqes_cnt(env); i++) {
rc = qmt_glb_write(env, th, qti_lqes(env)[i], flags, ver);
if (lqe->lqe_is_default) {
rec->qbr_hardlimit = 0;
rec->qbr_softlimit = 0;
- rec->qbr_time = LQUOTA_GRACE_FLAG(0, LQUOTA_FLAG_DEFAULT);
+ rec->qbr_time = LQUOTA_GRACE_FLAG(lqe->lqe_gracetime,
+ LQUOTA_FLAG_DEFAULT);
} else {
rec->qbr_hardlimit = lqe->lqe_hardlimit;
rec->qbr_softlimit = lqe->lqe_softlimit;
return need_reseed;
}
- if (lqe_gl->lqe_glbl_data && need_reseed) {
- qmt_seed_glbe_all(env, lqe_gl->lqe_glbl_data, qunit, edquot);
+ if (need_reseed) {
+ mutex_lock(&lqe_gl->lqe_glbl_data_lock);
+ if (lqe_gl->lqe_glbl_data)
+ qmt_seed_glbe_all(env, lqe_gl->lqe_glbl_data, qunit,
+ edquot);
+ mutex_unlock(&lqe_gl->lqe_glbl_data_lock);
+
qmt_id_lock_notify(qmt, lqe_gl);
}
return need_reseed;
for (i = 0; i < qti_lqes_cnt(env); i++)
need_notify |= qmt_revalidate(env, qti_lqes(env)[i]);
+ if (!need_notify)
+ return;
+
/* There could be no ID lock to the moment of reconciliation.
* As a result lqe global data is not initialised yet. It is ok
* for release and report requests. */
if (!lqe_gl->lqe_glbl_data &&
- (req_is_rel(qb_flags) || req_has_rep(qb_flags)))
+ (req_is_rel(qb_flags) || req_has_rep(qb_flags))) {
return;
+ }
- if (need_notify) {
+ mutex_lock(&lqe_gl->lqe_glbl_data_lock);
+ if (lqe_gl->lqe_glbl_data)
qmt_seed_glbe(env, lqe_gl->lqe_glbl_data);
- qmt_id_lock_notify(qmt, lqe_gl);
- }
+ mutex_unlock(&lqe_gl->lqe_glbl_data_lock);
+
+ qmt_id_lock_notify(qmt, lqe_gl);
}
void qti_lqes_init(const struct lu_env *env)
qti->qti_lqes_cnt = 0;
}
-int qti_lqes_min_qunit(const struct lu_env *env)
+__u64 qti_lqes_min_qunit(const struct lu_env *env)
{
- int i, min, qunit;
+ __u64 min, qunit;
+ int i;
for (i = 1, min = qti_lqe_qunit(env, 0); i < qti_lqes_cnt(env); i++) {
qunit = qti_lqe_qunit(env, i);
- if (qunit < min)
+ /* if qunit is 0, lqe is not enforced and we can ignore it */
+ if (qunit && qunit < min)
min = qunit;
}