Whamcloud - gitweb
LU-11518 ldlm: pool recalc forceful call
[fs/lustre-release.git] / lustre / include / lustre_dlm.h
index 5cc31e9..65e91fe 100644 (file)
@@ -69,6 +69,7 @@ extern struct kset *ldlm_svc_kset;
 #define LDLM_DIRTY_AGE_LIMIT (10)
 #define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024
 #define LDLM_DEFAULT_LRU_SHRINK_BATCH (16)
+#define LDLM_DEFAULT_SLV_RECALC_PCT (10)
 
 /**
  * LDLM non-error return states
@@ -197,6 +198,17 @@ static inline int lockmode_compat(enum ldlm_mode exist_mode,
  *
  */
 
+/* Cancel lru flag, it indicates we cancel aged locks. */
+enum ldlm_lru_flags {
+       LDLM_LRU_FLAG_NO_WAIT   = 0x1, /* Cancel locks w/o blocking (neither
+                                       * sending nor waiting for any RPCs) */
+       LDLM_LRU_FLAG_CLEANUP   = 0x2, /* Used when clearing lru, tells
+                                       * prepare_lru_list to set discard flag
+                                       * on PR extent locks so we don't waste
+                                       * time saving pages that will be
+                                       * discarded momentarily */
+};
+
 struct ldlm_pool;
 struct ldlm_lock;
 struct ldlm_resource;
@@ -212,7 +224,7 @@ struct ldlm_namespace;
  */
 struct ldlm_pool_ops {
        /** Recalculate pool \a pl usage */
-       int (*po_recalc)(struct ldlm_pool *pl);
+       int (*po_recalc)(struct ldlm_pool *pl, bool force);
        /** Cancel at least \a nr locks from pool \a pl */
        int (*po_shrink)(struct ldlm_pool *pl, int nr, gfp_t gfp_mask);
        int (*po_setup)(struct ldlm_pool *pl, int limit);
@@ -451,6 +463,11 @@ struct ldlm_namespace {
         */
        unsigned int            ns_cancel_batch;
 
+       /**
+        * How much the SLV should decrease in %% to trigger LRU cancel urgently.
+        */
+       unsigned int            ns_recalc_pct;
+
        /** Maximum allowed age (last used time) for locks in the LRU.  Set in
         * seconds from userspace, but stored in ns to avoid repeat conversions.
         */
@@ -545,7 +562,13 @@ struct ldlm_namespace {
         * Flag to indicate namespace is being freed. Used to determine if
         * recalculation of LDLM pool statistics should be skipped.
         */
-       unsigned                ns_stopping:1;
+       unsigned                ns_stopping:1,
+
+       /**
+        * Flag to indicate the LRU recalc on RPC reply is in progress.
+        * Used to limit the process by 1 thread only.
+        */
+                               ns_rpc_recalc:1;
 
        /**
         * Which bucket should we start with the lock reclaim.
@@ -1811,7 +1834,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
 int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask);
 void ldlm_pool_fini(struct ldlm_pool *pl);
 int ldlm_pool_setup(struct ldlm_pool *pl, int limit);
-time64_t ldlm_pool_recalc(struct ldlm_pool *pl);
+time64_t ldlm_pool_recalc(struct ldlm_pool *pl, bool force);
 __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl);
 __u64 ldlm_pool_get_slv(struct ldlm_pool *pl);
 __u64 ldlm_pool_get_clv(struct ldlm_pool *pl);