Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / staging / lustre / lustre / include / linux / lustre_compat25.h
1 /*
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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 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 _LINUX_COMPAT25_H
38 #define _LINUX_COMPAT25_H
39
40 #include <linux/fs_struct.h>
41 #include <linux/namei.h>
42
43 #include "lustre_patchless_compat.h"
44
45 /*
46  * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
47  * ATTR_* attributes (see bug 13828)
48  */
49 #define ATTR_BLOCKS    (1 << 27)
50
51 #define current_ngroups current_cred()->group_info->ngroups
52 #define current_groups current_cred()->group_info->small_block
53
54 /*
55  * OBD need working random driver, thus all our
56  * initialization routines must be called after device
57  * driver initialization
58  */
59 #ifndef MODULE
60 #undef module_init
61 #define module_init(a)     late_initcall(a)
62 #endif
63
64
65 #define LTIME_S(time)              (time.tv_sec)
66
67 /* inode_dio_wait(i) use as-is for write lock */
68 # define inode_dio_write_done(i)        do {} while (0) /* for write unlock */
69 # define inode_dio_read(i)              atomic_inc(&(i)->i_dio_count)
70 /* inode_dio_done(i) use as-is for read unlock */
71
72
73 #ifndef FS_HAS_FIEMAP
74 #define FS_HAS_FIEMAP                   (0)
75 #endif
76
77 #define ll_vfs_rmdir(dir, entry, mnt)        vfs_rmdir(dir, entry)
78 #define ll_vfs_mkdir(inode, dir, mnt, mode)     vfs_mkdir(inode, dir, mode)
79 #define ll_vfs_link(old, mnt, dir, new, mnt1)       vfs_link(old, dir, new)
80 #define ll_vfs_unlink(inode, entry, mnt)          vfs_unlink(inode, entry)
81 #define ll_vfs_mknod(dir, entry, mnt, mode, dev) \
82                      vfs_mknod(dir, entry, mode, dev)
83 #define ll_security_inode_unlink(dir, entry, mnt) \
84                                  security_inode_unlink(dir, entry)
85 #define ll_vfs_rename(old, old_dir, mnt, new, new_dir, mnt1) \
86                 vfs_rename(old, old_dir, new, new_dir, NULL, 0)
87
88 #define cfs_bio_io_error(a, b)   bio_io_error((a))
89 #define cfs_bio_endio(a, b, c)    bio_endio((a), (c))
90
91 #define cfs_path_put(nd)     path_put(&(nd)->path)
92
93
94 #ifndef SLAB_DESTROY_BY_RCU
95 #define SLAB_DESTROY_BY_RCU 0
96 #endif
97
98
99
100 static inline int
101 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
102 {
103         int rc;
104
105         if (sb->s_qcop->quota_on) {
106                 struct path path;
107
108                 rc = kern_path(name, LOOKUP_FOLLOW, &path);
109                 if (!rc)
110                         return rc;
111                 rc = sb->s_qcop->quota_on(sb, off, ver
112                                             , &path
113                                            );
114                 path_put(&path);
115                 return rc;
116         } else
117                 return -ENOSYS;
118 }
119
120 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
121 {
122         if (sb->s_qcop->quota_off) {
123                 return sb->s_qcop->quota_off(sb, off
124                                             );
125         } else
126                 return -ENOSYS;
127 }
128
129
130 # define ll_vfs_dq_init      dquot_initialize
131 # define ll_vfs_dq_drop      dquot_drop
132 # define ll_vfs_dq_transfer      dquot_transfer
133 # define ll_vfs_dq_off(sb, remount) dquot_suspend(sb, -1)
134
135
136
137
138
139 #define queue_max_phys_segments(rq)       queue_max_segments(rq)
140 #define queue_max_hw_segments(rq)        queue_max_segments(rq)
141
142
143 #define ll_d_hlist_node hlist_node
144 #define ll_d_hlist_empty(list) hlist_empty(list)
145 #define ll_d_hlist_entry(ptr, type, name) hlist_entry(ptr.first, type, name)
146 #define ll_d_hlist_for_each(tmp, i_dentry) hlist_for_each(tmp, i_dentry)
147 #define ll_d_hlist_for_each_entry(dentry, p, i_dentry, alias) \
148         p = NULL; hlist_for_each_entry(dentry, i_dentry, alias)
149
150
151 #define bio_hw_segments(q, bio) 0
152
153
154 #define ll_pagevec_init(pv, cold)       do {} while (0)
155 #define ll_pagevec_add(pv, pg)    (0)
156 #define ll_pagevec_lru_add_file(pv)     do {} while (0)
157
158
159 #ifndef QUOTA_OK
160 # define QUOTA_OK 0
161 #endif
162 #ifndef NO_QUOTA
163 # define NO_QUOTA (-EDQUOT)
164 #endif
165
166 #ifndef SEEK_DATA
167 #define SEEK_DATA      3       /* seek to the next data */
168 #endif
169 #ifndef SEEK_HOLE
170 #define SEEK_HOLE      4       /* seek to the next hole */
171 #endif
172
173 #ifndef FMODE_UNSIGNED_OFFSET
174 #define FMODE_UNSIGNED_OFFSET   ((__force fmode_t)0x2000)
175 #endif
176
177 #if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
178 # define ext2_set_bit        __test_and_set_bit_le
179 # define ext2_clear_bit    __test_and_clear_bit_le
180 # define ext2_test_bit      test_bit_le
181 # define ext2_find_first_zero_bit find_first_zero_bit_le
182 # define ext2_find_next_zero_bit  find_next_zero_bit_le
183 #endif
184
185 #ifdef ATTR_TIMES_SET
186 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
187 #else
188 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET)
189 #endif
190
191
192
193 /*
194  * After 3.1, kernel's nameidata.intent.open.flags is different
195  * with lustre's lookup_intent.it_flags, as lustre's it_flags'
196  * lower bits equal to FMODE_xxx while kernel doesn't transliterate
197  * lower bits of nameidata.intent.open.flags to FMODE_xxx.
198  * */
199 #include <linux/version.h>
200 static inline int ll_namei_to_lookup_intent_flag(int flag)
201 {
202 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
203         flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
204 #endif
205         return flag;
206 }
207
208 #include <linux/fs.h>
209
210 # define ll_umode_t     umode_t
211
212 #include <linux/dcache.h>
213
214 # define ll_dirty_inode(inode, flag)    (inode)->i_sb->s_op->dirty_inode((inode), flag)
215
216 #endif /* _COMPAT25_H */