Whamcloud - gitweb
LU-502 don't allow to kill service threads by OOM killer.
authorAlexey Lyashkov <alexey_lyashkov@xyratex.com>
Wed, 13 Jul 2011 03:16:12 +0000 (07:16 +0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 26 Jul 2011 17:04:07 +0000 (13:04 -0400)
OOM can produce a many issues like requests processing counter.

Change-Id: I8d417d148b589ea6de84c5d16bc2607a59852564
Signed-off-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Reviewed-on: http://review.whamcloud.com/1088
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
49 files changed:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/darwin/darwin-prim.h
libcfs/include/libcfs/linux/linux-prim.h
libcfs/include/libcfs/user-prim.h
libcfs/include/libcfs/winnt/winnt-prim.h
libcfs/libcfs/darwin/darwin-prim.c
libcfs/libcfs/darwin/darwin-utils.c
libcfs/libcfs/debug.c
libcfs/libcfs/linux/linux-lwt.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/user-prim.c
libcfs/libcfs/watchdog.c
libcfs/libcfs/winnt/winnt-prim.c
libcfs/libcfs/winnt/winnt-tcpip.c
libcfs/libcfs/workitem.c
lnet/klnds/mxlnd/mxlnd.c
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/ptllnd/ptllnd_cb.c
lnet/klnds/ptllnd/ptllnd_ptltrace.c
lnet/klnds/qswlnd/qswlnd_cb.c
lnet/klnds/ralnd/ralnd_cb.c
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/acceptor.c
lnet/lnet/module.c
lnet/lnet/router.c
lnet/selftest/timer.c
lnet/ulnds/socklnd/usocklnd.c
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_pool.c
lustre/llite/llite_capa.c
lustre/llite/llite_close.c
lustre/llite/lloop.c
lustre/llite/statahead.c
lustre/mdc/mdc_request.c
lustre/mds/mds_lov.c
lustre/mdt/mdt_capa.c
lustre/mgc/mgc_request.c
lustre/obdclass/genops.c
lustre/obdclass/llog.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpcd.c
lustre/ptlrpc/recov_thread.c
lustre/ptlrpc/sec_gc.c
lustre/ptlrpc/service.c
lustre/quota/quota_check.c
lustre/quota/quota_context.c
lustre/quota/quota_master.c

index 0e9779f..4843432 100644 (file)
@@ -662,6 +662,34 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
 ])
 ])
 
