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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2013, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_LNET
34 #include <linux/module.h>
35 #include <linux/kernel.h>
36 #include <linux/fs_struct.h>
37 #include <linux/sched.h>
39 #include <libcfs/libcfs.h>
41 #if defined(CONFIG_KGDB)
45 void cfs_init_timer(struct timer_list *t)
49 EXPORT_SYMBOL(cfs_init_timer);
51 void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg)
55 t->data = (unsigned long)arg;
57 EXPORT_SYMBOL(cfs_timer_init);
59 void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline)
61 mod_timer(t, deadline);
63 EXPORT_SYMBOL(cfs_timer_arm);
65 void cfs_timer_disarm(struct timer_list *t)
69 EXPORT_SYMBOL(cfs_timer_disarm);
71 int cfs_timer_is_armed(struct timer_list *t)
73 return timer_pending(t);
75 EXPORT_SYMBOL(cfs_timer_is_armed);
77 cfs_time_t cfs_timer_deadline(struct timer_list *t)
81 EXPORT_SYMBOL(cfs_timer_deadline);
83 #ifndef HAVE_KTIME_GET_REAL_TS64
84 void ktime_get_real_ts64(struct timespec64 *ts)
86 *ts = timespec_to_timespec64(CURRENT_TIME);
88 EXPORT_SYMBOL(ktime_get_real_ts64);
89 #endif /* HAVE_KTIME_GET_REAL_TS64 */
92 cfs_block_allsigs(void)
97 spin_lock_irqsave(¤t->sighand->siglock, flags);
98 old = current->blocked;
99 sigfillset(¤t->blocked);
101 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
104 EXPORT_SYMBOL(cfs_block_allsigs);
106 sigset_t cfs_block_sigs(unsigned long sigs)
111 spin_lock_irqsave(¤t->sighand->siglock, flags);
112 old = current->blocked;
113 sigaddsetmask(¤t->blocked, sigs);
115 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
118 EXPORT_SYMBOL(cfs_block_sigs);
120 /* Block all signals except for the @sigs */
121 sigset_t cfs_block_sigsinv(unsigned long sigs)
126 spin_lock_irqsave(¤t->sighand->siglock, flags);
127 old = current->blocked;
128 sigaddsetmask(¤t->blocked, ~sigs);
130 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
133 EXPORT_SYMBOL(cfs_block_sigsinv);
136 cfs_restore_sigs(sigset_t old)
140 spin_lock_irqsave(¤t->sighand->siglock, flags);
141 current->blocked = old;
143 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
145 EXPORT_SYMBOL(cfs_restore_sigs);
148 cfs_clear_sigpending(void)
152 spin_lock_irqsave(¤t->sighand->siglock, flags);
153 clear_tsk_thread_flag(current, TIF_SIGPENDING);
154 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
156 EXPORT_SYMBOL(cfs_clear_sigpending);