Whamcloud - gitweb
LU-3467 target: generic hpreq handler in target
[fs/lustre-release.git] / lustre / quota / qmt_internal.h
index d83ff83..cfcfd57 100644 (file)
  * Use is subject to license terms.
  */
 
-#include "lquota_internal.h"
-
 #ifndef _QMT_INTERNAL_H
 #define _QMT_INTERNAL_H
 
+#include "lquota_internal.h"
+
 /*
  * The Quota Master Target Device.
  * The qmt is responsible for:
@@ -248,21 +248,32 @@ static inline void qmt_restore(struct lquota_entry *lqe,
                (slv) -= (cnt);              \
        } while (0)
 
-/* helper routine returning true when the id has run out of quota space, which
- * means that it has either:
- * - reached hardlimit
- * OR
- * - reached softlimit and grace time expired already */
-static inline bool qmt_space_exhausted(struct lquota_entry *lqe, __u64 now)
+/* helper routine returning true when reached hardlimit */
+static inline bool qmt_hard_exhausted(struct lquota_entry *lqe)
 {
        if (lqe->lqe_hardlimit != 0 && lqe->lqe_granted >= lqe->lqe_hardlimit)
                return true;
+       return false;
+}
+
+/* helper routine returning true when reached softlimit */
+static inline bool qmt_soft_exhausted(struct lquota_entry *lqe, __u64 now)
+{
        if (lqe->lqe_softlimit != 0 && lqe->lqe_granted > lqe->lqe_softlimit &&
            lqe->lqe_gracetime != 0 && now >= lqe->lqe_gracetime)
                return true;
        return false;
 }
 
+/* helper routine returning true when the id has run out of quota space:
+ * - reached hardlimit
+ * OR
+ * - reached softlimit and grace time expired already */
+static inline bool qmt_space_exhausted(struct lquota_entry *lqe, __u64 now)
+{
+       return (qmt_hard_exhausted(lqe) || qmt_soft_exhausted(lqe, now));
+}
+
 /* number of seconds to wait for slaves to release quota space after
  * rebalancing */
 #define QMT_REBA_TIMEOUT 2