Whamcloud - gitweb
LU-1302 llog: pass lu_env as parametr in llog functions
[fs/lustre-release.git] / lustre / ptlrpc / sec_gc.c
index 4a3585b..a1649d2 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -38,9 +38,6 @@
  * Author: Eric Mei <ericm@clusterfs.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_SEC
 
 #ifndef __KERNEL__
@@ -119,7 +116,7 @@ void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx)
         cfs_list_add(&ctx->cc_gc_chain, &sec_gc_ctx_list);
         cfs_spin_unlock(&sec_gc_ctx_list_lock);
 
-        sec_gc_thread.t_flags |= SVC_SIGNAL;
+        thread_add_flags(&sec_gc_thread, SVC_SIGNAL);
         cfs_waitq_signal(&sec_gc_thread.t_ctl_waitq);
 }
 EXPORT_SYMBOL(sptlrpc_gc_add_ctx);
@@ -153,7 +150,7 @@ static void sec_do_gc(struct ptlrpc_sec *sec)
         LASSERT(sec->ps_policy->sp_cops->gc_ctx);
 
         if (unlikely(sec->ps_gc_next == 0)) {
-                CWARN("sec %p(%s) has 0 gc time\n",
+                CDEBUG(D_SEC, "sec %p(%s) has 0 gc time\n",
                       sec, sec->ps_policy->sp_name);
                 return;
         }
@@ -175,13 +172,13 @@ static int sec_gc_main(void *arg)
         cfs_daemonize_ctxt("sptlrpc_gc");
 
         /* Record that the thread is running */
-        thread->t_flags = SVC_RUNNING;
+        thread_set_flags(thread, SVC_RUNNING);
         cfs_waitq_signal(&thread->t_ctl_waitq);
 
         while (1) {
                 struct ptlrpc_sec *sec;
 
-                thread->t_flags &= ~SVC_SIGNAL;
+                thread_clear_flags(thread, SVC_SIGNAL);
                 sec_process_ctx_list();
 again:
                 /* go through sec list do gc.
@@ -195,7 +192,7 @@ again:
                         /* if someone is waiting to be deleted, let it
                          * proceed as soon as possible. */
                         if (cfs_atomic_read(&sec_gc_wait_del)) {
-                                CWARN("deletion pending, start over\n");
+                                CDEBUG(D_SEC, "deletion pending, start over\n");
                                 cfs_mutex_unlock(&sec_gc_mutex);
                                 goto again;
                         }
@@ -209,16 +206,15 @@ again:
 
                 lwi = LWI_TIMEOUT(SEC_GC_INTERVAL * CFS_HZ, NULL, NULL);
                 l_wait_event(thread->t_ctl_waitq,
-                             thread->t_flags & (SVC_STOPPING | SVC_SIGNAL),
+                             thread_is_stopping(thread) ||
+                             thread_is_signal(thread),
                              &lwi);
 
-                if (thread->t_flags & SVC_STOPPING) {
-                        thread->t_flags &= ~SVC_STOPPING;
+                if (thread_test_and_clear_flags(thread, SVC_STOPPING))
                         break;
-                }
         }
 
-        thread->t_flags = SVC_STOPPED;
+        thread_set_flags(thread, SVC_STOPPED);
         cfs_waitq_signal(&thread->t_ctl_waitq);
         return 0;
 }
@@ -236,15 +232,14 @@ int sptlrpc_gc_init(void)
         memset(&sec_gc_thread, 0, sizeof(sec_gc_thread));
         cfs_waitq_init(&sec_gc_thread.t_ctl_waitq);
 
-        rc = cfs_kernel_thread(sec_gc_main, &sec_gc_thread,
-                               CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(sec_gc_main, &sec_gc_thread, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("can't start gc thread: %d\n", rc);
                 return rc;
         }
 
         l_wait_event(sec_gc_thread.t_ctl_waitq,
-                     sec_gc_thread.t_flags & SVC_RUNNING, &lwi);
+                     thread_is_running(&sec_gc_thread), &lwi);
         return 0;
 }
 
@@ -252,11 +247,11 @@ void sptlrpc_gc_fini(void)
 {
         struct l_wait_info lwi = { 0 };
 
-        sec_gc_thread.t_flags = SVC_STOPPING;
+        thread_set_flags(&sec_gc_thread, SVC_STOPPING);
         cfs_waitq_signal(&sec_gc_thread.t_ctl_waitq);
 
         l_wait_event(sec_gc_thread.t_ctl_waitq,
-                     sec_gc_thread.t_flags & SVC_STOPPED, &lwi);
+                     thread_is_stopped(&sec_gc_thread), &lwi);
 }
 
 #else /* !__KERNEL__ */