Whamcloud - gitweb
LU-9019 quota : migrate to 64 bit time
[fs/lustre-release.git] / lustre / quota / qsd_handler.c
index b90ecc0..a8d842d 100644 (file)
@@ -402,7 +402,7 @@ out:
        adjust = qsd_adjust_needed(lqe);
        if (reqbody && req_is_acq(reqbody->qb_flags) && ret != -EDQUOT) {
                lqe->lqe_acq_rc = ret;
-               lqe->lqe_acq_time = cfs_time_current_64();
+               lqe->lqe_acq_time = ktime_get_seconds();
        }
 out_noadjust:
        qsd_request_exit(lqe);
@@ -463,8 +463,7 @@ static int qsd_acquire_local(struct lquota_entry *lqe, __u64 space)
         * sometimes due to the race reply of dqacq vs. id lock glimpse
         * (see LU-4505), so we revalidate it every 5 seconds. */
        } else if (lqe->lqe_edquot &&
-                  cfs_time_before_64(cfs_time_shift_64(-5),
-                                     lqe->lqe_edquot_time)) {
+                  (lqe->lqe_edquot_time > ktime_get_seconds() - 5)) {
                rc = -EDQUOT;
        }else {
                rc = -EAGAIN;
@@ -563,7 +562,7 @@ static int qsd_acquire_remote(const struct lu_env *env,
 
        /* check whether an acquire request completed recently */
        if (lqe->lqe_acq_rc != 0 &&
-           cfs_time_before_64(cfs_time_shift_64(-1), lqe->lqe_acq_time)) {
+           lqe->lqe_acq_time > ktime_get_seconds() - 1) {
                lqe_write_unlock(lqe);
                LQUOTA_DEBUG(lqe, "using cached return code %d", lqe->lqe_acq_rc);
                RETURN(lqe->lqe_acq_rc);
@@ -687,9 +686,10 @@ static int qsd_op_begin0(const struct lu_env *env, struct qsd_qtype_info *qqi,
                         struct lquota_id_info *qid, long long space,
                         int *flags)
 {
-       struct lquota_entry     *lqe;
-       int                      rc, ret = -EINPROGRESS;
-       struct l_wait_info       lwi;
+       struct lquota_entry *lqe;
+       struct l_wait_info lwi;
+       int qtype_flag = 0;
+       int rc, ret = -EINPROGRESS;
        ENTRY;
 
        if (qid->lqi_qentry != NULL) {
@@ -772,7 +772,7 @@ static int qsd_op_begin0(const struct lu_env *env, struct qsd_qtype_info *qqi,
 out_flags:
                LASSERT(qid->lqi_is_blk);
                if (rc != 0) {
-                       *flags |= LQUOTA_OVER_FL(qqi->qqi_qtype);
+                       *flags |= lquota_over_fl(qqi->qqi_qtype);
                } else {
                        __u64   usage;
 
@@ -782,11 +782,12 @@ out_flags:
                        usage += lqe->lqe_waiting_write;
                        usage += qqi->qqi_qsd->qsd_sync_threshold;
 
+                       qtype_flag = lquota_over_fl(qqi->qqi_qtype);
                        /* if we should notify client to start sync write */
                        if (usage >= lqe->lqe_granted - lqe->lqe_pending_rel)
-                               *flags |= LQUOTA_OVER_FL(qqi->qqi_qtype);
+                               *flags |= qtype_flag;
                        else
-                               *flags &= ~LQUOTA_OVER_FL(qqi->qqi_qtype);
+                               *flags &= ~qtype_flag;
                        lqe_read_unlock(lqe);
                }
        }
@@ -833,6 +834,9 @@ int qsd_op_begin(const struct lu_env *env, struct qsd_instance *qsd,
        if (unlikely(qsd == NULL))
                RETURN(0);
 
+       if (qsd->qsd_dev->dd_rdonly)
+               RETURN(0);
+
        /* We don't enforce quota until the qsd_instance is started */
        read_lock(&qsd->qsd_lock);
        if (!qsd->qsd_started) {
@@ -851,7 +855,7 @@ int qsd_op_begin(const struct lu_env *env, struct qsd_instance *qsd,
         * or - the user/group is root
         * or - quota accounting isn't enabled */
        if (!qsd_type_enabled(qsd, qi->lqi_type) || qi->lqi_id.qid_uid == 0 ||
-           qsd->qsd_acct_failed)
+           (qsd->qsd_type_array[qi->lqi_type])->qqi_acct_failed)
                RETURN(0);
 
        LASSERTF(trans->lqt_id_cnt <= QUOTA_MAX_TRANSIDS, "id_cnt=%d\n",
@@ -922,6 +926,9 @@ int qsd_adjust(const struct lu_env *env, struct lquota_entry *lqe)
        qqi = lqe2qqi(lqe);
        qsd = qqi->qqi_qsd;
 
+       if (qsd->qsd_dev->dd_rdonly)
+               RETURN(0);
+
        lqe_write_lock(lqe);
 
        /* fill qb_count & qb_flags */
@@ -1075,6 +1082,9 @@ void qsd_op_end(const struct lu_env *env, struct qsd_instance *qsd,
        if (unlikely(qsd == NULL))
                RETURN_EXIT;
 
+       if (qsd->qsd_dev->dd_rdonly)
+               RETURN_EXIT;
+
        /* We don't enforce quota until the qsd_instance is started */
        read_lock(&qsd->qsd_lock);
        if (!qsd->qsd_started) {