Whamcloud - gitweb
a1fb3dca47995d93b1ed20f47368a861aa7a0255
[fs/lustre-release.git] / lustre / include / linux / lustre_compat25.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2003 Cluster File Systems, Inc.
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  */
22
23 #ifndef _COMPAT25_H
24 #define _COMPAT25_H
25
26 #ifdef __KERNEL__
27
28 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) && LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69)
29 #error sorry, lustre requires at least 2.5.69
30 #endif
31
32 #include <linux/portals_compat25.h>
33
34 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
35
36 /*
37  * OBD need working random driver, thus all our
38  * initialization routines must be called after device
39  * driver initialization
40  */
41 #ifndef MODULE
42 #undef module_init
43 #define module_init(a)     late_initcall(a)
44 #endif
45
46 /* XXX our code should be using the 2.6 calls, not the other way around */
47 #define TryLockPage(page)                TestSetPageLocked(page)
48 #define filemap_fdatasync(mapping)       filemap_fdatawrite(mapping)
49 #define Page_Uptodate(page)              PageUptodate(page)
50
51 #define KDEVT_INIT(val)                 (val)
52
53 #define LTIME_S(time)                   (time.tv_sec)
54 #define ll_path_lookup                  path_lookup
55 #define ll_permission                   permission
56
57 #define ll_pgcache_lock(mapping)          spin_lock(&mapping->page_lock)
58 #define ll_pgcache_unlock(mapping)        spin_unlock(&mapping->page_lock)
59
60 #define ll_vfs_create(a,b,c,d)              vfs_create(a,b,c,d)
61
62 #define ll_dev_t                        dev_t
63 #define kdev_t                          dev_t
64 #define to_kdev_t(dev)                  (dev)
65 #define kdev_t_to_nr(dev)               (dev)
66 #define val_to_kdev(dev)                (dev)
67 #define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, data);
68
69 #include <linux/writeback.h>
70
71 static inline void lustre_daemonize_helper(void)
72 {
73         LASSERT(current->signal != NULL);
74         current->session = 1;
75         if (current->group_leader)
76                 current->group_leader->__pgrp = 1;
77         else
78                 CERROR("we aren't group leader\n");
79         current->tty = NULL;
80 }
81
82 #define  rb_node_s rb_node
83 #define  rb_root_s rb_root
84 typedef struct rb_root_s rb_root_t;
85 typedef struct rb_node_s rb_node_t;
86
87 #define smp_num_cpus    NR_CPUS
88
89 #ifndef conditional_schedule
90 #define conditional_schedule() cond_resched()
91 #endif
92
93 #include <linux/proc_fs.h>
94
95 #else /* 2.4.. */
96
97 #define ll_vfs_create(a,b,c,d)              vfs_create(a,b,c)
98 #define ll_permission(a,b,c)                permission(a,b)
99 #define ILOOKUP(sb, ino, test, data)        ilookup4(sb, ino, test, data);
100 #define DCACHE_DISCONNECTED                 DCACHE_NFSD_DISCONNECTED
101 #define ll_dev_t                            int
102
103 static inline void clear_page_dirty(struct page *page)
104 {
105         if (PageDirty(page))
106                 ClearPageDirty(page); 
107 }
108
109 /* 2.5 uses hlists for some things, like the d_hash.  we'll treat them
110  * as 2.5 and let macros drop back.. */
111 #ifndef HLIST_HEAD /* until we get a kernel newer than l28 */
112 #define hlist_entry                     list_entry
113 #define hlist_head                      list_head
114 #define hlist_node                      list_head
115 #define HLIST_HEAD                      LIST_HEAD
116 #define INIT_HLIST_HEAD                 INIT_LIST_HEAD
117 #define hlist_del_init                  list_del_init
118 #define hlist_add_head                  list_add
119 #define hlist_for_each_safe             list_for_each_safe
120 #endif
121 #define KDEVT_INIT(val)                 (val)
122 #define ext3_xattr_set_handle           ext3_xattr_set
123 #define extN_xattr_set_handle           extN_xattr_set
124 #define try_module_get                  __MOD_INC_USE_COUNT
125 #define module_put                      __MOD_DEC_USE_COUNT
126 #define LTIME_S(time)                   (time)
127 #if !defined(CONFIG_RH_2_4_20) && !defined(cpu_online)
128 #define cpu_online(cpu)                 (cpu_online_map & (1<<cpu))
129 #endif
130
131 static inline int ll_path_lookup(const char *path, unsigned flags, 
132                               struct nameidata *nd)
133 {
134         int error = 0;
135         if (path_init(path, flags, nd))
136                 error = path_walk(path, nd);
137         return error;
138 }
139 #define ll_permission(a,b,c)  permission(a,b)
140 typedef long sector_t;
141
142 #define ll_pgcache_lock(mapping)        spin_lock(&pagecache_lock)
143 #define ll_pgcache_unlock(mapping)      spin_unlock(&pagecache_lock)
144
145 static inline void __d_drop(struct dentry *dentry)
146 {
147         list_del(&dentry->d_hash);
148         INIT_LIST_HEAD(&dentry->d_hash);
149 }
150
151 static inline void lustre_daemonize_helper(void)
152 {
153         current->session = 1;
154         current->pgrp = 1;
155         current->tty = NULL;
156 }
157
158 #ifndef conditional_schedule
159 #define conditional_schedule() if (unlikely(need_resched())) schedule()
160 #endif
161
162 /* to find proc_dir_entry from inode. 2.6 has native one -bzzz */
163 #ifndef HAVE_PDE
164 #define PDE(ii)         ((ii)->u.generic_ip)
165 #endif
166
167 #endif /* end of 2.4 compat macros */
168
169 #endif /* __KERNEL__ */
170 #endif /* _COMPAT25_H */