Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / include / linux / lustre_lib.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Basic Lustre library routines.
22  *
23  */
24
25 #ifndef _LINUX_LUSTRE_LIB_H
26 #define _LINUX_LUSTRE_LIB_H
27
28 #ifndef _LUSTRE_LIB_H
29 #error Do not #include this file directly. #include <lustre_lib.h> instead
30 #endif
31
32 #ifndef __KERNEL__
33 # include <string.h>
34 # include <sys/types.h>
35 #else
36 # include <asm/semaphore.h>
37 # include <linux/rwsem.h>
38 # include <linux/sched.h>
39 # include <linux/signal.h>
40 # include <linux/types.h>
41 #endif
42 #include <linux/lustre_compat25.h>
43
44 #ifndef LP_POISON
45 #if BITS_PER_LONG > 32
46 # define LI_POISON ((int)0x5a5a5a5a5a5a5a5a)
47 # define LL_POISON ((long)0x5a5a5a5a5a5a5a5a)
48 # define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a)
49 #else
50 # define LI_POISON ((int)0x5a5a5a5a)
51 # define LL_POISON ((long)0x5a5a5a5a)
52 # define LP_POISON ((void *)(long)0x5a5a5a5a)
53 #endif
54 #endif
55
56 #define OBD_IOC_DATA_TYPE               long
57
58 #define LUSTRE_FATAL_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) |                \
59                            sigmask(SIGTERM) | sigmask(SIGQUIT) |               \
60                            sigmask(SIGALRM))
61
62 #ifdef __KERNEL__
63 static inline sigset_t l_w_e_set_sigs(int sigs)
64 {
65         sigset_t old;
66         unsigned long irqflags;
67
68         SIGNAL_MASK_LOCK(current, irqflags);
69         old = current->blocked;
70         siginitsetinv(&current->blocked, sigs);
71         RECALC_SIGPENDING;
72         SIGNAL_MASK_UNLOCK(current, irqflags);
73
74         return old;
75 }
76 #endif
77
78 #ifdef __KERNEL__
79 /* initialize ost_lvb according to inode */
80 static inline void inode_init_lvb(struct inode *inode, struct ost_lvb *lvb)
81 {
82         lvb->lvb_size = inode->i_size;
83         lvb->lvb_blocks = inode->i_blocks;
84         lvb->lvb_mtime = LTIME_S(inode->i_mtime);
85         lvb->lvb_atime = LTIME_S(inode->i_atime);
86         lvb->lvb_ctime = LTIME_S(inode->i_ctime);
87 }
88 #else
89 /* defined in liblustre/llite_lib.h */
90 #endif
91
92 #endif /* _LUSTRE_LIB_H */
93