4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #define DEBUG_SUBSYSTEM S_LNET
38 #include <linux/module.h>
39 #include <linux/kernel.h>
40 #include <linux/fs_struct.h>
41 #include <linux/sched.h>
43 #include <linux/libcfs/libcfs.h>
45 #if defined(CONFIG_KGDB)
50 * wait_queue_t of Linux (version < 2.6.34) is a FIFO list for exclusively
51 * waiting threads, which is not always desirable because all threads will
52 * be waken up again and again, even user only needs a few of them to be
53 * active most time. This is not good for performance because cache can
54 * be polluted by different threads.
56 * LIFO list can resolve this problem because we always wakeup the most
57 * recent active thread by default.
59 * NB: please don't call non-exclusive & exclusive wait on the same
60 * waitq if add_wait_queue_exclusive_head is used.
63 add_wait_queue_exclusive_head(wait_queue_head_t
*waitq
, wait_queue_t
*link
)
67 spin_lock_irqsave(&waitq
->lock
, flags
);
68 __add_wait_queue_exclusive(waitq
, link
);
69 spin_unlock_irqrestore(&waitq
->lock
, flags
);
71 EXPORT_SYMBOL(add_wait_queue_exclusive_head
);
73 void cfs_init_timer(struct timer_list
*t
)
77 EXPORT_SYMBOL(cfs_init_timer
);
79 void cfs_timer_init(struct timer_list
*t
, cfs_timer_func_t
*func
, void *arg
)
83 t
->data
= (unsigned long)arg
;
85 EXPORT_SYMBOL(cfs_timer_init
);
87 void cfs_timer_done(struct timer_list
*t
)
91 EXPORT_SYMBOL(cfs_timer_done
);
93 void cfs_timer_arm(struct timer_list
*t
, cfs_time_t deadline
)
95 mod_timer(t
, deadline
);
97 EXPORT_SYMBOL(cfs_timer_arm
);
99 void cfs_timer_disarm(struct timer_list
*t
)
103 EXPORT_SYMBOL(cfs_timer_disarm
);
105 int cfs_timer_is_armed(struct timer_list
*t
)
107 return timer_pending(t
);
109 EXPORT_SYMBOL(cfs_timer_is_armed
);
111 cfs_time_t
cfs_timer_deadline(struct timer_list
*t
)
115 EXPORT_SYMBOL(cfs_timer_deadline
);
117 void cfs_enter_debugger(void)
119 #if defined(CONFIG_KGDB)
128 cfs_block_allsigs(void)
133 SIGNAL_MASK_LOCK(current
, flags
);
134 old
= current
->blocked
;
135 sigfillset(¤t
->blocked
);
137 SIGNAL_MASK_UNLOCK(current
, flags
);
142 sigset_t
cfs_block_sigs(unsigned long sigs
)
147 SIGNAL_MASK_LOCK(current
, flags
);
148 old
= current
->blocked
;
149 sigaddsetmask(¤t
->blocked
, sigs
);
151 SIGNAL_MASK_UNLOCK(current
, flags
);
155 /* Block all signals except for the @sigs */
156 sigset_t
cfs_block_sigsinv(unsigned long sigs
)
161 SIGNAL_MASK_LOCK(current
, flags
);
162 old
= current
->blocked
;
163 sigaddsetmask(¤t
->blocked
, ~sigs
);
165 SIGNAL_MASK_UNLOCK(current
, flags
);
171 cfs_restore_sigs (sigset_t old
)
175 SIGNAL_MASK_LOCK(current
, flags
);
176 current
->blocked
= old
;
178 SIGNAL_MASK_UNLOCK(current
, flags
);
182 cfs_signal_pending(void)
184 return signal_pending(current
);
188 cfs_clear_sigpending(void)
192 SIGNAL_MASK_LOCK(current
, flags
);
193 clear_tsk_thread_flag(current
, TIF_SIGPENDING
);
194 SIGNAL_MASK_UNLOCK(current
, flags
);
198 libcfs_arch_init(void)
204 libcfs_arch_cleanup(void)
209 EXPORT_SYMBOL(libcfs_arch_init
);
210 EXPORT_SYMBOL(libcfs_arch_cleanup
);
211 EXPORT_SYMBOL(cfs_enter_debugger
);
212 EXPORT_SYMBOL(cfs_block_allsigs
);
213 EXPORT_SYMBOL(cfs_block_sigs
);
214 EXPORT_SYMBOL(cfs_block_sigsinv
);
215 EXPORT_SYMBOL(cfs_restore_sigs
);
216 EXPORT_SYMBOL(cfs_signal_pending
);
217 EXPORT_SYMBOL(cfs_clear_sigpending
);