Whamcloud - gitweb
LU-16271 ptlrpc: fix eviction right after recovery
[fs/lustre-release.git] / lustre / quota / qmt_lock.c
index 1e0a1a3..5ee05c2 100644 (file)
@@ -287,11 +287,12 @@ static bool qmt_clear_lgeg_arr_nu(struct lquota_entry *lqe, int stype, int idx)
        return false;
 }
 
-static void qmt_set_revoke(struct lu_env *env, struct lquota_entry *lqe,
+static bool qmt_set_revoke(struct lu_env *env, struct lquota_entry *lqe,
                          int stype, int idx)
 {
        unsigned long least_qunit = lqe2qpi(lqe)->qpi_least_qunit;
        struct lqe_glbl_data *lgd = lqe->lqe_glbl_data;
+       bool notify = false;
 
        if (lgd->lqeg_arr[idx].lge_qunit == least_qunit) {
                int i;
@@ -305,12 +306,13 @@ static void qmt_set_revoke(struct lu_env *env, struct lquota_entry *lqe,
                        if (qti_lqes(env)[i]->lqe_qunit == least_qunit) {
                                qti_lqes(env)[i]->lqe_revoke_time =
                                                        ktime_get_seconds();
-                               qmt_adjust_edquot(qti_lqes(env)[i],
+                               notify |= qmt_adjust_edquot(qti_lqes(env)[i],
                                                  ktime_get_real_seconds());
                        }
                }
                qti_lqes_write_unlock(env);
        }
+       return notify;
 }
 
 /*
@@ -399,8 +401,11 @@ int qmt_lvbo_update(struct lu_device *ld, struct ldlm_resource *res,
        if (rc)
                GOTO(out_exp, rc);
 
-       if (need_revoke)
-               qmt_set_revoke(env, lqe, rc, idx);
+       if (need_revoke && qmt_set_revoke(env, lqe, rc, idx) &&
+           lqe->lqe_glbl_data) {
+               qmt_seed_glbe_edquot(env, lqe->lqe_glbl_data);
+               qmt_id_lock_notify(qmt, lqe);
+       }
 
        if (lvb->lvb_id_rel) {
                LQUOTA_DEBUG(lqe, "releasing:%llu may release:%llu",
@@ -464,7 +469,7 @@ int qmt_lvbo_fill(struct lu_device *ld, struct ldlm_lock *lock, void *lvb,
                 * we are thus dealing with an ID lock. */
                struct lquota_entry *lqe = res->lr_lvb_data;
                struct qmt_device *qmt;
-               struct obd_uuid *uuid;
+               struct obd_uuid *uuid;
                int idx;
 
                uuid = &(lock)->l_export->exp_client_uuid;
@@ -490,7 +495,7 @@ int qmt_lvbo_fill(struct lu_device *ld, struct ldlm_lock *lock, void *lvb,
                lqe_putref(lqe);
        } else {
                /* global quota lock */
-               struct dt_object        *obj = res->lr_lvb_data;
+               struct dt_object *obj = res->lr_lvb_data;
 
                /* return current version of global index */
                qlvb->lvb_glb_ver = dt_version_get(env, obj);
@@ -515,10 +520,13 @@ int qmt_lvbo_free(struct lu_device *ld, struct ldlm_resource *res)
                struct lquota_entry *lqe = res->lr_lvb_data;
                struct lqe_glbl_data *lgd = lqe->lqe_glbl_data;
 
-               /* release lqe reference */
+               mutex_lock(&lqe->lqe_glbl_data_lock);
                lqe->lqe_glbl_data = NULL;
-               lqe_putref(lqe);
                qmt_free_lqe_gd(lgd);
+               mutex_unlock(&lqe->lqe_glbl_data_lock);
+
+               /* release lqe reference */
+               lqe_putref(lqe);
        } else {
                struct dt_object *obj = res->lr_lvb_data;
                /* release object reference */
@@ -788,6 +796,11 @@ void qmt_glb_lock_notify(const struct lu_env *env, struct lquota_entry *lqe,
                qti->qti_gl_desc.lquota_desc.gl_time = LQUOTA_GRACE_FLAG(0,
                                                        LQUOTA_FLAG_DEFAULT);
 
+       } else if (lqe->lqe_is_deleted) {
+               qti->qti_gl_desc.lquota_desc.gl_hardlimit = 0;
+               qti->qti_gl_desc.lquota_desc.gl_softlimit = 0;
+               qti->qti_gl_desc.lquota_desc.gl_time = LQUOTA_GRACE_FLAG(0,
+                                                       LQUOTA_FLAG_DELETED);
        } else {
                qti->qti_gl_desc.lquota_desc.gl_hardlimit = lqe->lqe_hardlimit;
                qti->qti_gl_desc.lquota_desc.gl_softlimit = lqe->lqe_softlimit;
@@ -797,7 +810,7 @@ void qmt_glb_lock_notify(const struct lu_env *env, struct lquota_entry *lqe,
 
        /* look up ldlm resource associated with global index */
        fid_build_reg_res_name(&qti->qti_fid, &qti->qti_resid);
-       res = ldlm_resource_get(pool->qpi_qmt->qmt_ns, NULL, &qti->qti_resid,
+       res = ldlm_resource_get(pool->qpi_qmt->qmt_ns, &qti->qti_resid,
                                LDLM_PLAIN, 0);
        if (IS_ERR(res)) {
                /* this might happen if no slaves have enqueued global quota
@@ -856,8 +869,7 @@ static void qmt_id_lock_glimpse(const struct lu_env *env,
 
        lquota_generate_fid(&qti->qti_fid, pool->qpi_rtype, lqe_qtype(lqe));
        fid_build_quota_res_name(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
-       res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
-                               0);
+       res = ldlm_resource_get(qmt->qmt_ns, &qti->qti_resid, LDLM_PLAIN, 0);
        if (IS_ERR(res)) {
                /* this might legitimately happens if slaves haven't had the
                 * opportunity to enqueue quota lock yet. */
@@ -1016,7 +1028,7 @@ int qmt_start_reba_thread(struct qmt_device *qmt)
 
        rc = lu_env_init(&args->qra_env, LCT_MD_THREAD);
        if (rc) {
-               CERROR("%s: failed to init env.", qmt->qmt_svname);
+               CERROR("%s: failed to init env.\n", qmt->qmt_svname);
                GOTO(out_env, rc);
        }