Whamcloud - gitweb
LU-1402 libcfs: CFS_ALLOC_HIGH is __GFP_HIGHMEM
[fs/lustre-release.git] / libcfs / libcfs / user-prim.c
index fb5ac58..e6aaaea 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -80,6 +80,11 @@ void cfs_waitq_add_exclusive(struct cfs_waitq *waitq, struct cfs_waitlink *link)
         (void)link;
 }
 
+void cfs_waitq_add_exclusive_head(struct cfs_waitq *waitq, struct cfs_waitlink *link)
+{
+        cfs_waitq_add_exclusive(waitq, link);
+}
+
 void cfs_waitq_del(struct cfs_waitq *waitq, struct cfs_waitlink *link)
 {
         LASSERT(waitq != NULL);
@@ -195,7 +200,7 @@ cfs_time_t cfs_timer_deadline(cfs_timer_t *l)
 }
 
 
-#ifdef HAVE_PTHREAD
+#ifdef HAVE_LIBPTHREAD
 
 /*
  * Threads
@@ -216,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;
@@ -276,24 +282,39 @@ int cfs_daemonize_ctxt(char *str)
 
 cfs_sigset_t cfs_block_allsigs(void)
 {
-        cfs_sigset_t   all;
-        cfs_sigset_t   old;
-        int            rc;
+       cfs_sigset_t   all;
+       cfs_sigset_t   old;
+       int            rc;
 
-        sigfillset(&all);
-        rc = sigprocmask(SIG_SETMASK, &all, &old);
-        LASSERT(rc == 0);
+       sigfillset(&all);
+       rc = sigprocmask(SIG_BLOCK, &all, &old);
+       LASSERT(rc == 0);
 
-        return old;
+       return old;
 }
 
-cfs_sigset_t cfs_block_sigs(cfs_sigset_t blocks)
+cfs_sigset_t cfs_block_sigs(unsigned long sigs)
 {
-        cfs_sigset_t   old;
-        int   rc;
+       cfs_sigset_t   old;
+       cfs_sigset_t   blocks = { { sigs } }; /* kludge */
+       int   rc;
 
-        rc = sigprocmask(SIG_SETMASK, &blocks, &old);
-        LASSERT (rc == 0);
+       rc = sigprocmask(SIG_BLOCK, &blocks, &old);
+       LASSERT (rc == 0);
+
+       return old;
+}
+
+/* Block all signals except for the @sigs. It's only used in
+ * Linux kernel, just a dummy here. */
+cfs_sigset_t cfs_block_sigsinv(unsigned long sigs)
+{
+        cfs_sigset_t old;
+        int rc;
+
+        /* Return old blocked sigs */
+        rc = sigprocmask(SIG_SETMASK, NULL, &old);
+        LASSERT(rc == 0);
 
         return old;
 }
@@ -357,10 +378,10 @@ void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no)
 /* __linux__ */
 #endif
 
-void lbug_with_loc(const char *file, const char *func, const int line)
+void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
 {
         /* No libcfs_catastrophe in userspace! */
-        libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "LBUG\n");
+        libcfs_debug_msg(msgdata, "LBUG\n");
         abort();
 }