* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2016, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_SEC
-#include <libcfs/libcfs.h>
+#include <libcfs/linux/linux-mem.h>
#include <obd.h>
#include <obd_cksum.h>
unsigned long epp_st_missings; /* # of cache missing */
unsigned long epp_st_lowfree; /* lowest free pages reached */
unsigned int epp_st_max_wqlen; /* highest waitqueue length */
- cfs_time_t epp_st_max_wait; /* in jeffies */
+ ktime_t epp_st_max_wait; /* in nanoseconds */
unsigned long epp_st_outofmem; /* # of out of mem requests */
/*
* pointers to pools, may be vmalloc'd
"total pages: %lu\n"
"total free: %lu\n"
"idle index: %lu/100\n"
- "last shrink: %lds\n"
- "last access: %lds\n"
+ "last shrink: %llds\n"
+ "last access: %llds\n"
"max pages reached: %lu\n"
"grows: %u\n"
"grows failure: %u\n"
"cache missing: %lu\n"
"low free mark: %lu\n"
"max waitqueue depth: %u\n"
- "max wait time: %ld/%lu\n"
+ "max wait time ms: %lld\n"
"out of mem: %lu\n",
totalram_pages, PAGES_PER_POOL,
page_pools.epp_max_pages,
page_pools.epp_total_pages,
page_pools.epp_free_pages,
page_pools.epp_idle_idx,
- (long)(ktime_get_seconds() - page_pools.epp_last_shrink),
- (long)(ktime_get_seconds() - page_pools.epp_last_access),
+ ktime_get_seconds() - page_pools.epp_last_shrink,
+ ktime_get_seconds() - page_pools.epp_last_access,
page_pools.epp_st_max_pages,
page_pools.epp_st_grows,
page_pools.epp_st_grow_fails,
page_pools.epp_st_missings,
page_pools.epp_st_lowfree,
page_pools.epp_st_max_wqlen,
- page_pools.epp_st_max_wait,
- msecs_to_jiffies(MSEC_PER_SEC),
+ ktime_to_ms(page_pools.epp_st_max_wait),
page_pools.epp_st_outofmem);
spin_unlock(&page_pools.epp_lock);
* if no pool access for a long time, we consider it's fully idle.
* a little race here is fine.
*/
- if (unlikely(ktime_get_real_seconds() - page_pools.epp_last_access >
+ if (unlikely(ktime_get_seconds() - page_pools.epp_last_access >
CACHE_QUIESCENT_PERIOD)) {
spin_lock(&page_pools.epp_lock);
page_pools.epp_idle_idx = IDLE_IDX_MAX;
(long)sc->nr_to_scan, page_pools.epp_free_pages);
page_pools.epp_st_shrinks++;
- page_pools.epp_last_shrink = ktime_get_real_seconds();
+ page_pools.epp_last_shrink = ktime_get_seconds();
}
spin_unlock(&page_pools.epp_lock);
* if no pool access for a long time, we consider it's fully idle.
* a little race here is fine.
*/
- if (unlikely(ktime_get_real_seconds() - page_pools.epp_last_access >
+ if (unlikely(ktime_get_seconds() - page_pools.epp_last_access >
CACHE_QUIESCENT_PERIOD)) {
spin_lock(&page_pools.epp_lock);
page_pools.epp_idle_idx = IDLE_IDX_MAX;
*/
int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc)
{
- wait_queue_t waitlink;
- unsigned long this_idle = -1;
- cfs_time_t tick = 0;
- long now;
- int p_idx, g_idx;
- int i;
+ wait_queue_entry_t waitlink;
+ unsigned long this_idle = -1;
+ u64 tick_ns = 0;
+ time64_t now;
+ int p_idx, g_idx;
+ int i;
LASSERT(ptlrpc_is_bulk_desc_kiov(desc->bd_type));
LASSERT(desc->bd_iov_count > 0);
page_pools.epp_st_access++;
again:
if (unlikely(page_pools.epp_free_pages < desc->bd_iov_count)) {
- if (tick == 0)
- tick = cfs_time_current();
+ if (tick_ns == 0)
+ tick_ns = ktime_get_ns();
now = ktime_get_real_seconds();
goto again;
}
- /* record max wait time */
- if (unlikely(tick != 0)) {
- tick = cfs_time_current() - tick;
- if (tick > page_pools.epp_st_max_wait)
- page_pools.epp_st_max_wait = tick;
- }
+ /* record max wait time */
+ if (unlikely(tick_ns)) {
+ ktime_t tick = ktime_sub_ns(ktime_get(), tick_ns);
+
+ if (ktime_after(tick, page_pools.epp_st_max_wait))
+ page_pools.epp_st_max_wait = tick;
+ }
/* proceed with rest of allocation */
page_pools.epp_free_pages -= desc->bd_iov_count;
this_idle) /
(IDLE_IDX_WEIGHT + 1);
- page_pools.epp_last_access = ktime_get_real_seconds();
+ page_pools.epp_last_access = ktime_get_seconds();
spin_unlock(&page_pools.epp_lock);
return 0;
page_pools.epp_growing = 0;
page_pools.epp_idle_idx = 0;
- page_pools.epp_last_shrink = ktime_get_real_seconds();
- page_pools.epp_last_access = ktime_get_real_seconds();
+ page_pools.epp_last_shrink = ktime_get_seconds();
+ page_pools.epp_last_access = ktime_get_seconds();
spin_lock_init(&page_pools.epp_lock);
page_pools.epp_total_pages = 0;
page_pools.epp_st_missings = 0;
page_pools.epp_st_lowfree = 0;
page_pools.epp_st_max_wqlen = 0;
- page_pools.epp_st_max_wait = 0;
+ page_pools.epp_st_max_wait = ktime_set(0, 0);
page_pools.epp_st_outofmem = 0;
enc_pools_alloc();
if (page_pools.epp_st_access > 0) {
CDEBUG(D_SEC,
- "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait %ld/%lu, out of mem %lu\n",
+ "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait ms %lld, out of mem %lu\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,
- msecs_to_jiffies(MSEC_PER_SEC),
+ ktime_to_ms(page_pools.epp_st_max_wait),
page_pools.epp_st_outofmem);
}
}
int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
void *buf, int buflen)
{
- struct cfs_crypto_hash_desc *hdesc;
+ struct ahash_request *req;
int hashsize;
unsigned int bufsize;
int i, err;
LASSERT(alg > BULK_HASH_ALG_NULL && alg < BULK_HASH_ALG_MAX);
LASSERT(buflen >= 4);
- hdesc = cfs_crypto_hash_init(cfs_hash_alg_id[alg], NULL, 0);
- if (IS_ERR(hdesc)) {
+ req = cfs_crypto_hash_init(cfs_hash_alg_id[alg], NULL, 0);
+ if (IS_ERR(req)) {
CERROR("Unable to initialize checksum hash %s\n",
cfs_crypto_hash_name(cfs_hash_alg_id[alg]));
- return PTR_ERR(hdesc);
+ return PTR_ERR(req);
}
hashsize = cfs_crypto_hash_digestsize(cfs_hash_alg_id[alg]);
for (i = 0; i < desc->bd_iov_count; i++) {
- cfs_crypto_hash_update_page(hdesc,
+ cfs_crypto_hash_update_page(req,
BD_GET_KIOV(desc, i).kiov_page,
BD_GET_KIOV(desc, i).kiov_offset &
~PAGE_MASK,
bufsize = sizeof(hashbuf);
LASSERTF(bufsize >= hashsize, "bufsize = %u < hashsize %u\n",
bufsize, hashsize);
- err = cfs_crypto_hash_final(hdesc, hashbuf, &bufsize);
+ err = cfs_crypto_hash_final(req, hashbuf, &bufsize);
memcpy(buf, hashbuf, buflen);
} else {
bufsize = buflen;
- err = cfs_crypto_hash_final(hdesc, buf, &bufsize);
+ err = cfs_crypto_hash_final(req, buf, &bufsize);
}
return err;