1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2011, 2012, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
38 * lustre/ldlm/ldlm_pool.c
40 * Author: Yury Umanets <umka@clusterfs.com>
44 * Idea of this code is rather simple. Each second, for each server namespace
45 * we have SLV - server lock volume which is calculated on current number of
46 * granted locks, grant speed for past period, etc - that is, locking load.
47 * This SLV number may be thought as a flow definition for simplicity. It is
48 * sent to clients with each occasion to let them know what is current load
49 * situation on the server. By default, at the beginning, SLV on server is
50 * set max value which is calculated as the following: allow to one client
51 * have all locks of limit ->pl_limit for 10h.
53 * Next, on clients, number of cached locks is not limited artificially in any
54 * way as it was before. Instead, client calculates CLV, that is, client lock
55 * volume for each lock and compares it with last SLV from the server. CLV is
56 * calculated as the number of locks in LRU * lock live time in seconds. If
57 * CLV > SLV - lock is canceled.
59 * Client has LVF, that is, lock volume factor which regulates how much sensitive
60 * client should be about last SLV from server. The higher LVF is the more locks
61 * will be canceled on client. Default value for it is 1. Setting LVF to 2 means
62 * that client will cancel locks 2 times faster.
64 * Locks on a client will be canceled more intensively in these cases:
65 * (1) if SLV is smaller, that is, load is higher on the server;
66 * (2) client has a lot of locks (the more locks are held by client, the bigger
67 * chances that some of them should be canceled);
68 * (3) client has old locks (taken some time ago);
70 * Thus, according to flow paradigm that we use for better understanding SLV,
71 * CLV is the volume of particle in flow described by SLV. According to this,
72 * if flow is getting thinner, more and more particles become outside of it and
73 * as particles are locks, they should be canceled.
75 * General idea of this belongs to Vitaly Fertman (vitaly@clusterfs.com). Andreas
76 * Dilger (adilger@clusterfs.com) proposed few nice ideas like using LVF and many
77 * cleanups. Flow definition to allow more easy understanding of the logic belongs
78 * to Nikita Danilov (nikita@clusterfs.com) as well as many cleanups and fixes.
79 * And design and implementation are done by Yury Umanets (umka@clusterfs.com).
81 * Glossary for terms used:
83 * pl_limit - Number of allowed locks in pool. Applies to server and client
86 * pl_granted - Number of granted locks (calculated);
87 * pl_grant_rate - Number of granted locks for last T (calculated);
88 * pl_cancel_rate - Number of canceled locks for last T (calculated);
89 * pl_grant_speed - Grant speed (GR - CR) for last T (calculated);
90 * pl_grant_plan - Planned number of granted locks for next T (calculated);
91 * pl_server_lock_volume - Current server lock volume (calculated);
93 * As it may be seen from list above, we have few possible tunables which may
94 * affect behavior much. They all may be modified via proc. However, they also
95 * give a possibility for constructing few pre-defined behavior policies. If
96 * none of predefines is suitable for a working pattern being used, new one may
97 * be "constructed" via proc tunables.
100 #define DEBUG_SUBSYSTEM S_LDLM
103 # include <lustre_dlm.h>
105 # include <liblustre.h>
108 #include <cl_object.h>
110 #include <obd_class.h>
111 #include <obd_support.h>
112 #include "ldlm_internal.h"
114 #ifdef HAVE_LRU_RESIZE_SUPPORT
117 * 50 ldlm locks for 1MB of RAM.
119 #define LDLM_POOL_HOST_L ((CFS_NUM_CACHEPAGES >> (20 - CFS_PAGE_SHIFT)) * 50)
122 * Maximal possible grant step plan in %.
124 #define LDLM_POOL_MAX_GSP (30)
127 * Minimal possible grant step plan in %.
129 #define LDLM_POOL_MIN_GSP (1)
132 * This controls the speed of reaching LDLM_POOL_MAX_GSP
133 * with increasing thread period.
135 #define LDLM_POOL_GSP_STEP_SHIFT (2)
138 * LDLM_POOL_GSP% of all locks is default GP.
140 #define LDLM_POOL_GP(L) (((L) * LDLM_POOL_MAX_GSP) / 100)
143 * Max age for locks on clients.
145 #define LDLM_POOL_MAX_AGE (36000)
148 * The granularity of SLV calculation.
150 #define LDLM_POOL_SLV_SHIFT (10)
153 extern cfs_proc_dir_entry_t *ldlm_ns_proc_dir;
156 static inline __u64 dru(__u64 val, __u32 shift, int round_up)
158 return (val + (round_up ? (1 << shift) - 1 : 0)) >> shift;
161 static inline __u64 ldlm_pool_slv_max(__u32 L)
164 * Allow to have all locks for 1 client for 10 hrs.
165 * Formula is the following: limit * 10h / 1 client.
167 __u64 lim = (__u64)L * LDLM_POOL_MAX_AGE / 1;
171 static inline __u64 ldlm_pool_slv_min(__u32 L)
177 LDLM_POOL_FIRST_STAT = 0,
178 LDLM_POOL_GRANTED_STAT = LDLM_POOL_FIRST_STAT,
179 LDLM_POOL_GRANT_STAT,
180 LDLM_POOL_CANCEL_STAT,
181 LDLM_POOL_GRANT_RATE_STAT,
182 LDLM_POOL_CANCEL_RATE_STAT,
183 LDLM_POOL_GRANT_PLAN_STAT,
185 LDLM_POOL_SHRINK_REQTD_STAT,
186 LDLM_POOL_SHRINK_FREED_STAT,
187 LDLM_POOL_RECALC_STAT,
188 LDLM_POOL_TIMING_STAT,
192 static inline struct ldlm_namespace *ldlm_pl2ns(struct ldlm_pool *pl)
194 return container_of(pl, struct ldlm_namespace, ns_pool);
198 * Calculates suggested grant_step in % of available locks for passed
199 * \a period. This is later used in grant_plan calculations.
201 static inline int ldlm_pool_t2gsp(unsigned int t)
204 * This yields 1% grant step for anything below LDLM_POOL_GSP_STEP
205 * and up to 30% for anything higher than LDLM_POOL_GSP_STEP.
207 * How this will affect execution is the following:
209 * - for thread period 1s we will have grant_step 1% which good from
210 * pov of taking some load off from server and push it out to clients.
211 * This is like that because 1% for grant_step means that server will
212 * not allow clients to get lots of locks in short period of time and
213 * keep all old locks in their caches. Clients will always have to
214 * get some locks back if they want to take some new;
216 * - for thread period 10s (which is default) we will have 23% which
217 * means that clients will have enough of room to take some new locks
218 * without getting some back. All locks from this 23% which were not
219 * taken by clients in current period will contribute in SLV growing.
220 * SLV growing means more locks cached on clients until limit or grant
223 return LDLM_POOL_MAX_GSP -
224 ((LDLM_POOL_MAX_GSP - LDLM_POOL_MIN_GSP) >>
225 (t >> LDLM_POOL_GSP_STEP_SHIFT));
229 * Recalculates next grant limit on passed \a pl.
231 * \pre ->pl_lock is locked.
233 static void ldlm_pool_recalc_grant_plan(struct ldlm_pool *pl)
235 int granted, grant_step, limit;
237 limit = ldlm_pool_get_limit(pl);
238 granted = cfs_atomic_read(&pl->pl_granted);
240 grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
241 grant_step = ((limit - granted) * grant_step) / 100;
242 pl->pl_grant_plan = granted + grant_step;
243 limit = (limit * 5) >> 2;
244 if (pl->pl_grant_plan > limit)
245 pl->pl_grant_plan = limit;
249 * Recalculates next SLV on passed \a pl.
251 * \pre ->pl_lock is locked.
253 static void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
263 slv = pl->pl_server_lock_volume;
264 grant_plan = pl->pl_grant_plan;
265 limit = ldlm_pool_get_limit(pl);
266 granted = cfs_atomic_read(&pl->pl_granted);
267 round_up = granted < limit;
269 grant_usage = max_t(int, limit - (granted - grant_plan), 1);
272 * Find out SLV change factor which is the ratio of grant usage
273 * from limit. SLV changes as fast as the ratio of grant plan
274 * consumption. The more locks from grant plan are not consumed
275 * by clients in last interval (idle time), the faster grows
276 * SLV. And the opposite, the more grant plan is over-consumed
277 * (load time) the faster drops SLV.
279 slv_factor = (grant_usage << LDLM_POOL_SLV_SHIFT);
280 do_div(slv_factor, limit);
281 slv = slv * slv_factor;
282 slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up);
284 if (slv > ldlm_pool_slv_max(limit)) {
285 slv = ldlm_pool_slv_max(limit);
286 } else if (slv < ldlm_pool_slv_min(limit)) {
287 slv = ldlm_pool_slv_min(limit);
290 pl->pl_server_lock_volume = slv;
294 * Recalculates next stats on passed \a pl.
296 * \pre ->pl_lock is locked.
298 static void ldlm_pool_recalc_stats(struct ldlm_pool *pl)
300 int grant_plan = pl->pl_grant_plan;
301 __u64 slv = pl->pl_server_lock_volume;
302 int granted = cfs_atomic_read(&pl->pl_granted);
303 int grant_rate = cfs_atomic_read(&pl->pl_grant_rate);
304 int cancel_rate = cfs_atomic_read(&pl->pl_cancel_rate);
306 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_SLV_STAT,
308 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
310 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANT_RATE_STAT,
312 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANT_PLAN_STAT,
314 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_CANCEL_RATE_STAT,
319 * Sets current SLV into obd accessible via ldlm_pl2ns(pl)->ns_obd.
321 static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl)
323 struct obd_device *obd;
326 * Set new SLV in obd field for using it later without accessing the
327 * pool. This is required to avoid race between sending reply to client
328 * with new SLV and cleanup server stack in which we can't guarantee
329 * that namespace is still alive. We know only that obd is alive as
330 * long as valid export is alive.
332 obd = ldlm_pl2ns(pl)->ns_obd;
333 LASSERT(obd != NULL);
334 cfs_write_lock(&obd->obd_pool_lock);
335 obd->obd_pool_slv = pl->pl_server_lock_volume;
336 cfs_write_unlock(&obd->obd_pool_lock);
340 * Recalculates all pool fields on passed \a pl.
342 * \pre ->pl_lock is not locked.
344 static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
346 time_t recalc_interval_sec;
349 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
350 if (recalc_interval_sec < pl->pl_recalc_period)
353 cfs_spin_lock(&pl->pl_lock);
354 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
355 if (recalc_interval_sec < pl->pl_recalc_period) {
356 cfs_spin_unlock(&pl->pl_lock);
360 * Recalc SLV after last period. This should be done
361 * _before_ recalculating new grant plan.
363 ldlm_pool_recalc_slv(pl);
366 * Make sure that pool informed obd of last SLV changes.
368 ldlm_srv_pool_push_slv(pl);
371 * Update grant_plan for new period.
373 ldlm_pool_recalc_grant_plan(pl);
375 pl->pl_recalc_time = cfs_time_current_sec();
376 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
377 recalc_interval_sec);
378 cfs_spin_unlock(&pl->pl_lock);
383 * This function is used on server side as main entry point for memory
384 * pressure handling. It decreases SLV on \a pl according to passed
385 * \a nr and \a gfp_mask.
387 * Our goal here is to decrease SLV such a way that clients hold \a nr
388 * locks smaller in next 10h.
390 static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
391 int nr, unsigned int gfp_mask)
396 * VM is asking how many entries may be potentially freed.
399 return cfs_atomic_read(&pl->pl_granted);
402 * Client already canceled locks but server is already in shrinker
403 * and can't cancel anything. Let's catch this race.
405 if (cfs_atomic_read(&pl->pl_granted) == 0)
408 cfs_spin_lock(&pl->pl_lock);
411 * We want shrinker to possibly cause cancellation of @nr locks from
412 * clients or grant approximately @nr locks smaller next intervals.
414 * This is why we decreased SLV by @nr. This effect will only be as
415 * long as one re-calc interval (1s these days) and this should be
416 * enough to pass this decreased SLV to all clients. On next recalc
417 * interval pool will either increase SLV if locks load is not high
418 * or will keep on same level or even decrease again, thus, shrinker
419 * decreased SLV will affect next recalc intervals and this way will
420 * make locking load lower.
422 if (nr < pl->pl_server_lock_volume) {
423 pl->pl_server_lock_volume = pl->pl_server_lock_volume - nr;
425 limit = ldlm_pool_get_limit(pl);
426 pl->pl_server_lock_volume = ldlm_pool_slv_min(limit);
430 * Make sure that pool informed obd of last SLV changes.
432 ldlm_srv_pool_push_slv(pl);
433 cfs_spin_unlock(&pl->pl_lock);
436 * We did not really free any memory here so far, it only will be
437 * freed later may be, so that we return 0 to not confuse VM.
443 * Setup server side pool \a pl with passed \a limit.
445 static int ldlm_srv_pool_setup(struct ldlm_pool *pl, int limit)
447 struct obd_device *obd;
449 obd = ldlm_pl2ns(pl)->ns_obd;
450 LASSERT(obd != NULL && obd != LP_POISON);
451 LASSERT(obd->obd_type != LP_POISON);
452 cfs_write_lock(&obd->obd_pool_lock);
453 obd->obd_pool_limit = limit;
454 cfs_write_unlock(&obd->obd_pool_lock);
456 ldlm_pool_set_limit(pl, limit);
461 * Sets SLV and Limit from ldlm_pl2ns(pl)->ns_obd tp passed \a pl.
463 static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
465 struct obd_device *obd;
468 * Get new SLV and Limit from obd which is updated with coming
471 obd = ldlm_pl2ns(pl)->ns_obd;
472 LASSERT(obd != NULL);
473 cfs_read_lock(&obd->obd_pool_lock);
474 pl->pl_server_lock_volume = obd->obd_pool_slv;
475 ldlm_pool_set_limit(pl, obd->obd_pool_limit);
476 cfs_read_unlock(&obd->obd_pool_lock);
480 * Recalculates client size pool \a pl according to current SLV and Limit.
482 static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
484 time_t recalc_interval_sec;
487 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
488 if (recalc_interval_sec < pl->pl_recalc_period)
491 cfs_spin_lock(&pl->pl_lock);
493 * Check if we need to recalc lists now.
495 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
496 if (recalc_interval_sec < pl->pl_recalc_period) {
497 cfs_spin_unlock(&pl->pl_lock);
502 * Make sure that pool knows last SLV and Limit from obd.
504 ldlm_cli_pool_pop_slv(pl);
506 pl->pl_recalc_time = cfs_time_current_sec();
507 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
508 recalc_interval_sec);
509 cfs_spin_unlock(&pl->pl_lock);
512 * Do not cancel locks in case lru resize is disabled for this ns.
514 if (!ns_connect_lru_resize(ldlm_pl2ns(pl)))
518 * In the time of canceling locks on client we do not need to maintain
519 * sharp timing, we only want to cancel locks asap according to new SLV.
520 * It may be called when SLV has changed much, this is why we do not
521 * take into account pl->pl_recalc_time here.
523 RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LDLM_SYNC,
528 * This function is main entry point for memory pressure handling on client
529 * side. Main goal of this function is to cancel some number of locks on
530 * passed \a pl according to \a nr and \a gfp_mask.
532 static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
533 int nr, unsigned int gfp_mask)
535 struct ldlm_namespace *ns;
536 int canceled = 0, unused;
541 * Do not cancel locks in case lru resize is disabled for this ns.
543 if (!ns_connect_lru_resize(ns))
547 * Make sure that pool knows last SLV and Limit from obd.
549 ldlm_cli_pool_pop_slv(pl);
551 cfs_spin_lock(&ns->ns_lock);
552 unused = ns->ns_nr_unused;
553 cfs_spin_unlock(&ns->ns_lock);
556 canceled = ldlm_cancel_lru(ns, nr, LDLM_ASYNC,
561 * Return the number of potentially reclaimable locks.
563 return ((unused - canceled) / 100) * sysctl_vfs_cache_pressure;
565 return unused - canceled;
569 struct ldlm_pool_ops ldlm_srv_pool_ops = {
570 .po_recalc = ldlm_srv_pool_recalc,
571 .po_shrink = ldlm_srv_pool_shrink,
572 .po_setup = ldlm_srv_pool_setup
575 struct ldlm_pool_ops ldlm_cli_pool_ops = {
576 .po_recalc = ldlm_cli_pool_recalc,
577 .po_shrink = ldlm_cli_pool_shrink
581 * Pool recalc wrapper. Will call either client or server pool recalc callback
582 * depending what pool \a pl is used.
584 int ldlm_pool_recalc(struct ldlm_pool *pl)
586 time_t recalc_interval_sec;
589 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
590 if (recalc_interval_sec <= 0)
593 cfs_spin_lock(&pl->pl_lock);
594 recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
595 if (recalc_interval_sec > 0) {
597 * Update pool statistics every 1s.
599 ldlm_pool_recalc_stats(pl);
602 * Zero out all rates and speed for the last period.
604 cfs_atomic_set(&pl->pl_grant_rate, 0);
605 cfs_atomic_set(&pl->pl_cancel_rate, 0);
607 cfs_spin_unlock(&pl->pl_lock);
610 if (pl->pl_ops->po_recalc != NULL) {
611 count = pl->pl_ops->po_recalc(pl);
612 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
619 EXPORT_SYMBOL(ldlm_pool_recalc);
622 * Pool shrink wrapper. Will call either client or server pool recalc callback
623 * depending what pool \a pl is used.
625 int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
626 unsigned int gfp_mask)
630 if (pl->pl_ops->po_shrink != NULL) {
631 cancel = pl->pl_ops->po_shrink(pl, nr, gfp_mask);
633 lprocfs_counter_add(pl->pl_stats,
634 LDLM_POOL_SHRINK_REQTD_STAT,
636 lprocfs_counter_add(pl->pl_stats,
637 LDLM_POOL_SHRINK_FREED_STAT,
639 CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, "
640 "shrunk %d\n", pl->pl_name, nr, cancel);
645 EXPORT_SYMBOL(ldlm_pool_shrink);
648 * Pool setup wrapper. Will call either client or server pool recalc callback
649 * depending what pool \a pl is used.
651 * Sets passed \a limit into pool \a pl.
653 int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
655 if (pl->pl_ops->po_setup != NULL)
656 return(pl->pl_ops->po_setup(pl, limit));
659 EXPORT_SYMBOL(ldlm_pool_setup);
662 static int lprocfs_rd_pool_state(char *page, char **start, off_t off,
663 int count, int *eof, void *data)
665 int granted, grant_rate, cancel_rate, grant_step;
666 int nr = 0, grant_speed, grant_plan, lvf;
667 struct ldlm_pool *pl = data;
671 cfs_spin_lock(&pl->pl_lock);
672 slv = pl->pl_server_lock_volume;
673 clv = pl->pl_client_lock_volume;
674 limit = ldlm_pool_get_limit(pl);
675 grant_plan = pl->pl_grant_plan;
676 granted = cfs_atomic_read(&pl->pl_granted);
677 grant_rate = cfs_atomic_read(&pl->pl_grant_rate);
678 cancel_rate = cfs_atomic_read(&pl->pl_cancel_rate);
679 grant_speed = grant_rate - cancel_rate;
680 lvf = cfs_atomic_read(&pl->pl_lock_volume_factor);
681 grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
682 cfs_spin_unlock(&pl->pl_lock);
684 nr += snprintf(page + nr, count - nr, "LDLM pool state (%s):\n",
686 nr += snprintf(page + nr, count - nr, " SLV: "LPU64"\n", slv);
687 nr += snprintf(page + nr, count - nr, " CLV: "LPU64"\n", clv);
688 nr += snprintf(page + nr, count - nr, " LVF: %d\n", lvf);
690 if (ns_is_server(ldlm_pl2ns(pl))) {
691 nr += snprintf(page + nr, count - nr, " GSP: %d%%\n",
693 nr += snprintf(page + nr, count - nr, " GP: %d\n",
696 nr += snprintf(page + nr, count - nr, " GR: %d\n",
698 nr += snprintf(page + nr, count - nr, " CR: %d\n",
700 nr += snprintf(page + nr, count - nr, " GS: %d\n",
702 nr += snprintf(page + nr, count - nr, " G: %d\n",
704 nr += snprintf(page + nr, count - nr, " L: %d\n",
709 static int lprocfs_rd_grant_speed(char *page, char **start, off_t off,
710 int count, int *eof, void *data)
712 struct ldlm_pool *pl = data;
715 cfs_spin_lock(&pl->pl_lock);
716 /* serialize with ldlm_pool_recalc */
717 grant_speed = cfs_atomic_read(&pl->pl_grant_rate) -
718 cfs_atomic_read(&pl->pl_cancel_rate);
719 cfs_spin_unlock(&pl->pl_lock);
720 return lprocfs_rd_uint(page, start, off, count, eof, &grant_speed);
723 LDLM_POOL_PROC_READER(grant_plan, int);
724 LDLM_POOL_PROC_READER(recalc_period, int);
725 LDLM_POOL_PROC_WRITER(recalc_period, int);
727 static int ldlm_pool_proc_init(struct ldlm_pool *pl)
729 struct ldlm_namespace *ns = ldlm_pl2ns(pl);
730 struct proc_dir_entry *parent_ns_proc;
731 struct lprocfs_vars pool_vars[2];
732 char *var_name = NULL;
736 OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
740 parent_ns_proc = lprocfs_srch(ldlm_ns_proc_dir,
742 if (parent_ns_proc == NULL) {
743 CERROR("%s: proc entry is not initialized\n",
745 GOTO(out_free_name, rc = -EINVAL);
747 pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
749 if (IS_ERR(pl->pl_proc_dir)) {
750 CERROR("LProcFS failed in ldlm-pool-init\n");
751 rc = PTR_ERR(pl->pl_proc_dir);
752 GOTO(out_free_name, rc);
755 var_name[MAX_STRING_SIZE] = '\0';
756 memset(pool_vars, 0, sizeof(pool_vars));
757 pool_vars[0].name = var_name;
759 snprintf(var_name, MAX_STRING_SIZE, "server_lock_volume");
760 pool_vars[0].data = &pl->pl_server_lock_volume;
761 pool_vars[0].read_fptr = lprocfs_rd_u64;
762 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
764 snprintf(var_name, MAX_STRING_SIZE, "limit");
765 pool_vars[0].data = &pl->pl_limit;
766 pool_vars[0].read_fptr = lprocfs_rd_atomic;
767 pool_vars[0].write_fptr = lprocfs_wr_atomic;
768 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
770 snprintf(var_name, MAX_STRING_SIZE, "granted");
771 pool_vars[0].data = &pl->pl_granted;
772 pool_vars[0].read_fptr = lprocfs_rd_atomic;
773 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
775 snprintf(var_name, MAX_STRING_SIZE, "grant_speed");
776 pool_vars[0].data = pl;
777 pool_vars[0].read_fptr = lprocfs_rd_grant_speed;
778 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
780 snprintf(var_name, MAX_STRING_SIZE, "cancel_rate");
781 pool_vars[0].data = &pl->pl_cancel_rate;
782 pool_vars[0].read_fptr = lprocfs_rd_atomic;
783 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
785 snprintf(var_name, MAX_STRING_SIZE, "grant_rate");
786 pool_vars[0].data = &pl->pl_grant_rate;
787 pool_vars[0].read_fptr = lprocfs_rd_atomic;
788 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
790 snprintf(var_name, MAX_STRING_SIZE, "grant_plan");
791 pool_vars[0].data = pl;
792 pool_vars[0].read_fptr = lprocfs_rd_grant_plan;
793 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
795 snprintf(var_name, MAX_STRING_SIZE, "recalc_period");
796 pool_vars[0].data = pl;
797 pool_vars[0].read_fptr = lprocfs_rd_recalc_period;
798 pool_vars[0].write_fptr = lprocfs_wr_recalc_period;
799 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
801 snprintf(var_name, MAX_STRING_SIZE, "lock_volume_factor");
802 pool_vars[0].data = &pl->pl_lock_volume_factor;
803 pool_vars[0].read_fptr = lprocfs_rd_atomic;
804 pool_vars[0].write_fptr = lprocfs_wr_atomic;
805 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
807 snprintf(var_name, MAX_STRING_SIZE, "state");
808 pool_vars[0].data = pl;
809 pool_vars[0].read_fptr = lprocfs_rd_pool_state;
810 lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
812 pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
813 LDLM_POOL_FIRST_STAT, 0);
815 GOTO(out_free_name, rc = -ENOMEM);
817 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
818 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
820 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_STAT,
821 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
823 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_STAT,
824 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
826 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_RATE_STAT,
827 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
828 "grant_rate", "locks/s");
829 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_RATE_STAT,
830 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
831 "cancel_rate", "locks/s");
832 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_PLAN_STAT,
833 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
834 "grant_plan", "locks/s");
835 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SLV_STAT,
836 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
838 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SHRINK_REQTD_STAT,
839 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
840 "shrink_request", "locks");
841 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SHRINK_FREED_STAT,
842 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
843 "shrink_freed", "locks");
844 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_RECALC_STAT,
845 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
846 "recalc_freed", "locks");
847 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
848 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
849 "recalc_timing", "sec");
850 lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
854 OBD_FREE(var_name, MAX_STRING_SIZE + 1);
858 static void ldlm_pool_proc_fini(struct ldlm_pool *pl)
860 if (pl->pl_stats != NULL) {
861 lprocfs_free_stats(&pl->pl_stats);
864 if (pl->pl_proc_dir != NULL) {
865 lprocfs_remove(&pl->pl_proc_dir);
866 pl->pl_proc_dir = NULL;
869 #else /* !__KERNEL__*/
870 #define ldlm_pool_proc_init(pl) (0)
871 #define ldlm_pool_proc_fini(pl) while (0) {}
874 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
875 int idx, ldlm_side_t client)
880 cfs_spin_lock_init(&pl->pl_lock);
881 cfs_atomic_set(&pl->pl_granted, 0);
882 pl->pl_recalc_time = cfs_time_current_sec();
883 cfs_atomic_set(&pl->pl_lock_volume_factor, 1);
885 cfs_atomic_set(&pl->pl_grant_rate, 0);
886 cfs_atomic_set(&pl->pl_cancel_rate, 0);
887 pl->pl_grant_plan = LDLM_POOL_GP(LDLM_POOL_HOST_L);
889 snprintf(pl->pl_name, sizeof(pl->pl_name), "ldlm-pool-%s-%d",
890 ldlm_ns_name(ns), idx);
892 if (client == LDLM_NAMESPACE_SERVER) {
893 pl->pl_ops = &ldlm_srv_pool_ops;
894 ldlm_pool_set_limit(pl, LDLM_POOL_HOST_L);
895 pl->pl_recalc_period = LDLM_POOL_SRV_DEF_RECALC_PERIOD;
896 pl->pl_server_lock_volume = ldlm_pool_slv_max(LDLM_POOL_HOST_L);
898 ldlm_pool_set_limit(pl, 1);
899 pl->pl_server_lock_volume = 0;
900 pl->pl_ops = &ldlm_cli_pool_ops;
901 pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD;
903 pl->pl_client_lock_volume = 0;
904 rc = ldlm_pool_proc_init(pl);
908 CDEBUG(D_DLMTRACE, "Lock pool %s is initialized\n", pl->pl_name);
912 EXPORT_SYMBOL(ldlm_pool_init);
914 void ldlm_pool_fini(struct ldlm_pool *pl)
917 ldlm_pool_proc_fini(pl);
920 * Pool should not be used after this point. We can't free it here as
921 * it lives in struct ldlm_namespace, but still interested in catching
922 * any abnormal using cases.
924 POISON(pl, 0x5a, sizeof(*pl));
927 EXPORT_SYMBOL(ldlm_pool_fini);
930 * Add new taken ldlm lock \a lock into pool \a pl accounting.
932 void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
935 * FLOCK locks are special in a sense that they are almost never
936 * cancelled, instead special kind of lock is used to drop them.
937 * also there is no LRU for flock locks, so no point in tracking
940 if (lock->l_resource->lr_type == LDLM_FLOCK)
943 cfs_atomic_inc(&pl->pl_granted);
944 cfs_atomic_inc(&pl->pl_grant_rate);
945 lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_GRANT_STAT);
947 * Do not do pool recalc for client side as all locks which
948 * potentially may be canceled has already been packed into
949 * enqueue/cancel rpc. Also we do not want to run out of stack
950 * with too long call paths.
952 if (ns_is_server(ldlm_pl2ns(pl)))
953 ldlm_pool_recalc(pl);
955 EXPORT_SYMBOL(ldlm_pool_add);
958 * Remove ldlm lock \a lock from pool \a pl accounting.
960 void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock)
963 * Filter out FLOCK locks. Read above comment in ldlm_pool_add().
965 if (lock->l_resource->lr_type == LDLM_FLOCK)
968 LASSERT(cfs_atomic_read(&pl->pl_granted) > 0);
969 cfs_atomic_dec(&pl->pl_granted);
970 cfs_atomic_inc(&pl->pl_cancel_rate);
972 lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
974 if (ns_is_server(ldlm_pl2ns(pl)))
975 ldlm_pool_recalc(pl);
977 EXPORT_SYMBOL(ldlm_pool_del);
980 * Returns current \a pl SLV.
982 * \pre ->pl_lock is not locked.
984 __u64 ldlm_pool_get_slv(struct ldlm_pool *pl)
987 cfs_spin_lock(&pl->pl_lock);
988 slv = pl->pl_server_lock_volume;
989 cfs_spin_unlock(&pl->pl_lock);
992 EXPORT_SYMBOL(ldlm_pool_get_slv);
995 * Sets passed \a slv to \a pl.
997 * \pre ->pl_lock is not locked.
999 void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv)
1001 cfs_spin_lock(&pl->pl_lock);
1002 pl->pl_server_lock_volume = slv;
1003 cfs_spin_unlock(&pl->pl_lock);
1005 EXPORT_SYMBOL(ldlm_pool_set_slv);
1008 * Returns current \a pl CLV.
1010 * \pre ->pl_lock is not locked.
1012 __u64 ldlm_pool_get_clv(struct ldlm_pool *pl)
1015 cfs_spin_lock(&pl->pl_lock);
1016 slv = pl->pl_client_lock_volume;
1017 cfs_spin_unlock(&pl->pl_lock);
1020 EXPORT_SYMBOL(ldlm_pool_get_clv);
1023 * Sets passed \a clv to \a pl.
1025 * \pre ->pl_lock is not locked.
1027 void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv)
1029 cfs_spin_lock(&pl->pl_lock);
1030 pl->pl_client_lock_volume = clv;
1031 cfs_spin_unlock(&pl->pl_lock);
1033 EXPORT_SYMBOL(ldlm_pool_set_clv);
1036 * Returns current \a pl limit.
1038 __u32 ldlm_pool_get_limit(struct ldlm_pool *pl)
1040 return cfs_atomic_read(&pl->pl_limit);
1042 EXPORT_SYMBOL(ldlm_pool_get_limit);
1045 * Sets passed \a limit to \a pl.
1047 void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit)
1049 cfs_atomic_set(&pl->pl_limit, limit);
1051 EXPORT_SYMBOL(ldlm_pool_set_limit);
1054 * Returns current LVF from \a pl.
1056 __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
1058 return cfs_atomic_read(&pl->pl_lock_volume_factor);
1060 EXPORT_SYMBOL(ldlm_pool_get_lvf);
1063 static int ldlm_pool_granted(struct ldlm_pool *pl)
1065 return cfs_atomic_read(&pl->pl_granted);
1068 static struct ptlrpc_thread *ldlm_pools_thread;
1069 static struct cfs_shrinker *ldlm_pools_srv_shrinker;
1070 static struct cfs_shrinker *ldlm_pools_cli_shrinker;
1071 static cfs_completion_t ldlm_pools_comp;
1074 * Cancel \a nr locks from all namespaces (if possible). Returns number of
1075 * cached locks after shrink is finished. All namespaces are asked to
1076 * cancel approximately equal amount of locks to keep balancing.
1078 static int ldlm_pools_shrink(ldlm_side_t client, int nr,
1079 unsigned int gfp_mask)
1081 int total = 0, cached = 0, nr_ns;
1082 struct ldlm_namespace *ns;
1085 if (client == LDLM_NAMESPACE_CLIENT && nr != 0 &&
1086 !(gfp_mask & __GFP_FS))
1089 CDEBUG(D_DLMTRACE, "Request to shrink %d %s locks from all pools\n",
1090 nr, client == LDLM_NAMESPACE_CLIENT ? "client" : "server");
1092 cookie = cl_env_reenter();
1095 * Find out how many resources we may release.
1097 for (nr_ns = cfs_atomic_read(ldlm_namespace_nr(client));
1100 cfs_mutex_down(ldlm_namespace_lock(client));
1101 if (cfs_list_empty(ldlm_namespace_list(client))) {
1102 cfs_mutex_up(ldlm_namespace_lock(client));
1103 cl_env_reexit(cookie);
1106 ns = ldlm_namespace_first_locked(client);
1107 ldlm_namespace_get(ns);
1108 ldlm_namespace_move_locked(ns, client);
1109 cfs_mutex_up(ldlm_namespace_lock(client));
1110 total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask);
1111 ldlm_namespace_put(ns);
1114 if (nr == 0 || total == 0) {
1115 cl_env_reexit(cookie);
1120 * Shrink at least ldlm_namespace_nr(client) namespaces.
1122 for (nr_ns = cfs_atomic_read(ldlm_namespace_nr(client));
1125 int cancel, nr_locks;
1128 * Do not call shrink under ldlm_namespace_lock(client)
1130 cfs_mutex_down(ldlm_namespace_lock(client));
1131 if (cfs_list_empty(ldlm_namespace_list(client))) {
1132 cfs_mutex_up(ldlm_namespace_lock(client));
1134 * If list is empty, we can't return any @cached > 0,
1135 * that probably would cause needless shrinker
1141 ns = ldlm_namespace_first_locked(client);
1142 ldlm_namespace_get(ns);
1143 ldlm_namespace_move_locked(ns, client);
1144 cfs_mutex_up(ldlm_namespace_lock(client));
1146 nr_locks = ldlm_pool_granted(&ns->ns_pool);
1147 cancel = 1 + nr_locks * nr / total;
1148 ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask);
1149 cached += ldlm_pool_granted(&ns->ns_pool);
1150 ldlm_namespace_put(ns);
1152 cl_env_reexit(cookie);
1153 /* we only decrease the SLV in server pools shrinker, return -1 to
1154 * kernel to avoid needless loop. LU-1128 */
1155 return (client == LDLM_NAMESPACE_SERVER) ? -1 : cached;
1158 static int ldlm_pools_srv_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask))
1160 return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER,
1161 shrink_param(sc, nr_to_scan),
1162 shrink_param(sc, gfp_mask));
1165 static int ldlm_pools_cli_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask))
1167 return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT,
1168 shrink_param(sc, nr_to_scan),
1169 shrink_param(sc, gfp_mask));
1172 void ldlm_pools_recalc(ldlm_side_t client)
1174 __u32 nr_l = 0, nr_p = 0, l;
1175 struct ldlm_namespace *ns;
1179 * No need to setup pool limit for client pools.
1181 if (client == LDLM_NAMESPACE_SERVER) {
1183 * Check all modest namespaces first.
1185 cfs_mutex_down(ldlm_namespace_lock(client));
1186 cfs_list_for_each_entry(ns, ldlm_namespace_list(client),
1189 if (ns->ns_appetite != LDLM_NAMESPACE_MODEST)
1192 l = ldlm_pool_granted(&ns->ns_pool);
1197 * Set the modest pools limit equal to their avg granted
1200 l += dru(l, LDLM_POOLS_MODEST_MARGIN_SHIFT, 0);
1201 ldlm_pool_setup(&ns->ns_pool, l);
1207 * Make sure that modest namespaces did not eat more that 2/3
1210 if (nr_l >= 2 * (LDLM_POOL_HOST_L / 3)) {
1211 CWARN("\"Modest\" pools eat out 2/3 of server locks "
1212 "limit (%d of %lu). This means that you have too "
1213 "many clients for this amount of server RAM. "
1214 "Upgrade server!\n", nr_l, LDLM_POOL_HOST_L);
1219 * The rest is given to greedy namespaces.
1221 cfs_list_for_each_entry(ns, ldlm_namespace_list(client),
1224 if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY)
1229 * In the case 2/3 locks are eaten out by
1230 * modest pools, we re-setup equal limit
1233 l = LDLM_POOL_HOST_L /
1235 ldlm_namespace_nr(client));
1238 * All the rest of greedy pools will have
1239 * all locks in equal parts.
1241 l = (LDLM_POOL_HOST_L - nr_l) /
1243 ldlm_namespace_nr(client)) -
1246 ldlm_pool_setup(&ns->ns_pool, l);
1248 cfs_mutex_up(ldlm_namespace_lock(client));
1252 * Recalc at least ldlm_namespace_nr(client) namespaces.
1254 for (nr = cfs_atomic_read(ldlm_namespace_nr(client)); nr > 0; nr--) {
1257 * Lock the list, get first @ns in the list, getref, move it
1258 * to the tail, unlock and call pool recalc. This way we avoid
1259 * calling recalc under @ns lock what is really good as we get
1260 * rid of potential deadlock on client nodes when canceling
1261 * locks synchronously.
1263 cfs_mutex_down(ldlm_namespace_lock(client));
1264 if (cfs_list_empty(ldlm_namespace_list(client))) {
1265 cfs_mutex_up(ldlm_namespace_lock(client));
1268 ns = ldlm_namespace_first_locked(client);
1270 cfs_spin_lock(&ns->ns_lock);
1272 * skip ns which is being freed, and we don't want to increase
1273 * its refcount again, not even temporarily. bz21519 & LU-499.
1275 if (ns->ns_stopping) {
1279 ldlm_namespace_get(ns);
1281 cfs_spin_unlock(&ns->ns_lock);
1283 ldlm_namespace_move_locked(ns, client);
1284 cfs_mutex_up(ldlm_namespace_lock(client));
1287 * After setup is done - recalc the pool.
1290 ldlm_pool_recalc(&ns->ns_pool);
1291 ldlm_namespace_put(ns);
1295 EXPORT_SYMBOL(ldlm_pools_recalc);
1297 static int ldlm_pools_thread_main(void *arg)
1299 struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
1300 char *t_name = "ldlm_poold";
1303 cfs_daemonize(t_name);
1304 thread_set_flags(thread, SVC_RUNNING);
1305 cfs_waitq_signal(&thread->t_ctl_waitq);
1307 CDEBUG(D_DLMTRACE, "%s: pool thread starting, process %d\n",
1308 t_name, cfs_curproc_pid());
1311 struct l_wait_info lwi;
1314 * Recal all pools on this tick.
1316 ldlm_pools_recalc(LDLM_NAMESPACE_SERVER);
1317 ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
1320 * Wait until the next check time, or until we're
1323 lwi = LWI_TIMEOUT(cfs_time_seconds(LDLM_POOLS_THREAD_PERIOD),
1325 l_wait_event(thread->t_ctl_waitq,
1326 thread_is_stopping(thread) ||
1327 thread_is_event(thread),
1330 if (thread_test_and_clear_flags(thread, SVC_STOPPING))
1333 thread_test_and_clear_flags(thread, SVC_EVENT);
1336 thread_set_flags(thread, SVC_STOPPED);
1337 cfs_waitq_signal(&thread->t_ctl_waitq);
1339 CDEBUG(D_DLMTRACE, "%s: pool thread exiting, process %d\n",
1340 t_name, cfs_curproc_pid());
1342 cfs_complete_and_exit(&ldlm_pools_comp, 0);
1345 static int ldlm_pools_thread_start(void)
1347 struct l_wait_info lwi = { 0 };
1351 if (ldlm_pools_thread != NULL)
1354 OBD_ALLOC_PTR(ldlm_pools_thread);
1355 if (ldlm_pools_thread == NULL)
1358 cfs_init_completion(&ldlm_pools_comp);
1359 cfs_waitq_init(&ldlm_pools_thread->t_ctl_waitq);
1362 * CLONE_VM and CLONE_FILES just avoid a needless copy, because we
1363 * just drop the VM and FILES in cfs_daemonize() right away.
1365 rc = cfs_create_thread(ldlm_pools_thread_main, ldlm_pools_thread,
1368 CERROR("Can't start pool thread, error %d\n",
1370 OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread));
1371 ldlm_pools_thread = NULL;
1374 l_wait_event(ldlm_pools_thread->t_ctl_waitq,
1375 thread_is_running(ldlm_pools_thread), &lwi);
1379 static void ldlm_pools_thread_stop(void)
1383 if (ldlm_pools_thread == NULL) {
1388 thread_set_flags(ldlm_pools_thread, SVC_STOPPING);
1389 cfs_waitq_signal(&ldlm_pools_thread->t_ctl_waitq);
1392 * Make sure that pools thread is finished before freeing @thread.
1393 * This fixes possible race and oops due to accessing freed memory
1396 cfs_wait_for_completion(&ldlm_pools_comp);
1397 OBD_FREE_PTR(ldlm_pools_thread);
1398 ldlm_pools_thread = NULL;
1402 int ldlm_pools_init(void)
1407 rc = ldlm_pools_thread_start();
1409 ldlm_pools_srv_shrinker =
1410 cfs_set_shrinker(CFS_DEFAULT_SEEKS,
1411 ldlm_pools_srv_shrink);
1412 ldlm_pools_cli_shrinker =
1413 cfs_set_shrinker(CFS_DEFAULT_SEEKS,
1414 ldlm_pools_cli_shrink);
1418 EXPORT_SYMBOL(ldlm_pools_init);
1420 void ldlm_pools_fini(void)
1422 if (ldlm_pools_srv_shrinker != NULL) {
1423 cfs_remove_shrinker(ldlm_pools_srv_shrinker);
1424 ldlm_pools_srv_shrinker = NULL;
1426 if (ldlm_pools_cli_shrinker != NULL) {
1427 cfs_remove_shrinker(ldlm_pools_cli_shrinker);
1428 ldlm_pools_cli_shrinker = NULL;
1430 ldlm_pools_thread_stop();
1432 EXPORT_SYMBOL(ldlm_pools_fini);
1433 #endif /* __KERNEL__ */
1435 #else /* !HAVE_LRU_RESIZE_SUPPORT */
1436 int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
1440 EXPORT_SYMBOL(ldlm_pool_setup);
1442 int ldlm_pool_recalc(struct ldlm_pool *pl)
1446 EXPORT_SYMBOL(ldlm_pool_recalc);
1448 int ldlm_pool_shrink(struct ldlm_pool *pl,
1449 int nr, unsigned int gfp_mask)
1453 EXPORT_SYMBOL(ldlm_pool_shrink);
1455 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
1456 int idx, ldlm_side_t client)
1460 EXPORT_SYMBOL(ldlm_pool_init);
1462 void ldlm_pool_fini(struct ldlm_pool *pl)
1466 EXPORT_SYMBOL(ldlm_pool_fini);
1468 void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
1472 EXPORT_SYMBOL(ldlm_pool_add);
1474 void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock)
1478 EXPORT_SYMBOL(ldlm_pool_del);
1480 __u64 ldlm_pool_get_slv(struct ldlm_pool *pl)
1484 EXPORT_SYMBOL(ldlm_pool_get_slv);
1486 void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv)
1490 EXPORT_SYMBOL(ldlm_pool_set_slv);
1492 __u64 ldlm_pool_get_clv(struct ldlm_pool *pl)
1496 EXPORT_SYMBOL(ldlm_pool_get_clv);
1498 void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv)
1502 EXPORT_SYMBOL(ldlm_pool_set_clv);
1504 __u32 ldlm_pool_get_limit(struct ldlm_pool *pl)
1508 EXPORT_SYMBOL(ldlm_pool_get_limit);
1510 void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit)
1514 EXPORT_SYMBOL(ldlm_pool_set_limit);
1516 __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
1520 EXPORT_SYMBOL(ldlm_pool_get_lvf);
1522 int ldlm_pools_init(void)
1526 EXPORT_SYMBOL(ldlm_pools_init);
1528 void ldlm_pools_fini(void)
1532 EXPORT_SYMBOL(ldlm_pools_fini);
1534 void ldlm_pools_recalc(ldlm_side_t client)
1538 EXPORT_SYMBOL(ldlm_pools_recalc);
1539 #endif /* HAVE_LRU_RESIZE_SUPPORT */