+AC_DEFUN([LIBCFS_HAVE_OOM_H],
+[LB_CHECK_FILE([$LINUX/include/linux/oom.h], [
+        AC_DEFINE(HAVE_LINUX_OOM_H, 1,
+                [kernel has include/oom.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.18 store oom parameters in task struct.
+# 2.6.32 store oom parameters in signal struct
+AC_DEFUN([LIBCFS_OOMADJ_IN_SIG],
+[AC_MSG_CHECKING([kernel store oom parameters in task])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/sched.h>
+],[
+        struct signal_struct s;
+
+        s.oom_adj = 0;
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_OOMADJ_IN_SIG, 1,
+                  [kernel store a oom parameters in signal struct])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
 #
 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
 #
 #
 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
 #
@@ -752,6 +780,8 @@ LIBCFS_SOCK_MAP_FD_2ARG
 # 2.6.32
 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
 LC_SHRINKER_WANT_SHRINK_PTR
 # 2.6.32
 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
 LC_SHRINKER_WANT_SHRINK_PTR
+LIBCFS_HAVE_OOM_H
+LIBCFS_OOMADJ_IN_SIG
 # 2.6.34
 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
 ])
 # 2.6.34
 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
 ])
index 4291ff0..12008ee 100644 (file)
@@ -204,7 +204,9 @@ extern task_t       kernel_task;
 
 #define CLONE_SIGNAL    (CLONE_SIGHAND | CLONE_THREAD)
 
 
 #define CLONE_SIGNAL    (CLONE_SIGHAND | CLONE_THREAD)
 
-extern int cfs_kernel_thread(cfs_thread_t func, void *arg, int flag);
+#define CFS_DAEMON_FLAGS (CLONE_VM | CLONE_FILES)
+
+extern int cfs_create_thread(cfs_thread_t func, void *arg, unsigned long flag);
 
 
 /*
 
 
 /*
index 19fbca1..dfe8af2 100644 (file)
@@ -184,18 +184,9 @@ typedef long                            cfs_task_state_t;
 /* Kernel thread */
 typedef int (*cfs_thread_t)(void *);
 
 /* Kernel thread */
 typedef int (*cfs_thread_t)(void *);
 
-static inline int cfs_kernel_thread(int (*fn)(void *),
-                                    void *arg, unsigned long flags)
-{
-        void *orig_info = current->journal_info;
-        int rc;
-
-        current->journal_info = NULL;
-        rc = kernel_thread(fn, arg, flags);
-        current->journal_info = orig_info;
-        return rc;
-}
-
+#define CFS_DAEMON_FLAGS (CLONE_VM | CLONE_FILES)
+extern int cfs_create_thread(int (*fn)(void *),
+                             void *arg, unsigned long flags);
 
 /*
  * Task struct
 
 /*
  * Task struct
index 8605d37..39cb8bf 100644 (file)
@@ -142,12 +142,13 @@ static inline int cfs_psdev_deregister(cfs_psdev_t *foo)
 #define cfs_sigfillset(l)               do {} while (0)
 #define cfs_recalc_sigpending(l)        do {} while (0)
 /* Fine, crash, but stop giving me compile warnings */
 #define cfs_sigfillset(l)               do {} while (0)
 #define cfs_recalc_sigpending(l)        do {} while (0)
 /* Fine, crash, but stop giving me compile warnings */
-#define cfs_kernel_thread(l,m,n)        (LBUG(), l, 0)
 #define cfs_kthread_run(fn,d,fmt,...)   LBUG()
 
 #define cfs_kthread_run(fn,d,fmt,...)   LBUG()
 
+#define CFS_DAEMON_FLAGS                0
+
 #ifdef HAVE_LIBPTHREAD
 typedef int (*cfs_thread_t)(void *);
 #ifdef HAVE_LIBPTHREAD
 typedef int (*cfs_thread_t)(void *);
-int cfs_create_thread(cfs_thread_t func, void *arg);
+int cfs_create_thread(cfs_thread_t func, void *arg, unsigned long flags);
 #else
 #define cfs_create_thread(l,m) LBUG()
 #endif
 #else
 #define cfs_create_thread(l,m) LBUG()
 #endif
index 72d0acd..f2792d5 100644 (file)
@@ -461,7 +461,7 @@ typedef struct _cfs_thread_context {
     void *              arg;
 } cfs_thread_context_t;
 
     void *              arg;
 } cfs_thread_context_t;
 
-int cfs_kernel_thread(int (*func)(void *), void *arg, int flag);
+int cfs_create_thread(int (*func)(void *), void *arg, unsigned long flag);
 
 /*
  * thread creation flags from Linux, not used in winnt
 
 /*
  * thread creation flags from Linux, not used in winnt
@@ -480,6 +480,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag);
 
 #define CLONE_SIGNAL    (CLONE_SIGHAND | CLONE_THREAD)
 
 
 #define CLONE_SIGNAL    (CLONE_SIGHAND | CLONE_THREAD)
 
+#define CFS_DAEMON_FLAGS (CLONE_VM|CLONE_FILES)
 
 /*
  * group_info: linux/sched.h
 
 /*
  * group_info: linux/sched.h
index eb8b232..9c7b2e5 100644 (file)
@@ -334,7 +334,7 @@ cfs_thread_agent (void)
 extern thread_t kernel_thread(task_t task, void (*start)(void));
 
 int
 extern thread_t kernel_thread(task_t task, void (*start)(void));
 
 int
-cfs_kernel_thread(cfs_thread_t  func, void *arg, int flag)
+cfs_create_thread(cfs_thread_t  func, void *arg, unsigned long flag)
 {
         int ret = 0;
         thread_t th = NULL;
 {
         int ret = 0;
         thread_t th = NULL;
index c53f878..3337f54 100644 (file)
@@ -533,7 +533,7 @@ static int is_last_frame(void *addr)
                return 1;
        else if (is_addr_in_range(addr, trap, syscall_trace))
                return 1;
                return 1;
        else if (is_addr_in_range(addr, trap, syscall_trace))
                return 1;
-       else if (is_addr_in_range(addr, cfs_thread_agent, cfs_kernel_thread))
+       else if (is_addr_in_range(addr, cfs_thread_agent, cfs_create_thread))
                return 1;
        else
                return 0;
                return 1;
        else
                return 0;
index fdd29e2..cfcefdf 100644 (file)
@@ -379,7 +379,7 @@ void libcfs_debug_dumplog(void)
         else
                 cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE);
 
         else
                 cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE);
 
-        /* be sure to teardown if cfs_kernel_thread() failed */
+        /* be sure to teardown if cfs_create_thread() failed */
         cfs_waitq_del(&debug_ctlwq, &wait);
         cfs_set_current_state(CFS_TASK_RUNNING);
 }
         cfs_waitq_del(&debug_ctlwq, &wait);
         cfs_set_current_state(CFS_TASK_RUNNING);
 }
index faf378f..a69b4e3 100644 (file)
  */
 
 # define DEBUG_SUBSYSTEM S_LNET
  */
 
 # define DEBUG_SUBSYSTEM S_LNET
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+
+#ifdef HAVE_LINUX_OOM_H
+#include <linux/oom.h>
+#else
+#include <linux/mm.h>
+#endif
+
+int oom_get_adj(struct task_struct *task, int scope)
+{
+
+        int oom_adj;
+#ifdef HAVE_OOMADJ_IN_SIG
+        unsigned long flags;
+
+        spin_lock_irqsave(&task->sighand->siglock, flags);
+        oom_adj = task->signal->oom_adj;
+        task->signal->oom_adj = scope;
+        spin_unlock_irqrestore(&task->sighand->siglock, flags);
+
+#else
+        oom_adj = task->oomkilladj;
+        task->oomkilladj = scope;
+#endif
+        return oom_adj;
+}
+
+int cfs_create_thread(int (*fn)(void *),
+                      void *arg, unsigned long flags)
+{
+        void *orig_info = current->journal_info;
+        int rc;
+        int old_oom;
+
+        old_oom = oom_get_adj(current, OOM_DISABLE);
+        current->journal_info = NULL;
+        rc = kernel_thread(fn, arg, flags);
+        current->journal_info = orig_info;
+        oom_get_adj(current, old_oom);
+
+        return rc;
+}
+EXPORT_SYMBOL(cfs_create_thread);
index b7439e9..d681fc3 100644 (file)
@@ -1096,7 +1096,7 @@ int cfs_trace_start_thread(void)
         cfs_waitq_init(&tctl->tctl_waitq);
         cfs_atomic_set(&tctl->tctl_shutdown, 0);
 
         cfs_waitq_init(&tctl->tctl_waitq);
         cfs_atomic_set(&tctl->tctl_shutdown, 0);
 
