* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* could be called frequently for query (@nr_to_scan == 0).
* we try to keep at least PTLRPC_MAX_BRW_PAGES pages in the pool.
*/
-static int enc_pools_shrink(int nr_to_scan, unsigned int gfp_mask)
+static int enc_pools_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask))
{
- if (unlikely(nr_to_scan != 0)) {
+ if (unlikely(shrink_param(sc, nr_to_scan) != 0)) {
cfs_spin_lock(&page_pools.epp_lock);
- nr_to_scan = min(nr_to_scan, (int) page_pools.epp_free_pages -
- PTLRPC_MAX_BRW_PAGES);
- if (nr_to_scan > 0) {
- enc_pools_release_free_pages(nr_to_scan);
- CDEBUG(D_SEC, "released %d pages, %ld left\n",
- nr_to_scan, page_pools.epp_free_pages);
+ shrink_param(sc, nr_to_scan) = min_t(unsigned long,
+ shrink_param(sc, nr_to_scan),
+ page_pools.epp_free_pages -
+ PTLRPC_MAX_BRW_PAGES);
+ if (shrink_param(sc, nr_to_scan) > 0) {
+ enc_pools_release_free_pages(shrink_param(sc,
+ nr_to_scan));
+ CDEBUG(D_SEC, "released %ld pages, %ld left\n",
+ (long)shrink_param(sc, nr_to_scan),
+ page_pools.epp_free_pages);
page_pools.epp_st_shrinks++;
page_pools.epp_last_shrink = cfs_time_current_sec();
static int enc_pools_add_pages(int npages)
{
- static CFS_DECLARE_MUTEX(sem_add_pages);
+ static CFS_DEFINE_MUTEX(add_pages_mutex);
cfs_page_t ***pools;
int npools, alloced = 0;
int i, j, rc = -ENOMEM;
if (npages < PTLRPC_MAX_BRW_PAGES)
npages = PTLRPC_MAX_BRW_PAGES;
- cfs_down(&sem_add_pages);
+ cfs_mutex_lock(&add_pages_mutex);
if (npages + page_pools.epp_total_pages > page_pools.epp_max_pages)
npages = page_pools.epp_max_pages - page_pools.epp_total_pages;
CERROR("Failed to allocate %d enc pages\n", npages);
}
- cfs_up(&sem_add_pages);
+ cfs_mutex_unlock(&add_pages_mutex);
return rc;
}
static inline void enc_pools_alloc(void)
{
LASSERT(page_pools.epp_max_pools);
- /*
- * on system with huge memory but small page size, this might lead to
- * high-order allocation. but it's not common, and we suppose memory
- * be not too much fragmented at module loading time.
- */
- OBD_ALLOC(page_pools.epp_pools,
- page_pools.epp_max_pools * sizeof(*page_pools.epp_pools));
+ OBD_ALLOC_LARGE(page_pools.epp_pools,
+ page_pools.epp_max_pools *
+ sizeof(*page_pools.epp_pools));
}
static inline void enc_pools_free(void)
LASSERT(page_pools.epp_max_pools);
LASSERT(page_pools.epp_pools);
- OBD_FREE(page_pools.epp_pools,
- page_pools.epp_max_pools * sizeof(*page_pools.epp_pools));
+ OBD_FREE_LARGE(page_pools.epp_pools,
+ page_pools.epp_max_pools *
+ sizeof(*page_pools.epp_pools));
}
int sptlrpc_enc_pool_init(void)
enc_pools_free();
if (page_pools.epp_st_access > 0) {
- CWARN("max pages %lu, grows %u, grow fails %u, shrinks %u, "
- "access %lu, missing %lu, max qlen %u, max wait "
- CFS_TIME_T"/%d\n",
- page_pools.epp_st_max_pages, page_pools.epp_st_grows,
- page_pools.epp_st_grow_fails,
- page_pools.epp_st_shrinks, page_pools.epp_st_access,
- page_pools.epp_st_missings, page_pools.epp_st_max_wqlen,
- page_pools.epp_st_max_wait, CFS_HZ);
+ CDEBUG(D_SEC,
+ "max pages %lu, grows %u, grow fails %u, shrinks %u, "
+ "access %lu, missing %lu, max qlen %u, max wait "
+ CFS_TIME_T"/%d\n",
+ page_pools.epp_st_max_pages, page_pools.epp_st_grows,
+ page_pools.epp_st_grow_fails,
+ page_pools.epp_st_shrinks, page_pools.epp_st_access,
+ page_pools.epp_st_missings, page_pools.epp_st_max_wqlen,
+ page_pools.epp_st_max_wait, CFS_HZ);
}
}