Whamcloud - gitweb
LU-15880 quota: fix issues in reserving quota
[fs/lustre-release.git] / lustre / target / tgt_lastrcvd.c
index b0f200c..387223c 100644 (file)
@@ -872,28 +872,15 @@ static void tgt_cb_last_committed(struct lu_env *env, struct thandle *th,
        LASSERT(ccb->llcc_tgt != NULL);
        LASSERT(ccb->llcc_exp->exp_obd == ccb->llcc_tgt->lut_obd);
 
-       if (th->th_reserved_quota.qrr_count > 0) {
-               struct lu_env            temp_env;
-               int rc;
-
+       if (th->th_reserved_quota.lqi_space > 0) {
                CDEBUG(D_QUOTA, "free quota %llu %llu\n",
-                      th->th_reserved_quota.qrr_id.qid_gid,
-                      th->th_reserved_quota.qrr_count);
-
-               rc = lu_env_init(&temp_env, LCT_DT_THREAD);
-               if (rc) {
-                       CERROR("%s: can't initialize environment: rc = %d\n",
-                              ccb->llcc_tgt->lut_obd->obd_name, rc);
-                       goto out;
-               }
+                      th->th_reserved_quota.lqi_id.qid_gid,
+                      th->th_reserved_quota.lqi_space);
 
-               dt_reserve_or_free_quota(&temp_env, th->th_dev,
-                                        th->th_reserved_quota.qrr_type,
-                                        th->th_reserved_quota.qrr_id.qid_uid,
-                                        th->th_reserved_quota.qrr_id.qid_gid,
-                                        -th->th_reserved_quota.qrr_count,
-                                        false);
-               lu_env_fini(&temp_env);
+               /* env can be NULL for freeing reserved quota */
+               th->th_reserved_quota.lqi_space *= -1;
+               dt_reserve_or_free_quota(NULL, th->th_dev,
+                                        &th->th_reserved_quota);
        }
 
        /* error hit, don't update last committed to provide chance to