blob: a268ef7aa19daa9a703623465442fdb76c7be473 [file] [log] [blame]
Peng Taod7e09d02013-05-02 16:46:55 +08001/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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.
9 *
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).
15 *
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
19 *
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
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2012, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 */
36
37#ifndef __LIBCFS_LINUX_LIBCFS_H__
38#define __LIBCFS_LINUX_LIBCFS_H__
39
40#ifndef __LIBCFS_LIBCFS_H__
41#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
42#endif
43
Greg Kroah-Hartmand2bc1182014-07-11 23:15:15 -070044#include <linux/bitops.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070045#include <linux/compiler.h>
46#include <linux/ctype.h>
47#include <linux/errno.h>
48#include <linux/file.h>
49#include <linux/fs.h>
50#include <linux/highmem.h>
51#include <linux/interrupt.h>
52#include <linux/kallsyms.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070053#include <linux/kernel.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070054#include <linux/kmod.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070055#include <linux/kthread.h>
56#include <linux/miscdevice.h>
57#include <linux/mm.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070058#include <linux/mm_inline.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070059#include <linux/module.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070060#include <linux/moduleparam.h>
Greg Kroah-Hartman6de97102014-07-11 23:28:12 -070061#include <linux/mutex.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070062#include <linux/notifier.h>
James Simmons899e1a32016-03-31 10:18:40 -040063#include <linux/pagemap.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070064#include <linux/random.h>
65#include <linux/rbtree.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070066#include <linux/rwsem.h>
67#include <linux/scatterlist.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070068#include <linux/sched.h>
69#include <linux/signal.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070070#include <linux/slab.h>
71#include <linux/smp.h>
72#include <linux/stat.h>
73#include <linux/string.h>
74#include <linux/time.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070075#include <linux/timer.h>
Greg Kroah-Hartman9fc48d02014-07-11 23:32:19 -070076#include <linux/types.h>
Greg Kroah-Hartman0918cf02014-07-12 20:32:03 -070077#include <linux/unistd.h>
78#include <linux/vmalloc.h>
Greg Kroah-Hartmanfb4a1532014-07-12 00:01:03 -070079#include <net/sock.h>
Gulsah Kosec2ad80e2014-09-30 21:59:19 +030080#include <linux/atomic.h>
Greg Kroah-Hartmanfa8d5b42014-07-12 18:17:20 -070081#include <asm/div64.h>
Gulsah Kosec2ad80e2014-09-30 21:59:19 +030082#include <linux/timex.h>
83#include <linux/uaccess.h>
Peng Taod7e09d02013-05-02 16:46:55 +080084#include <stdarg.h>
Greg Kroah-Hartman9fdaf8c2014-07-11 20:51:16 -070085#include "linux-cpu.h"
86#include "linux-time.h"
Peng Taod7e09d02013-05-02 16:46:55 +080087
Peng Taod7e09d02013-05-02 16:46:55 +080088#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
89
90#if !defined(__x86_64__)
Greg Kroah-Hartmana393fd52014-07-11 22:47:02 -070091# ifdef __ia64__
Peng Taod7e09d02013-05-02 16:46:55 +080092# define CDEBUG_STACK() (THREAD_SIZE - \
93 ((unsigned long)__builtin_dwarf_cfa() & \
94 (THREAD_SIZE - 1)))
95# else
96# define CDEBUG_STACK() (THREAD_SIZE - \
97 ((unsigned long)__builtin_frame_address(0) & \
98 (THREAD_SIZE - 1)))
99# endif /* __ia64__ */
100
101#define __CHECK_STACK(msgdata, mask, cdls) \
102do { \
103 if (unlikely(CDEBUG_STACK() > libcfs_stack)) { \
104 LIBCFS_DEBUG_MSG_DATA_INIT(msgdata, D_WARNING, NULL); \
105 libcfs_stack = CDEBUG_STACK(); \
106 libcfs_debug_msg(msgdata, \
107 "maximum lustre stack %lu\n", \
108 CDEBUG_STACK()); \
109 (msgdata)->msg_mask = mask; \
110 (msgdata)->msg_cdls = cdls; \
111 dump_stack(); \
112 /*panic("LBUG");*/ \
113 } \
114} while (0)
115#define CFS_CHECK_STACK(msgdata, mask, cdls) __CHECK_STACK(msgdata, mask, cdls)
116#else /* __x86_64__ */
Greg Kroah-Hartmana393fd52014-07-11 22:47:02 -0700117#define CFS_CHECK_STACK(msgdata, mask, cdls) do {} while (0)
Peng Taod7e09d02013-05-02 16:46:55 +0800118#define CDEBUG_STACK() (0L)
119#endif /* __x86_64__ */
120
Peng Taod7e09d02013-05-02 16:46:55 +0800121#define __current_nesting_level() (0)
122
123/**
124 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
125 *
126 * Implementation is in linux-curproc.c
127 */
Greg Kroah-Hartmana393fd52014-07-11 22:47:02 -0700128#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
Peng Taod7e09d02013-05-02 16:46:55 +0800129
130#include <linux/capability.h>
131
Peng Taod7e09d02013-05-02 16:46:55 +0800132/* long integer with size equal to pointer */
133typedef unsigned long ulong_ptr_t;
134typedef long long_ptr_t;
135
136#ifndef WITH_WATCHDOG
137#define WITH_WATCHDOG
138#endif
139
Peng Taod7e09d02013-05-02 16:46:55 +0800140#endif /* _LINUX_LIBCFS_H */