+typedef int (*ldlm_pool_recalc_t)(struct ldlm_pool *pl);
+
+typedef int (*ldlm_pool_shrink_t)(struct ldlm_pool *pl,
+ int nr, unsigned int gfp_mask);
+
+enum {
+ LDLM_POOL_CTL_RECALC = 1 << 0, /* Pool recalc is enabled */
+ LDLM_POOL_CTL_SHRINK = 1 << 1, /* Pool shrink is enabled */
+ LDLM_POOL_CTL_FULL = (LDLM_POOL_CTL_RECALC | LDLM_POOL_CTL_SHRINK)
+};
+
+/* One second for pools thread check interval. */
+#define LDLM_POOLS_THREAD_PERIOD (1)
+
+/* 5% margin for modest pools. See ldlm_pool.c for details. */
+#define LDLM_POOLS_MODEST_MARGIN (5)
+
+/* A change to SLV in % after which we want to wake up pools thread asap. */
+#define LDLM_POOLS_FAST_SLV_CHANGE (5)
+
+struct ldlm_pool {
+ /* Common pool fields */
+ cfs_proc_dir_entry_t *pl_proc_dir; /* Pool proc directory. */
+ char pl_name[100]; /* Pool name, should be long
+ * enough to contain complex
+ * proc entry name. */
+ spinlock_t pl_lock; /* Lock for protecting slv/clv
+ * updates. */
+ atomic_t pl_limit; /* Number of allowed locks in
+ * in pool, both, client and
+ * server side. */
+ atomic_t pl_granted; /* Number of granted locks. */
+ atomic_t pl_grant_rate; /* Grant rate per T. */
+ atomic_t pl_cancel_rate; /* Cancel rate per T. */
+ atomic_t pl_grant_speed; /* Grant speed (GR - CR) per T. */
+ __u64 pl_server_lock_volume; /* Server lock volume. Protected
+ * by pl_lock. */
+ cfs_time_t pl_update_time; /* Time when last slv from server
+ * was obtained. */
+ ldlm_pool_recalc_t pl_recalc; /* Recalc callback func pointer. */
+ ldlm_pool_shrink_t pl_shrink; /* Shrink callback func pointer. */
+ int pl_control; /* Pool features mask */
+
+ /* Server side pool fields */
+ atomic_t pl_grant_plan; /* Planned number of granted
+ * locks for next T. */
+ atomic_t pl_grant_step; /* Grant plan step for next T. */
+
+ /* Client side pool related fields */
+ atomic_t pl_lock_volume_factor; /* Lock volume factor. */
+ struct lprocfs_stats *pl_stats; /* Pool statistics. */
+};
+
+static inline int pool_recalc_enabled(struct ldlm_pool *pl)
+{
+ return pl->pl_control & LDLM_POOL_CTL_RECALC;
+}
+
+static inline int pool_shrink_enabled(struct ldlm_pool *pl)
+{
+ return pl->pl_control & LDLM_POOL_CTL_SHRINK;
+}
+