X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fptlrpc%2Fsec_gc.c;h=a7f3b7946766cce77dd6b8517cd45e26e024d9b6;hp=d5a028058191fe50c55df4aecb96174145e6846f;hb=f6995cf04407dff15d6ca79ca44cfa97dc6eb014;hpb=294e507d34de0d7990ec507334f71ff1d1a7db01 diff --git a/lustre/ptlrpc/sec_gc.c b/lustre/ptlrpc/sec_gc.c index d5a0280..a7f3b79 100644 --- a/lustre/ptlrpc/sec_gc.c +++ b/lustre/ptlrpc/sec_gc.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -40,27 +40,25 @@ #define DEBUG_SUBSYSTEM S_SEC -#ifndef __KERNEL__ -#include -#else +#include #include -#endif #include #include #include #include +#include "ptlrpc_internal.h" + #define SEC_GC_INTERVAL (30 * 60) -#ifdef __KERNEL__ static struct mutex sec_gc_mutex; -static CFS_LIST_HEAD(sec_gc_list); static spinlock_t sec_gc_list_lock; +static struct list_head sec_gc_list; -static CFS_LIST_HEAD(sec_gc_ctx_list); static spinlock_t sec_gc_ctx_list_lock; +static struct list_head sec_gc_ctx_list; static struct ptlrpc_thread sec_gc_thread; static atomic_t sec_gc_wait_del = ATOMIC_INIT(0); @@ -70,21 +68,20 @@ void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) { LASSERT(sec->ps_policy->sp_cops->gc_ctx); LASSERT(sec->ps_gc_interval > 0); - LASSERT(cfs_list_empty(&sec->ps_gc_list)); + LASSERT(list_empty(&sec->ps_gc_list)); sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; spin_lock(&sec_gc_list_lock); - cfs_list_add_tail(&sec_gc_list, &sec->ps_gc_list); + list_add_tail(&sec_gc_list, &sec->ps_gc_list); spin_unlock(&sec_gc_list_lock); CDEBUG(D_SEC, "added sec %p(%s)\n", sec, sec->ps_policy->sp_name); } -EXPORT_SYMBOL(sptlrpc_gc_add_sec); void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec) { - if (cfs_list_empty(&sec->ps_gc_list)) + if (list_empty(&sec->ps_gc_list)) return; might_sleep(); @@ -93,7 +90,7 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec) atomic_inc(&sec_gc_wait_del); spin_lock(&sec_gc_list_lock); - cfs_list_del_init(&sec->ps_gc_list); + list_del_init(&sec->ps_gc_list); spin_unlock(&sec_gc_list_lock); /* barrier */ @@ -104,16 +101,15 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec) CDEBUG(D_SEC, "del sec %p(%s)\n", sec, sec->ps_policy->sp_name); } -EXPORT_SYMBOL(sptlrpc_gc_del_sec); void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx) { - LASSERT(cfs_list_empty(&ctx->cc_gc_chain)); + LASSERT(list_empty(&ctx->cc_gc_chain)); CDEBUG(D_SEC, "hand over ctx %p(%u->%s)\n", ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); spin_lock(&sec_gc_ctx_list_lock); - cfs_list_add(&ctx->cc_gc_chain, &sec_gc_ctx_list); + list_add(&ctx->cc_gc_chain, &sec_gc_ctx_list); spin_unlock(&sec_gc_ctx_list_lock); thread_add_flags(&sec_gc_thread, SVC_SIGNAL); @@ -127,10 +123,10 @@ static void sec_process_ctx_list(void) spin_lock(&sec_gc_ctx_list_lock); - while (!cfs_list_empty(&sec_gc_ctx_list)) { - ctx = cfs_list_entry(sec_gc_ctx_list.next, + while (!list_empty(&sec_gc_ctx_list)) { + ctx = list_entry(sec_gc_ctx_list.next, struct ptlrpc_cli_ctx, cc_gc_chain); - cfs_list_del_init(&ctx->cc_gc_chain); + list_del_init(&ctx->cc_gc_chain); spin_unlock(&sec_gc_ctx_list_lock); LASSERT(ctx->cc_sec); @@ -188,7 +184,7 @@ again: * another issue here is we wakeup as fixed interval instead of * according to each sec's expiry time */ mutex_lock(&sec_gc_mutex); - cfs_list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { + list_for_each_entry(sec, &sec_gc_list, ps_gc_list) { /* if someone is waiting to be deleted, let it * proceed as soon as possible. */ if (atomic_read(&sec_gc_wait_del)) { @@ -204,7 +200,9 @@ again: /* check ctx list again before sleep */ sec_process_ctx_list(); - lwi = LWI_TIMEOUT(SEC_GC_INTERVAL * HZ, NULL, NULL); + lwi = LWI_TIMEOUT(msecs_to_jiffies(SEC_GC_INTERVAL * + MSEC_PER_SEC), + NULL, NULL); l_wait_event(thread->t_ctl_waitq, thread_is_stopping(thread) || thread_is_signal(thread), @@ -228,6 +226,9 @@ int sptlrpc_gc_init(void) spin_lock_init(&sec_gc_list_lock); spin_lock_init(&sec_gc_ctx_list_lock); + INIT_LIST_HEAD(&sec_gc_list); + INIT_LIST_HEAD(&sec_gc_ctx_list); + /* initialize thread control */ memset(&sec_gc_thread, 0, sizeof(sec_gc_thread)); init_waitqueue_head(&sec_gc_thread.t_ctl_waitq); @@ -253,21 +254,3 @@ void sptlrpc_gc_fini(void) l_wait_event(sec_gc_thread.t_ctl_waitq, thread_is_stopped(&sec_gc_thread), &lwi); } - -#else /* !__KERNEL__ */ - -void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) -{ -} -void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec) -{ -} -int sptlrpc_gc_init(void) -{ - return 0; -} -void sptlrpc_gc_fini(void) -{ -} - -#endif /* __KERNEL__ */