* 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.
*/
/*
/*
* in-pool pages bookkeeping
*/
- spinlock_t epp_lock; /* protect following fields */
+ cfs_spinlock_t epp_lock; /* protect following fields */
unsigned long epp_total_pages; /* total pages in pools */
unsigned long epp_free_pages; /* current pages available */
/*
* memory shrinker
*/
-const int pools_shrinker_seeks = DEFAULT_SEEKS;
-static struct shrinker *pools_shrinker = NULL;
+const int pools_shrinker_seeks = CFS_DEFAULT_SEEKS;
+static struct cfs_shrinker *pools_shrinker = NULL;
/*
{
int rc;
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
rc = snprintf(page, count,
"physical pages: %lu\n"
"max waitqueue depth: %u\n"
"max wait time: "CFS_TIME_T"/%u\n"
,
- num_physpages,
+ cfs_num_physpages,
PAGES_PER_POOL,
page_pools.epp_max_pages,
page_pools.epp_max_pools,
page_pools.epp_st_missings,
page_pools.epp_st_lowfree,
page_pools.epp_st_max_wqlen,
- page_pools.epp_st_max_wait, HZ
+ page_pools.epp_st_max_wait, CFS_HZ
);
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
return rc;
}
static int enc_pools_shrink(int nr_to_scan, unsigned int gfp_mask)
{
if (unlikely(nr_to_scan != 0)) {
- spin_lock(&page_pools.epp_lock);
+ 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) {
page_pools.epp_st_shrinks++;
page_pools.epp_last_shrink = cfs_time_current_sec();
}
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
}
/*
*/
if (unlikely(cfs_time_current_sec() - page_pools.epp_last_access >
CACHE_QUIESCENT_PERIOD)) {
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
page_pools.epp_idle_idx = IDLE_IDX_MAX;
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
}
LASSERT(page_pools.epp_idle_idx <= IDLE_IDX_MAX);
LASSERT(npages_to_npools(npages) == npools);
LASSERT(page_pools.epp_growing);
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
/*
* (1) fill all the free slots of current pools.
CDEBUG(D_SEC, "add %d pages to total %lu\n", npages,
page_pools.epp_total_pages);
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
}
static int enc_pools_add_pages(int npages)
{
- static DECLARE_MUTEX(sem_add_pages);
+ static CFS_DECLARE_MUTEX(sem_add_pages);
cfs_page_t ***pools;
int npools, alloced = 0;
int i, j, rc = -ENOMEM;
if (npages < PTLRPC_MAX_BRW_PAGES)
npages = PTLRPC_MAX_BRW_PAGES;
- down(&sem_add_pages);
+ cfs_down(&sem_add_pages);
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);
}
- up(&sem_add_pages);
+ cfs_up(&sem_add_pages);
return rc;
}
if (desc->bd_enc_iov == NULL)
return -ENOMEM;
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
page_pools.epp_st_access++;
again:
if (enc_pools_should_grow(desc->bd_iov_count, now)) {
page_pools.epp_growing = 1;
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
enc_pools_add_pages(page_pools.epp_pages_short / 2);
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
page_pools.epp_growing = 0;
page_pools.epp_st_max_wqlen =
page_pools.epp_waitqlen;
- set_current_state(CFS_TASK_UNINT);
+ cfs_set_current_state(CFS_TASK_UNINT);
cfs_waitlink_init(&waitlink);
cfs_waitq_add(&page_pools.epp_waitq, &waitlink);
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
cfs_waitq_wait(&waitlink, CFS_TASK_UNINT);
cfs_waitq_del(&page_pools.epp_waitq, &waitlink);
LASSERT(page_pools.epp_waitqlen > 0);
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
page_pools.epp_waitqlen--;
}
page_pools.epp_last_access = cfs_time_current_sec();
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
return 0;
}
EXPORT_SYMBOL(sptlrpc_enc_pool_get_pages);
LASSERT(desc->bd_iov_count > 0);
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
p_idx = page_pools.epp_free_pages / PAGES_PER_POOL;
g_idx = page_pools.epp_free_pages % PAGES_PER_POOL;
enc_pools_wakeup();
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
OBD_FREE(desc->bd_enc_iov,
desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
{
int need_grow = 0;
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
if (page_pools.epp_growing == 0 && page_pools.epp_total_pages == 0) {
page_pools.epp_growing = 1;
need_grow = 1;
}
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
if (need_grow) {
enc_pools_add_pages(PTLRPC_MAX_BRW_PAGES +
PTLRPC_MAX_BRW_PAGES);
- spin_lock(&page_pools.epp_lock);
+ cfs_spin_lock(&page_pools.epp_lock);
page_pools.epp_growing = 0;
enc_pools_wakeup();
- spin_unlock(&page_pools.epp_lock);
+ cfs_spin_unlock(&page_pools.epp_lock);
}
return 0;
}
* maximum capacity is 1/8 of total physical memory.
* is the 1/8 a good number?
*/
- page_pools.epp_max_pages = num_physpages / 8;
+ page_pools.epp_max_pages = cfs_num_physpages / 8;
page_pools.epp_max_pools = npages_to_npools(page_pools.epp_max_pages);
cfs_waitq_init(&page_pools.epp_waitq);
page_pools.epp_last_shrink = cfs_time_current_sec();
page_pools.epp_last_access = cfs_time_current_sec();
- spin_lock_init(&page_pools.epp_lock);
+ cfs_spin_lock_init(&page_pools.epp_lock);
page_pools.epp_total_pages = 0;
page_pools.epp_free_pages = 0;
if (page_pools.epp_pools == NULL)
return -ENOMEM;
- pools_shrinker = set_shrinker(pools_shrinker_seeks, enc_pools_shrink);
+ pools_shrinker = cfs_set_shrinker(pools_shrinker_seeks,
+ enc_pools_shrink);
if (pools_shrinker == NULL) {
enc_pools_free();
return -ENOMEM;
LASSERT(page_pools.epp_pools);
LASSERT(page_pools.epp_total_pages == page_pools.epp_free_pages);
- remove_shrinker(pools_shrinker);
+ cfs_remove_shrinker(pools_shrinker);
npools = npages_to_npools(page_pools.epp_total_pages);
cleaned = enc_pools_cleanup(page_pools.epp_pools, npools);
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, HZ);
+ page_pools.epp_st_max_wait, CFS_HZ);
}
}
hashsize = ll_crypto_hash_digestsize(hdesc.tfm);
for (i = 0; i < desc->bd_iov_count; i++) {
- sl.page = desc->bd_iov[i].kiov_page;
- sl.offset = desc->bd_iov[i].kiov_offset;
- sl.length = desc->bd_iov[i].kiov_len;
+ sg_set_page(&sl, desc->bd_iov[i].kiov_page,
+ desc->bd_iov[i].kiov_len,
+ desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK);
ll_crypto_hash_update(&hdesc, &sl, sl.length);
}