-        if (cfs_kernel_thread(tracefiled, tctl, 0) < 0) {
+        if (cfs_create_thread(tracefiled, tctl, 0) < 0) {
                 rc = -ECHILD;
                 goto out;
         }
                 rc = -ECHILD;
                 goto out;
         }
index ca6c661..0529581 100644 (file)
@@ -221,7 +221,8 @@ static void *cfs_thread_helper(void *data)
         (void)f(arg);
         return NULL;
 }
         (void)f(arg);
         return NULL;
 }
-int cfs_create_thread(cfs_thread_t func, void *arg)
+
+int cfs_create_thread(cfs_thread_t func, void *arg, unsigned long flags)
 {
         pthread_t tid;
         pthread_attr_t tattr;
 {
         pthread_t tid;
         pthread_attr_t tattr;
index cc6ae59..b9f488f 100644 (file)
@@ -326,7 +326,7 @@ static void lcw_dispatch_start(void)
         cfs_waitq_init(&lcw_event_waitq);
 
         CDEBUG(D_INFO, "starting dispatch thread\n");
         cfs_waitq_init(&lcw_event_waitq);
 
         CDEBUG(D_INFO, "starting dispatch thread\n");
-        rc = cfs_kernel_thread(lcw_dispatch_main, NULL, 0);
+        rc = cfs_create_thread(lcw_dispatch_main, NULL, 0);
         if (rc < 0) {
                 CERROR("error spawning watchdog dispatch thread: %d\n", rc);
                 EXIT;
         if (rc < 0) {
                 CERROR("error spawning watchdog dispatch thread: %d\n", rc);
                 EXIT;
index e28b654..0f1d0bd 100644 (file)
@@ -82,7 +82,7 @@ cfs_thread_proc(
 }
 
 /*
 }
 
 /*
- * cfs_kernel_thread
+ * cfs_create_thread
  *   Create a system thread to execute the routine specified
  *
  * Arguments:
  *   Create a system thread to execute the routine specified
  *
  * Arguments:
@@ -97,7 +97,7 @@ cfs_thread_proc(
  *   N/A
  */
 
  *   N/A
  */
 
-int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
+int cfs_create_thread(int (*func)(void *), void *arg, unsigned long flag)
 {
     cfs_handle_t  thread = NULL;
     NTSTATUS      status;
 {
     cfs_handle_t  thread = NULL;
     NTSTATUS      status;
index 90213ef..2da98fc 100644 (file)
@@ -5901,7 +5901,7 @@ ks_init_tdi_data()
         cfs_init_event(&ks_data.ksnd_engine_mgr[i].start, TRUE, FALSE);
         cfs_init_event(&ks_data.ksnd_engine_mgr[i].exit, TRUE, FALSE);
         CFS_INIT_LIST_HEAD(&ks_data.ksnd_engine_mgr[i].list);
         cfs_init_event(&ks_data.ksnd_engine_mgr[i].start, TRUE, FALSE);
         cfs_init_event(&ks_data.ksnd_engine_mgr[i].exit, TRUE, FALSE);
         CFS_INIT_LIST_HEAD(&ks_data.ksnd_engine_mgr[i].list);
-        cfs_kernel_thread(KsDeliveryEngineThread, &ks_data.ksnd_engine_mgr[i], 0);
+        cfs_create_thread(KsDeliveryEngineThread, &ks_data.ksnd_engine_mgr[i], 0);
     }
 
     /* register pnp handlers to watch network condition */
     }
 
     /* register pnp handlers to watch network condition */
index 6533867..d3bdf68 100644 (file)
@@ -332,7 +332,7 @@ cfs_wi_start_thread (int (*func) (void*), void *arg)
 {
         long pid;
 
 {
         long pid;
 
-        pid = cfs_kernel_thread(func, arg, 0);
+        pid = cfs_create_thread(func, arg, 0);
         if (pid < 0)
                 return (int)pid;
 
         if (pid < 0)
                 return (int)pid;
 
index fb80d3e..ae367e7 100644 (file)
@@ -397,9 +397,9 @@ mxlnd_thread_start(int (*fn)(void *arg), void *arg)
         cfs_atomic_inc(&kmxlnd_data.kmx_nthreads);
         cfs_init_completion(&kmxlnd_data.kmx_completions[i]);
 
         cfs_atomic_inc(&kmxlnd_data.kmx_nthreads);
         cfs_init_completion(&kmxlnd_data.kmx_completions[i]);
 
-        pid = cfs_kernel_thread (fn, arg, 0);
+        pid = cfs_create_thread(fn, arg, 0);
         if (pid < 0) {
         if (pid < 0) {
-                CERROR("cfs_kernel_thread() failed with %d\n", pid);
+                CERROR("cfs_create_thread() failed with %d\n", pid);
                 cfs_atomic_dec(&kmxlnd_data.kmx_nthreads);
         }
         return pid;
                 cfs_atomic_dec(&kmxlnd_data.kmx_nthreads);
         }
         return pid;
index 8127bd2..374d161 100644 (file)
@@ -1782,7 +1782,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 int
 kiblnd_thread_start (int (*fn)(void *arg), void *arg)
 {
 int
 kiblnd_thread_start (int (*fn)(void *arg), void *arg)
 {
-        long    pid = cfs_kernel_thread (fn, arg, 0);
+        long    pid = cfs_create_thread (fn, arg, 0);
 
         if (pid < 0)
                 return ((int)pid);
 
         if (pid < 0)
                 return ((int)pid);
index ad6a2bd..4934eda 100644 (file)
@@ -669,11 +669,11 @@ kptllnd_thread_start (int (*fn)(void *arg), void *arg)
 
         cfs_atomic_inc(&kptllnd_data.kptl_nthreads);
 
 
         cfs_atomic_inc(&kptllnd_data.kptl_nthreads);
 
-        pid = cfs_kernel_thread (fn, arg, 0);
+        pid = cfs_create_thread (fn, arg, 0);
         if (pid >= 0)
                 return 0;
 
         if (pid >= 0)
                 return 0;
 
-        CERROR("Failed to start cfs_kernel_thread: error %d\n", (int)pid);
+        CERROR("Failed to start thread: error %d\n", (int)pid);
         kptllnd_thread_fini();
         return (int)pid;
 }
         kptllnd_thread_fini();
         return (int)pid;
 }
index 1ff4621..a94bebb 100644 (file)
@@ -166,9 +166,9 @@ kptllnd_dump_ptltrace(void)
         cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
         cfs_waitq_add(&ptltrace_debug_ctlwq, &wait);
 
         cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
         cfs_waitq_add(&ptltrace_debug_ctlwq, &wait);
 
-        rc = cfs_kernel_thread(kptllnd_dump_ptltrace_thread,
+        rc = cfs_create_thread(kptllnd_dump_ptltrace_thread,
                                (void *)(long)cfs_curproc_pid(),
                                (void *)(long)cfs_curproc_pid(),
-                               CLONE_VM | CLONE_FS | CLONE_FILES);
+                               CFS_DAEMON_FLAGS | CLONE_FS);
         if (rc < 0) {
                 CERROR("Error %d starting ptltrace dump thread\n", rc);
         } else {
         if (rc < 0) {
                 CERROR("Error %d starting ptltrace dump thread\n", rc);
         } else {
index 0a6c249..835d970 100644 (file)
@@ -1658,7 +1658,7 @@ kqswnal_recv (lnet_ni_t     *ni,
 int
 kqswnal_thread_start (int (*fn)(void *arg), void *arg)
 {
 int
 kqswnal_thread_start (int (*fn)(void *arg), void *arg)
 {
-        long    pid = cfs_kernel_thread (fn, arg, 0);
+        long    pid = cfs_create_thread (fn, arg, 0);
 
         if (pid < 0)
                 return ((int)pid);
 
         if (pid < 0)
                 return ((int)pid);
index 9a73ad8..e6eb1ab 100644 (file)
@@ -893,7 +893,7 @@ kranal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
 int
 kranal_thread_start (int(*fn)(void *arg), void *arg)
 {
 int
 kranal_thread_start (int(*fn)(void *arg), void *arg)
 {
-        long    pid = cfs_kernel_thread(fn, arg, 0);
+        long    pid = cfs_create_thread(fn, arg, 0);
 
         if (pid < 0)
                 return(int)pid;
 
         if (pid < 0)
                 return(int)pid;
index 93e2e54..8182813 100644 (file)
@@ -1009,7 +1009,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 int
 ksocknal_thread_start (int (*fn)(void *arg), void *arg)
 {
 int
 ksocknal_thread_start (int (*fn)(void *arg), void *arg)
 {
-        long          pid = cfs_kernel_thread (fn, arg, 0);
+        long          pid = cfs_create_thread (fn, arg, 0);
 
         if (pid < 0)
                 return ((int)pid);
 
         if (pid < 0)
                 return ((int)pid);
index 56d264d..200a2f9 100644 (file)
@@ -72,7 +72,6 @@ lnet_accept_magic(__u32 magic, __u32 constant)
 #define cfs_mt_wait_for_completion(c) cfs_wait_for_completion(c)
 #define cfs_mt_complete(c)            cfs_complete(c)
 #define cfs_mt_fini_completion(c)     cfs_fini_completion(c)
 #define cfs_mt_wait_for_completion(c) cfs_wait_for_completion(c)
 #define cfs_mt_complete(c)            cfs_complete(c)
 #define cfs_mt_fini_completion(c)     cfs_fini_completion(c)
-#define cfs_create_thread(func, a)    cfs_kernel_thread(func, a, 0)
 
 EXPORT_SYMBOL(lnet_acceptor_port);
 
 
 EXPORT_SYMBOL(lnet_acceptor_port);
 
@@ -542,7 +541,7 @@ lnet_acceptor_start(void)
         if (lnet_count_acceptor_nis() == 0)  /* not required */
                 return 0;
 
         if (lnet_count_acceptor_nis() == 0)  /* not required */
                 return 0;
 
-        rc2 = cfs_create_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure);
+        rc2 = cfs_create_thread(lnet_acceptor, (void *)(ulong_ptr_t)secure, 0);
         if (rc2 < 0) {
                 CERROR("Can't start acceptor thread: %d\n", rc);
                 cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
         if (rc2 < 0) {
                 CERROR("Can't start acceptor thread: %d\n", rc);
                 cfs_mt_fini_completion(&lnet_acceptor_state.pta_signal);
index 752fad1..7b7ffa5 100644 (file)
@@ -49,7 +49,7 @@ static cfs_semaphore_t lnet_config_mutex;
 int
 lnet_configure (void *arg)
 {
 int
 lnet_configure (void *arg)
 {
-        /* 'arg' only there so I can be passed to cfs_kernel_thread() */
+        /* 'arg' only there so I can be passed to cfs_create_thread() */
         int    rc = 0;
 
         LNET_MUTEX_DOWN(&lnet_config_mutex);
         int    rc = 0;
 
         LNET_MUTEX_DOWN(&lnet_config_mutex);
@@ -133,7 +133,7 @@ init_lnet(void)
         if (config_on_load) {
                 /* Have to schedule a separate thread to avoid deadlocking
                  * in modload */
         if (config_on_load) {
                 /* Have to schedule a separate thread to avoid deadlocking
                  * in modload */
-                (void) cfs_kernel_thread(lnet_configure, NULL, 0);
+                (void) cfs_create_thread(lnet_configure, NULL, 0);
         }
 
         RETURN(0);
         }
 
         RETURN(0);
index 7fe9a0d..b7d6c85 100644 (file)
@@ -1003,7 +1003,7 @@ lnet_router_checker_start(void)
 
         the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
 #ifdef __KERNEL__
 
         the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
 #ifdef __KERNEL__
-        rc = (int)cfs_kernel_thread(lnet_router_checker, NULL, 0);
+        rc = cfs_create_thread(lnet_router_checker, NULL, 0);
         if (rc < 0) {
                 CERROR("Can't start router checker thread: %d\n", rc);
                 the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKING;
         if (rc < 0) {
                 CERROR("Can't start router checker thread: %d\n", rc);
                 the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKING;
index b4e5d52..96240bb 100644 (file)
@@ -206,7 +206,7 @@ stt_start_timer_thread (void)
 
         LASSERT (!stt_data.stt_shuttingdown);
 
 
         LASSERT (!stt_data.stt_shuttingdown);
 
-        pid = cfs_kernel_thread(stt_timer_main, NULL, 0);
+        pid = cfs_create_thread(stt_timer_main, NULL, 0);
         if (pid < 0)
                 return (int)pid;
 
         if (pid < 0)
                 return (int)pid;
 
index a48b644..83a5575 100644 (file)
@@ -298,7 +298,7 @@ usocklnd_base_startup()
         /* Spawn poll threads */
         for (i = 0; i < usock_data.ud_npollthreads; i++) {
                 rc = cfs_create_thread(usocklnd_poll_thread,
         /* Spawn poll threads */
         for (i = 0; i < usock_data.ud_npollthreads; i++) {
                 rc = cfs_create_thread(usocklnd_poll_thread,
-                                       &usock_data.ud_pollthreads[i]);
+                                       &usock_data.ud_pollthreads[i], 0);
                 if (rc) {
                         usocklnd_base_shutdown(i);
                         return rc;
                 if (rc) {
                         usocklnd_base_shutdown(i);
                         return rc;
index d0fa1cf..f55e5be 100644 (file)
@@ -1836,7 +1836,7 @@ static int target_start_recovery_thread(struct lu_target *lut,
         cfs_init_completion(&trd->trd_finishing);
         trd->trd_recovery_handler = handler;
 
         cfs_init_completion(&trd->trd_finishing);
         trd->trd_recovery_handler = handler;
 
-        if (cfs_kernel_thread(target_recovery_thread, lut, 0) > 0) {
+        if (cfs_create_thread(target_recovery_thread, lut, 0) > 0) {
                 cfs_wait_for_completion(&trd->trd_starting);
                 LASSERT(obd->obd_recovering != 0);
         } else
                 cfs_wait_for_completion(&trd->trd_starting);
                 LASSERT(obd->obd_recovering != 0);
         } else
index 6234ccf..f67fcc9 100644 (file)
@@ -2193,7 +2193,7 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp)
         int rc;
 
         cfs_init_completion(&bltd.bltd_comp);
         int rc;
 
         cfs_init_completion(&bltd.bltd_comp);
-        rc = cfs_kernel_thread(ldlm_bl_thread_main, &bltd, 0);
+        rc = cfs_create_thread(ldlm_bl_thread_main, &bltd, 0);
         if (rc < 0) {
                 CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %d\n",
                        cfs_atomic_read(&blp->blp_num_threads), rc);
         if (rc < 0) {
                 CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %d\n",
                        cfs_atomic_read(&blp->blp_num_threads), rc);
@@ -2527,7 +2527,7 @@ static int ldlm_setup(void)
         cfs_spin_lock_init(&waiting_locks_spinlock);
         cfs_timer_init(&waiting_locks_timer, waiting_locks_callback, 0);
 
         cfs_spin_lock_init(&waiting_locks_spinlock);
         cfs_timer_init(&waiting_locks_timer, waiting_locks_callback, 0);
 
-        rc = cfs_kernel_thread(expired_lock_main, NULL, CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(expired_lock_main, NULL, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("Cannot start ldlm expired-lock thread: %d\n", rc);
                 GOTO(out_thread, rc);
         if (rc < 0) {
                 CERROR("Cannot start ldlm expired-lock thread: %d\n", rc);
                 GOTO(out_thread, rc);
index 1219b39..2749a76 100644 (file)
@@ -1357,8 +1357,8 @@ static int ldlm_pools_thread_start(void)
          * CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize() right away.
          */
          * CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize() right away.
          */
-        rc = cfs_kernel_thread(ldlm_pools_thread_main, ldlm_pools_thread,
-                               CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(ldlm_pools_thread_main, ldlm_pools_thread,
+                               CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("Can't start pool thread, error %d\n",
                        rc);
         if (rc < 0) {
                 CERROR("Can't start pool thread, error %d\n",
                        rc);
index 483f026..1fcfacf 100644 (file)
@@ -297,7 +297,7 @@ int ll_capa_thread_start(void)
 
         cfs_waitq_init(&ll_capa_thread.t_ctl_waitq);
 
 
         cfs_waitq_init(&ll_capa_thread.t_ctl_waitq);
 
-        rc = cfs_kernel_thread(capa_thread_main, NULL, 0);
+        rc = cfs_create_thread(capa_thread_main, NULL, 0);
         if (rc < 0) {
                 CERROR("cannot start expired capa thread: rc %d\n", rc);
                 RETURN(rc);
         if (rc < 0) {
                 CERROR("cannot start expired capa thread: rc %d\n", rc);
                 RETURN(rc);
index 000e2c4..d2a6b0b 100644 (file)
@@ -401,7 +401,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
         cfs_waitq_init(&lcq->lcq_waitq);
         cfs_init_completion(&lcq->lcq_comp);
 
         cfs_waitq_init(&lcq->lcq_waitq);
         cfs_init_completion(&lcq->lcq_comp);
 
-        pid = cfs_kernel_thread(ll_close_thread, lcq, 0);
+        pid = cfs_create_thread(ll_close_thread, lcq, 0);
         if (pid < 0) {
                 OBD_FREE(lcq, sizeof(*lcq));
                 return pid;
         if (pid < 0) {
                 OBD_FREE(lcq, sizeof(*lcq));
                 return pid;
index 6975c85..f7d4654 100644 (file)
@@ -553,7 +553,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 
         set_blocksize(bdev, lo->lo_blocksize);
 
 
         set_blocksize(bdev, lo->lo_blocksize);
 
-        cfs_kernel_thread(loop_thread, lo, CLONE_KERNEL);
+        cfs_create_thread(loop_thread, lo, CLONE_KERNEL);
         cfs_down(&lo->lo_sem);
         return 0;
 
         cfs_down(&lo->lo_sem);
         return 0;
 
index 0385649..bfd7f89 100644 (file)
@@ -1198,7 +1198,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
         }
 
         lli->lli_sai = sai;
         }
 
         lli->lli_sai = sai;
-        rc = cfs_kernel_thread(ll_statahead_thread, parent, 0);
+        rc = cfs_create_thread(ll_statahead_thread, parent, 0);
         if (rc < 0) {
                 CERROR("can't start ll_sa thread, rc: %d\n", rc);
                 dput(parent);
         if (rc < 0) {
                 CERROR("can't start ll_sa thread, rc: %d\n", rc);
                 dput(parent);
index 92ebe03..a0bb726 100644 (file)
@@ -1348,8 +1348,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
 
         /* New thread because we should return to user app before
            writing into our pipe */
 
         /* New thread because we should return to user app before
            writing into our pipe */
-        rc = cfs_kernel_thread(mdc_changelog_send_thread, cs,
-                               CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(mdc_changelog_send_thread, cs, CFS_DAEMON_FLAGS);
         if (rc >= 0) {
                 CDEBUG(D_CHANGELOG, "start changelog thread: %d\n", rc);
                 return 0;
         if (rc >= 0) {
                 CDEBUG(D_CHANGELOG, "start changelog thread: %d\n", rc);
                 return 0;
index 8225a53..95edc07 100644 (file)
@@ -953,8 +953,8 @@ int mds_lov_start_synchronize(struct obd_device *obd,
 
         if (ev != OBD_NOTIFY_SYNC) {
                 /* Synchronize in the background */
 
         if (ev != OBD_NOTIFY_SYNC) {
                 /* Synchronize in the background */
-                rc = cfs_kernel_thread(mds_lov_synchronize, mlsi,
-                                       CLONE_VM | CLONE_FILES);
+                rc = cfs_create_thread(mds_lov_synchronize, mlsi,
+                                       CFS_DAEMON_FLAGS);
                 if (rc < 0) {
                         CERROR("%s: error starting mds_lov_synchronize: %d\n",
                                obd->obd_name, rc);
                 if (rc < 0) {
                         CERROR("%s: error starting mds_lov_synchronize: %d\n",
                                obd->obd_name, rc);
index bd10eda..a40d839 100644 (file)
@@ -287,8 +287,7 @@ int mdt_ck_thread_start(struct mdt_device *mdt)
         int rc;
 
         cfs_waitq_init(&thread->t_ctl_waitq);
         int rc;
 
         cfs_waitq_init(&thread->t_ctl_waitq);
-        rc = cfs_kernel_thread(mdt_ck_thread_main, mdt,
-                               (CLONE_VM | CLONE_FILES));
+        rc = cfs_create_thread(mdt_ck_thread_main, mdt, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("cannot start mdt_ck thread, rc = %d\n", rc);
                 return rc;
         if (rc < 0) {
                 CERROR("cannot start mdt_ck thread, rc = %d\n", rc);
                 return rc;
index a12a4e1..bc1cc5f 100644 (file)
@@ -513,8 +513,8 @@ static int mgc_requeue_add(struct config_llog_data *cld, int later)
                 LASSERT(rq_state == 0);
                 rq_state = RQ_RUNNING | (later ? RQ_LATER : RQ_NOW);
                 cfs_spin_unlock(&config_list_lock);
                 LASSERT(rq_state == 0);
                 rq_state = RQ_RUNNING | (later ? RQ_LATER : RQ_NOW);
                 cfs_spin_unlock(&config_list_lock);
-                rc = cfs_kernel_thread(mgc_requeue_thread, 0,
-                                       CLONE_VM | CLONE_FILES);
+                rc = cfs_create_thread(mgc_requeue_thread, NULL,
+                                       CFS_DAEMON_FLAGS);
                 if (rc < 0) {
                         CERROR("log %s: cannot start requeue thread (%d),"
                                "no more log updates!\n", cld->cld_logname, rc);
                 if (rc < 0) {
                         CERROR("log %s: cannot start requeue thread (%d),"
                                "no more log updates!\n", cld->cld_logname, rc);
index b004084..6221881 100644 (file)
@@ -1687,7 +1687,7 @@ int obd_zombie_impexp_init(void)
         obd_zombie_pid = 0;
 
 #ifdef __KERNEL__
         obd_zombie_pid = 0;
 
 #ifdef __KERNEL__
-        rc = cfs_kernel_thread(obd_zombie_impexp_thread, NULL, 0);
+        rc = cfs_create_thread(obd_zombie_impexp_thread, NULL, 0);
         if (rc < 0)
                 RETURN(rc);
 
         if (rc < 0)
                 RETURN(rc);
 
index 6469578..c2f4c17 100644 (file)
@@ -375,7 +375,7 @@ int llog_process_flags(struct llog_handle *loghandle, llog_cb_t cb,
 
 #ifdef __KERNEL__
         cfs_init_completion(&lpi->lpi_completion);
 
 #ifdef __KERNEL__
         cfs_init_completion(&lpi->lpi_completion);
-        rc = cfs_kernel_thread(llog_process_thread, lpi, CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(llog_process_thread, lpi, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("cannot start thread: %d\n", rc);
                 OBD_FREE_PTR(lpi);
         if (rc < 0) {
                 CERROR("cannot start thread: %d\n", rc);
                 OBD_FREE_PTR(lpi);
index 76de93e..ef403ce 100644 (file)
@@ -1325,8 +1325,8 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
                  * invalidate thread without reference to import and import can
                  * be freed at same time. */
                 class_import_get(imp);
                  * invalidate thread without reference to import and import can
                  * be freed at same time. */
                 class_import_get(imp);
-                rc = cfs_kernel_thread(ptlrpc_invalidate_import_thread, imp,
-                                       CLONE_VM | CLONE_FILES);
+                rc = cfs_create_thread(ptlrpc_invalidate_import_thread, imp,
+                                       CFS_DAEMON_FLAGS);
                 if (rc < 0) {
                         class_import_put(imp);
                         CERROR("error starting invalidate thread: %d\n", rc);
                 if (rc < 0) {
                         class_import_put(imp);
                         CERROR("error starting invalidate thread: %d\n", rc);
index 6724762..8251636 100644 (file)
@@ -363,7 +363,7 @@ int ptlrpc_start_pinger(void)
 
         /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */
 
         /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */
-        rc = cfs_kernel_thread(ptlrpc_pinger_main, &d, CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(ptlrpc_pinger_main, &d, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("cannot start thread: %d\n", rc);
                 OBD_FREE(pinger_thread, sizeof(*pinger_thread));
         if (rc < 0) {
                 CERROR("cannot start thread: %d\n", rc);
                 OBD_FREE(pinger_thread, sizeof(*pinger_thread));
@@ -698,7 +698,7 @@ void ping_evictor_start(void)
 
         cfs_waitq_init(&pet_waitq);
 
 
         cfs_waitq_init(&pet_waitq);
 
-        rc = cfs_kernel_thread(ping_evictor_main, NULL, CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(ping_evictor_main, NULL, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 pet_refcount--;
                 CERROR("Cannot start ping evictor thread: %d\n", rc);
         if (rc < 0) {
                 pet_refcount--;
                 CERROR("Cannot start ping evictor thread: %d\n", rc);
index 78c0546..90220ce 100644 (file)
@@ -436,7 +436,7 @@ int ptlrpcd_start(const char *name, struct ptlrpcd_ctl *pc)
         }
 
 #ifdef __KERNEL__
         }
 
 #ifdef __KERNEL__
-        rc = cfs_kernel_thread(ptlrpcd, pc, 0);
+        rc = cfs_create_thread(ptlrpcd, pc, 0);
         if (rc < 0)  {
                 lu_context_fini(&pc->pc_env.le_ctx);
                 ptlrpc_set_destroy(pc->pc_set);
         if (rc < 0)  {
                 lu_context_fini(&pc->pc_env.le_ctx);
                 ptlrpc_set_destroy(pc->pc_set);
index 38c4ad7..0a5365e 100644 (file)
@@ -546,8 +546,7 @@ static int llog_recov_thread_replay(struct llog_ctxt *ctxt,
                 OBD_FREE_PTR(lpca);
                 RETURN(-ENODEV);
         }
                 OBD_FREE_PTR(lpca);
                 RETURN(-ENODEV);
         }
-        rc = cfs_kernel_thread(llog_cat_process_thread, lpca,
-                               CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(llog_cat_process_thread, lpca, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("Error starting llog_cat_process_thread(): %d\n", rc);
                 OBD_FREE_PTR(lpca);
         if (rc < 0) {
                 CERROR("Error starting llog_cat_process_thread(): %d\n", rc);
                 OBD_FREE_PTR(lpca);
index 4a3585b..47e40f7 100644 (file)
@@ -236,8 +236,7 @@ int sptlrpc_gc_init(void)
         memset(&sec_gc_thread, 0, sizeof(sec_gc_thread));
         cfs_waitq_init(&sec_gc_thread.t_ctl_waitq);
 
         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;
         if (rc < 0) {
                 CERROR("can't start gc thread: %d\n", rc);
                 return rc;
index 902cdfd..3064cb8 100644 (file)
@@ -2325,8 +2325,7 @@ static int ptlrpc_start_hr_thread(struct ptlrpc_hr_service *hr, int n, int cpu)
         args.cpu_index = cpu;
         args.hrs = hr;
 
         args.cpu_index = cpu;
         args.hrs = hr;
 
-        rc = cfs_kernel_thread(ptlrpc_hr_main, (void*)&args,
-                               CLONE_VM|CLONE_FILES);
+        rc = cfs_create_thread(ptlrpc_hr_main, (void*)&args, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 cfs_complete(&t->hrt_completion);
                 GOTO(out, rc);
         if (rc < 0) {
                 cfs_complete(&t->hrt_completion);
                 GOTO(out, rc);
@@ -2518,7 +2517,7 @@ int ptlrpc_start_thread(struct ptlrpc_service *svc)
         /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize_ctxt() right away.
          */
         /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
          * just drop the VM and FILES in cfs_daemonize_ctxt() right away.
          */
-        rc = cfs_kernel_thread(ptlrpc_main, &d, CLONE_VM | CLONE_FILES);
+        rc = cfs_create_thread(ptlrpc_main, &d, CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("cannot start thread '%s': rc %d\n", name, rc);
 
         if (rc < 0) {
                 CERROR("cannot start thread '%s': rc %d\n", name, rc);
 
index 413934a..599ea4c 100644 (file)
@@ -174,8 +174,8 @@ int target_quota_check(struct obd_device *obd, struct obd_export *exp,
         /* we get ref for exp because target_quotacheck_callback() will use this
          * export later b=18126 */
         class_export_get(exp);
         /* we get ref for exp because target_quotacheck_callback() will use this
          * export later b=18126 */
         class_export_get(exp);
-        rc = cfs_kernel_thread(target_quotacheck_thread, qta,
-                               CLONE_VM|CLONE_FILES);
+        rc = cfs_create_thread(target_quotacheck_thread, qta,
+                               CFS_DAEMON_FLAGS);
         if (rc >= 0) {
                 /* target_quotacheck_thread will drop the ref on exp and release
                  * obt_quotachecking */
         if (rc >= 0) {
                 /* target_quotacheck_thread will drop the ref on exp and release
                  * obt_quotachecking */
index b1149e0..fbed203 100644 (file)
@@ -1487,8 +1487,8 @@ qslave_start_recovery(struct obd_device *obd, struct lustre_quota_ctxt *qctxt)
         data.qctxt = qctxt;
         cfs_init_completion(&data.comp);
 
         data.qctxt = qctxt;
         cfs_init_completion(&data.comp);
 
-        rc = cfs_kernel_thread(qslave_recovery_main, &data,
-                               CLONE_VM|CLONE_FILES);
+        rc = cfs_create_thread(qslave_recovery_main, &data,
+                               CFS_DAEMON_FLAGS);
         if (rc < 0) {
                 CERROR("Cannot start quota recovery thread: rc %d\n", rc);
                 goto exit;
         if (rc < 0) {
                 CERROR("Cannot start quota recovery thread: rc %d\n", rc);
                 goto exit;
index f675772..710f801 100644 (file)
@@ -1766,8 +1766,8 @@ int mds_quota_recovery(struct obd_device *obd)
         data.obd = obd;
         cfs_init_completion(&data.comp);
 
         data.obd = obd;
         cfs_init_completion(&data.comp);
 
-        rc = cfs_kernel_thread(qmaster_recovery_main, &data,
-                               CLONE_VM|CLONE_FILES);
+        rc = cfs_create_thread(qmaster_recovery_main, &data,
+                               CFS_DAEMON_FLAGS);
         if (rc < 0)
                 CERROR("%s: cannot start quota recovery thread: rc %d\n",
                        obd->obd_name, rc);
         if (rc < 0)
                 CERROR("%s: cannot start quota recovery thread: rc %d\n",
                        obd->obd_name, rc);