- /* Simple proportion but it gives impression on how much should be
- * SLV changed for request @nr of locks to be canceled.*/
- slv_delta = nr * ldlm_pool_get_slv(pl);
- limit = ldlm_pool_get_limit(pl);
- do_div(slv_delta, granted);
-
- /* As SLV has some dependence on historical data, that is new value
- * is based on old one, this decreasing will make clients get some
- * locks back to the server and after some time it will stabilize.*/
- if (slv_delta < ldlm_pool_get_slv(pl))
- ldlm_pool_set_slv(pl, ldlm_pool_get_slv(pl) - slv_delta);
- else
- ldlm_pool_set_slv(pl, ldlm_pool_slv_min(limit));
- spin_unlock(&pl->pl_lock);
-
- /* We did not really free any memory here so far, it only will be
- * freed later may be, so that we return 0 to not confuse VM. */
- RETURN(0);
+ /*
+ * Make sure that pool informed obd of last SLV changes.
+ */
+ ldlm_srv_pool_push_slv(pl);
+ cfs_spin_unlock(&pl->pl_lock);
+
+ /*
+ * We did not really free any memory here so far, it only will be
+ * freed later may be, so that we return 0 to not confuse VM.
+ */
+ return 0;
+}
+
+/**
+ * Setup server side pool \a pl with passed \a limit.
+ */
+static int ldlm_srv_pool_setup(struct ldlm_pool *pl, int limit)
+{
+ struct obd_device *obd;
+
+ obd = ldlm_pl2ns(pl)->ns_obd;
+ LASSERT(obd != NULL && obd != LP_POISON);
+ LASSERT(obd->obd_type != LP_POISON);
+ cfs_write_lock(&obd->obd_pool_lock);
+ obd->obd_pool_limit = limit;
+ cfs_write_unlock(&obd->obd_pool_lock);
+
+ ldlm_pool_set_limit(pl, limit);
+ return 0;
+}
+
+/**
+ * Sets SLV and Limit from ldlm_pl2ns(pl)->ns_obd tp passed \a pl.
+ */
+static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
+{
+ struct obd_device *obd;
+
+ /*
+ * Get new SLV and Limit from obd which is updated with coming
+ * RPCs.
+ */
+ obd = ldlm_pl2ns(pl)->ns_obd;
+ LASSERT(obd != NULL);
+ cfs_read_lock(&obd->obd_pool_lock);
+ pl->pl_server_lock_volume = obd->obd_pool_slv;
+ ldlm_pool_set_limit(pl, obd->obd_pool_limit);
+ cfs_read_unlock(&obd->obd_pool_lock);