Whamcloud - gitweb
LU-2509 quota: various code cleanups
[fs/lustre-release.git] / lustre / quota / qmt_lock.c
index 3067ce7..05c60b0 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012 Intel, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann.lombardi@intel.com>
@@ -52,10 +52,12 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        struct obd_uuid         *uuid;
        struct lquota_lvb       *lvb;
        struct ldlm_resource    *res = (*lockp)->l_resource;
-       int                      rc;
+       int                      rc, lvb_len;
        ENTRY;
 
        req_capsule_extend(&req->rq_pill, &RQF_LDLM_INTENT_QUOTA);
+       req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER,
+                            ldlm_lvbo_size(*lockp));
 
        /* extract quota body and intent opc */
        it = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
@@ -132,10 +134,10 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        }
 
        /* on success, pack lvb in reply */
-       req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER,
-                            ldlm_lvbo_size(*lockp));
        lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
-       ldlm_lvbo_fill(*lockp, lvb, ldlm_lvbo_size(*lockp));
+       lvb_len = ldlm_lvbo_size(*lockp);
+       lvb_len = ldlm_lvbo_fill(*lockp, lvb, lvb_len);
+       req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, lvb_len, RCL_SERVER);
        EXIT;
 out:
        return rc;
@@ -252,7 +254,8 @@ int qmt_lvbo_update(struct lu_device *ld, struct ldlm_resource *res,
                /* no need to update lvb for global quota locks */
                RETURN(0);
 
-       lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
+       lvb = req_capsule_server_swab_get(&req->rq_pill, &RMF_DLM_LVB,
+                                         lustre_swab_lquota_lvb);
        if (lvb == NULL) {
                CERROR("%s: failed to extract lvb from request\n",
                       qmt->qmt_svname);
@@ -549,6 +552,7 @@ void qmt_glb_lock_notify(const struct lu_env *env, struct lquota_entry *lqe,
        qti->qti_gl_desc.lquota_desc.gl_flags     = 0;
        qti->qti_gl_desc.lquota_desc.gl_hardlimit = lqe->lqe_hardlimit;
        qti->qti_gl_desc.lquota_desc.gl_softlimit = lqe->lqe_softlimit;
+       qti->qti_gl_desc.lquota_desc.gl_time      = lqe->lqe_gracetime;
        qti->qti_gl_desc.lquota_desc.gl_ver       = ver;
 
        /* look up ldlm resource associated with global index */
@@ -678,12 +682,12 @@ void qmt_id_lock_notify(struct qmt_device *qmt, struct lquota_entry *lqe)
        ENTRY;
 
        lqe_getref(lqe);
-       cfs_spin_lock(&qmt->qmt_reba_lock);
+       spin_lock(&qmt->qmt_reba_lock);
        if (!qmt->qmt_stopping && cfs_list_empty(&lqe->lqe_link)) {
                cfs_list_add_tail(&lqe->lqe_link, &qmt->qmt_reba_list);
                added = true;
        }
-       cfs_spin_unlock(&qmt->qmt_reba_lock);
+       spin_unlock(&qmt->qmt_reba_lock);
 
        if (added)
                cfs_waitq_signal(&qmt->qmt_reba_thread.t_ctl_waitq);
@@ -735,19 +739,19 @@ static int qmt_reba_thread(void *arg)
                             !cfs_list_empty(&qmt->qmt_reba_list) ||
                             !thread_is_running(thread), &lwi);
 
-               cfs_spin_lock(&qmt->qmt_reba_lock);
+               spin_lock(&qmt->qmt_reba_lock);
                cfs_list_for_each_entry_safe(lqe, tmp, &qmt->qmt_reba_list,
                                             lqe_link) {
                        cfs_list_del_init(&lqe->lqe_link);
-                       cfs_spin_unlock(&qmt->qmt_reba_lock);
+                       spin_unlock(&qmt->qmt_reba_lock);
 
                        if (thread_is_running(thread))
                                qmt_id_lock_glimpse(env, qmt, lqe, NULL);
 
                        lqe_putref(lqe);
-                       cfs_spin_lock(&qmt->qmt_reba_lock);
+                       spin_lock(&qmt->qmt_reba_lock);
                }
-               cfs_spin_unlock(&qmt->qmt_reba_lock);
+               spin_unlock(&qmt->qmt_reba_lock);
 
                if (!thread_is_running(thread))
                        break;