From adb6cea0b70ac465b2a47635d9dc45d64ab1605b Mon Sep 17 00:00:00 2001 From: Alexey Lyashkov Date: Wed, 13 Jul 2011 07:16:12 +0400 Subject: [PATCH] LU-502 don't allow to kill service threads by OOM killer. OOM can produce a many issues like requests processing counter. Change-Id: I8d417d148b589ea6de84c5d16bc2607a59852564 Signed-off-by: Alexey Lyashkov Reviewed-on: http://review.whamcloud.com/1088 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 30 ++++++++++++++++++++ libcfs/include/libcfs/darwin/darwin-prim.h | 4 ++- libcfs/include/libcfs/linux/linux-prim.h | 15 ++-------- libcfs/include/libcfs/user-prim.h | 5 ++-- libcfs/include/libcfs/winnt/winnt-prim.h | 3 +- libcfs/libcfs/darwin/darwin-prim.c | 2 +- libcfs/libcfs/darwin/darwin-utils.c | 2 +- libcfs/libcfs/debug.c | 2 +- libcfs/libcfs/linux/linux-lwt.c | 45 ++++++++++++++++++++++++++++++ libcfs/libcfs/tracefile.c | 2 +- libcfs/libcfs/user-prim.c | 3 +- libcfs/libcfs/watchdog.c | 2 +- libcfs/libcfs/winnt/winnt-prim.c | 4 +-- libcfs/libcfs/winnt/winnt-tcpip.c | 2 +- libcfs/libcfs/workitem.c | 2 +- lnet/klnds/mxlnd/mxlnd.c | 4 +-- lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- lnet/klnds/ptllnd/ptllnd_cb.c | 4 +-- lnet/klnds/ptllnd/ptllnd_ptltrace.c | 4 +-- lnet/klnds/qswlnd/qswlnd_cb.c | 2 +- lnet/klnds/ralnd/ralnd_cb.c | 2 +- lnet/klnds/socklnd/socklnd_cb.c | 2 +- lnet/lnet/acceptor.c | 3 +- lnet/lnet/module.c | 4 +-- lnet/lnet/router.c | 2 +- lnet/selftest/timer.c | 2 +- lnet/ulnds/socklnd/usocklnd.c | 2 +- lustre/ldlm/ldlm_lib.c | 2 +- lustre/ldlm/ldlm_lockd.c | 4 +-- lustre/ldlm/ldlm_pool.c | 4 +-- lustre/llite/llite_capa.c | 2 +- lustre/llite/llite_close.c | 2 +- lustre/llite/lloop.c | 2 +- lustre/llite/statahead.c | 2 +- lustre/mdc/mdc_request.c | 3 +- lustre/mds/mds_lov.c | 4 +-- lustre/mdt/mdt_capa.c | 3 +- lustre/mgc/mgc_request.c | 4 +-- lustre/obdclass/genops.c | 2 +- lustre/obdclass/llog.c | 2 +- lustre/ptlrpc/import.c | 4 +-- lustre/ptlrpc/pinger.c | 4 +-- lustre/ptlrpc/ptlrpcd.c | 2 +- lustre/ptlrpc/recov_thread.c | 3 +- lustre/ptlrpc/sec_gc.c | 3 +- lustre/ptlrpc/service.c | 5 ++-- lustre/quota/quota_check.c | 4 +-- lustre/quota/quota_context.c | 4 +-- lustre/quota/quota_master.c | 4 +-- 49 files changed, 145 insertions(+), 80 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 0e9779f..4843432 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -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 +],[ + 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 # @@ -752,6 +780,8 @@ LIBCFS_SOCK_MAP_FD_2ARG # 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 ]) diff --git a/libcfs/include/libcfs/darwin/darwin-prim.h b/libcfs/include/libcfs/darwin/darwin-prim.h index 4291ff0..12008ee 100644 --- a/libcfs/include/libcfs/darwin/darwin-prim.h +++ b/libcfs/include/libcfs/darwin/darwin-prim.h @@ -204,7 +204,9 @@ extern task_t kernel_task; #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); /* diff --git a/libcfs/include/libcfs/linux/linux-prim.h b/libcfs/include/libcfs/linux/linux-prim.h index 19fbca1..dfe8af2 100644 --- a/libcfs/include/libcfs/linux/linux-prim.h +++ b/libcfs/include/libcfs/linux/linux-prim.h @@ -184,18 +184,9 @@ typedef long cfs_task_state_t; /* 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 diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index 8605d37..39cb8bf 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -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_kernel_thread(l,m,n) (LBUG(), l, 0) #define cfs_kthread_run(fn,d,fmt,...) LBUG() +#define CFS_DAEMON_FLAGS 0 + #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 diff --git a/libcfs/include/libcfs/winnt/winnt-prim.h b/libcfs/include/libcfs/winnt/winnt-prim.h index 72d0acd..f2792d5 100644 --- a/libcfs/include/libcfs/winnt/winnt-prim.h +++ b/libcfs/include/libcfs/winnt/winnt-prim.h @@ -461,7 +461,7 @@ typedef struct _cfs_thread_context { 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 @@ -480,6 +480,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag); #define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD) +#define CFS_DAEMON_FLAGS (CLONE_VM|CLONE_FILES) /* * group_info: linux/sched.h diff --git a/libcfs/libcfs/darwin/darwin-prim.c b/libcfs/libcfs/darwin/darwin-prim.c index eb8b232..9c7b2e5 100644 --- a/libcfs/libcfs/darwin/darwin-prim.c +++ b/libcfs/libcfs/darwin/darwin-prim.c @@ -334,7 +334,7 @@ cfs_thread_agent (void) 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; diff --git a/libcfs/libcfs/darwin/darwin-utils.c b/libcfs/libcfs/darwin/darwin-utils.c index c53f878..3337f54 100644 --- a/libcfs/libcfs/darwin/darwin-utils.c +++ b/libcfs/libcfs/darwin/darwin-utils.c @@ -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; - 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; diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index fdd29e2..cfcefdf 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -379,7 +379,7 @@ void libcfs_debug_dumplog(void) 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); } diff --git a/libcfs/libcfs/linux/linux-lwt.c b/libcfs/libcfs/linux/linux-lwt.c index faf378f..a69b4e3 100644 --- a/libcfs/libcfs/linux/linux-lwt.c +++ b/libcfs/libcfs/linux/linux-lwt.c @@ -35,3 +35,48 @@ */ # define DEBUG_SUBSYSTEM S_LNET +#include +#include +#include + +#ifdef HAVE_LINUX_OOM_H +#include +#else +#include +#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); diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index b7439e9..d681fc3 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -1096,7 +1096,7 @@ int cfs_trace_start_thread(void) 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; } diff --git a/libcfs/libcfs/user-prim.c b/libcfs/libcfs/user-prim.c index ca6c661..0529581 100644 --- a/libcfs/libcfs/user-prim.c +++ b/libcfs/libcfs/user-prim.c @@ -221,7 +221,8 @@ static void *cfs_thread_helper(void *data) (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; diff --git a/libcfs/libcfs/watchdog.c b/libcfs/libcfs/watchdog.c index cc6ae59..b9f488f 100644 --- a/libcfs/libcfs/watchdog.c +++ b/libcfs/libcfs/watchdog.c @@ -326,7 +326,7 @@ static void lcw_dispatch_start(void) 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; diff --git a/libcfs/libcfs/winnt/winnt-prim.c b/libcfs/libcfs/winnt/winnt-prim.c index e28b654..0f1d0bd 100644 --- a/libcfs/libcfs/winnt/winnt-prim.c +++ b/libcfs/libcfs/winnt/winnt-prim.c @@ -82,7 +82,7 @@ cfs_thread_proc( } /* - * cfs_kernel_thread + * cfs_create_thread * Create a system thread to execute the routine specified * * Arguments: @@ -97,7 +97,7 @@ cfs_thread_proc( * 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; diff --git a/libcfs/libcfs/winnt/winnt-tcpip.c b/libcfs/libcfs/winnt/winnt-tcpip.c index 90213ef..2da98fc 100644 --- a/libcfs/libcfs/winnt/winnt-tcpip.c +++ b/libcfs/libcfs/winnt/winnt-tcpip.c @@ -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_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 */ diff --git a/libcfs/libcfs/workitem.c b/libcfs/libcfs/workitem.c index 6533867..d3bdf68 100644 --- a/libcfs/libcfs/workitem.c +++ b/libcfs/libcfs/workitem.c @@ -332,7 +332,7 @@ cfs_wi_start_thread (int (*func) (void*), void *arg) { long pid; - pid = cfs_kernel_thread(func, arg, 0); + pid = cfs_create_thread(func, arg, 0); if (pid < 0) return (int)pid; diff --git a/lnet/klnds/mxlnd/mxlnd.c b/lnet/klnds/mxlnd/mxlnd.c index fb80d3e..ae367e7 100644 --- a/lnet/klnds/mxlnd/mxlnd.c +++ b/lnet/klnds/mxlnd/mxlnd.c @@ -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]); - pid = cfs_kernel_thread (fn, arg, 0); + pid = cfs_create_thread(fn, arg, 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; diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c index 8127bd2..374d161 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -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) { - long pid = cfs_kernel_thread (fn, arg, 0); + long pid = cfs_create_thread (fn, arg, 0); if (pid < 0) return ((int)pid); diff --git a/lnet/klnds/ptllnd/ptllnd_cb.c b/lnet/klnds/ptllnd/ptllnd_cb.c index ad6a2bd..4934eda 100644 --- a/lnet/klnds/ptllnd/ptllnd_cb.c +++ b/lnet/klnds/ptllnd/ptllnd_cb.c @@ -669,11 +669,11 @@ kptllnd_thread_start (int (*fn)(void *arg), void *arg) 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; - 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; } diff --git a/lnet/klnds/ptllnd/ptllnd_ptltrace.c b/lnet/klnds/ptllnd/ptllnd_ptltrace.c index 1ff4621..a94bebb 100644 --- a/lnet/klnds/ptllnd/ptllnd_ptltrace.c +++ b/lnet/klnds/ptllnd/ptllnd_ptltrace.c @@ -166,9 +166,9 @@ kptllnd_dump_ptltrace(void) 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(), - CLONE_VM | CLONE_FS | CLONE_FILES); + CFS_DAEMON_FLAGS | CLONE_FS); if (rc < 0) { CERROR("Error %d starting ptltrace dump thread\n", rc); } else { diff --git a/lnet/klnds/qswlnd/qswlnd_cb.c b/lnet/klnds/qswlnd/qswlnd_cb.c index 0a6c249..835d970 100644 --- a/lnet/klnds/qswlnd/qswlnd_cb.c +++ b/lnet/klnds/qswlnd/qswlnd_cb.c @@ -1658,7 +1658,7 @@ kqswnal_recv (lnet_ni_t *ni, 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); diff --git a/lnet/klnds/ralnd/ralnd_cb.c b/lnet/klnds/ralnd/ralnd_cb.c index 9a73ad8..e6eb1ab 100644 --- a/lnet/klnds/ralnd/ralnd_cb.c +++ b/lnet/klnds/ralnd/ralnd_cb.c @@ -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) { - long pid = cfs_kernel_thread(fn, arg, 0); + long pid = cfs_create_thread(fn, arg, 0); if (pid < 0) return(int)pid; diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c index 93e2e54..8182813 100644 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ b/lnet/klnds/socklnd/socklnd_cb.c @@ -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) { - long pid = cfs_kernel_thread (fn, arg, 0); + long pid = cfs_create_thread (fn, arg, 0); if (pid < 0) return ((int)pid); diff --git a/lnet/lnet/acceptor.c b/lnet/lnet/acceptor.c index 56d264d..200a2f9 100644 --- a/lnet/lnet/acceptor.c +++ b/lnet/lnet/acceptor.c @@ -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_create_thread(func, a) cfs_kernel_thread(func, a, 0) EXPORT_SYMBOL(lnet_acceptor_port); @@ -542,7 +541,7 @@ lnet_acceptor_start(void) 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); diff --git a/lnet/lnet/module.c b/lnet/lnet/module.c index 752fad1..7b7ffa5 100644 --- a/lnet/lnet/module.c +++ b/lnet/lnet/module.c @@ -49,7 +49,7 @@ static cfs_semaphore_t lnet_config_mutex; 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); @@ -133,7 +133,7 @@ init_lnet(void) 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); diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 7fe9a0d..b7d6c85 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -1003,7 +1003,7 @@ lnet_router_checker_start(void) 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; diff --git a/lnet/selftest/timer.c b/lnet/selftest/timer.c index b4e5d52..96240bb 100644 --- a/lnet/selftest/timer.c +++ b/lnet/selftest/timer.c @@ -206,7 +206,7 @@ stt_start_timer_thread (void) 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; diff --git a/lnet/ulnds/socklnd/usocklnd.c b/lnet/ulnds/socklnd/usocklnd.c index a48b644..83a5575 100644 --- a/lnet/ulnds/socklnd/usocklnd.c +++ b/lnet/ulnds/socklnd/usocklnd.c @@ -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, - &usock_data.ud_pollthreads[i]); + &usock_data.ud_pollthreads[i], 0); if (rc) { usocklnd_base_shutdown(i); return rc; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index d0fa1cf..f55e5be 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -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; - 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 diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 6234ccf..f67fcc9 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2193,7 +2193,7 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) 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); @@ -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); - 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); diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index 1219b39..2749a76 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -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. */ - 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); diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index 483f026..1fcfacf 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -297,7 +297,7 @@ int ll_capa_thread_start(void) 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); diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 000e2c4..d2a6b0b 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -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); - 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; diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 6975c85..f7d4654 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -553,7 +553,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused, 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; diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 0385649..bfd7f89 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -1198,7 +1198,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup) } 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); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 92ebe03..a0bb726 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -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 */ - 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; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 8225a53..95edc07 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -953,8 +953,8 @@ int mds_lov_start_synchronize(struct obd_device *obd, 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); diff --git a/lustre/mdt/mdt_capa.c b/lustre/mdt/mdt_capa.c index bd10eda..a40d839 100644 --- a/lustre/mdt/mdt_capa.c +++ b/lustre/mdt/mdt_capa.c @@ -287,8 +287,7 @@ int mdt_ck_thread_start(struct mdt_device *mdt) 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; diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index a12a4e1..bc1cc5f 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -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); - 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); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index b004084..6221881 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1687,7 +1687,7 @@ int obd_zombie_impexp_init(void) 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); diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 6469578..c2f4c17 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -375,7 +375,7 @@ int llog_process_flags(struct llog_handle *loghandle, llog_cb_t cb, #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); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 76de93e..ef403ce 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -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); - 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); diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index 6724762..8251636 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -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. */ - 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)); @@ -698,7 +698,7 @@ void ping_evictor_start(void) 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); diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index 78c0546..90220ce 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -436,7 +436,7 @@ int ptlrpcd_start(const char *name, struct ptlrpcd_ctl *pc) } #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); diff --git a/lustre/ptlrpc/recov_thread.c b/lustre/ptlrpc/recov_thread.c index 38c4ad7..0a5365e 100644 --- a/lustre/ptlrpc/recov_thread.c +++ b/lustre/ptlrpc/recov_thread.c @@ -546,8 +546,7 @@ static int llog_recov_thread_replay(struct llog_ctxt *ctxt, 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); diff --git a/lustre/ptlrpc/sec_gc.c b/lustre/ptlrpc/sec_gc.c index 4a3585b..47e40f7 100644 --- a/lustre/ptlrpc/sec_gc.c +++ b/lustre/ptlrpc/sec_gc.c @@ -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); - 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; diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 902cdfd..3064cb8 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -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; - 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); @@ -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. */ - 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); diff --git a/lustre/quota/quota_check.c b/lustre/quota/quota_check.c index 413934a..599ea4c 100644 --- a/lustre/quota/quota_check.c +++ b/lustre/quota/quota_check.c @@ -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); - 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 */ diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index b1149e0..fbed203 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -1487,8 +1487,8 @@ qslave_start_recovery(struct obd_device *obd, struct lustre_quota_ctxt *qctxt) 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; diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c index f675772..710f801 100644 --- a/lustre/quota/quota_master.c +++ b/lustre/quota/quota_master.c @@ -1766,8 +1766,8 @@ int mds_quota_recovery(struct obd_device *obd) 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); -- 1.8.3.1