Whamcloud - gitweb
b=22418 2.6.32 compat synchronize_rcu already defined
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
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 #ifdef __KERNEL__
41
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
43 #error sorry, lustre requires at least 2.6.5
44 #endif
45
46 #include <linux/fs_struct.h>
47 #include <libcfs/linux/portals_compat25.h>
48
49 #include <linux/lustre_patchless_compat.h>
50
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
52 struct ll_iattr_struct {
53         struct iattr    iattr;
54         unsigned int    ia_attr_flags;
55 };
56 #else
57 #define ll_iattr_struct iattr
58 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
59
60 #ifdef HAVE_FS_STRUCT_USE_PATH
61 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
62                 struct dentry *dentry)
63 {
64         struct path path;
65         struct path old_pwd;
66
67         path.mnt = mnt;
68         path.dentry = dentry;
69         write_lock(&fs->lock);
70         old_pwd = fs->pwd;
71         path_get(&path);
72         fs->pwd = path;
73         write_unlock(&fs->lock);
74
75         if (old_pwd.dentry)
76                 path_put(&old_pwd);
77 }
78 #else
79 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
80                 struct dentry *dentry)
81 {
82         struct dentry *old_pwd;
83         struct vfsmount *old_pwdmnt;
84
85         write_lock(&fs->lock);
86         old_pwd = fs->pwd;
87         old_pwdmnt = fs->pwdmnt;
88         fs->pwdmnt = mntget(mnt);
89         fs->pwd = dget(dentry);
90         write_unlock(&fs->lock);
91
92         if (old_pwd) {
93                 dput(old_pwd);
94                 mntput(old_pwdmnt);
95         }
96 }
97 #endif /* HAVE_FS_STRUCT_USE_PATH */
98
99 #ifdef HAVE_INODE_I_MUTEX
100 #define UNLOCK_INODE_MUTEX(inode) do {mutex_unlock(&(inode)->i_mutex); } while(0)
101 #define LOCK_INODE_MUTEX(inode) do {mutex_lock(&(inode)->i_mutex); } while(0)
102 #define TRYLOCK_INODE_MUTEX(inode) mutex_trylock(&(inode)->i_mutex)
103 #else
104 #define UNLOCK_INODE_MUTEX(inode) do {up(&(inode)->i_sem); } while(0)
105 #define LOCK_INODE_MUTEX(inode) do {down(&(inode)->i_sem); } while(0)
106 #define TRYLOCK_INODE_MUTEX(inode) (!down_trylock(&(inode)->i_sem))
107 #endif /* HAVE_INODE_I_MUTEX */
108
109 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
110 #define d_child d_u.d_child
111 #define d_rcu d_u.d_rcu
112 #endif
113
114 #ifdef HAVE_DQUOTOFF_MUTEX
115 #define UNLOCK_DQONOFF_MUTEX(dqopt) do {mutex_unlock(&(dqopt)->dqonoff_mutex); } while(0)
116 #define LOCK_DQONOFF_MUTEX(dqopt) do {mutex_lock(&(dqopt)->dqonoff_mutex); } while(0)
117 #else
118 #define UNLOCK_DQONOFF_MUTEX(dqopt) do {up(&(dqopt)->dqonoff_sem); } while(0)
119 #define LOCK_DQONOFF_MUTEX(dqopt) do {down(&(dqopt)->dqonoff_sem); } while(0)
120 #endif /* HAVE_DQUOTOFF_MUTEX */
121
122
123 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
124 #define NGROUPS_SMALL           NGROUPS
125 #define NGROUPS_PER_BLOCK       ((int)(EXEC_PAGESIZE / sizeof(gid_t)))
126
127 struct group_info {
128         int        ngroups;
129         atomic_t   usage;
130         gid_t      small_block[NGROUPS_SMALL];
131         int        nblocks;
132         gid_t     *blocks[0];
133 };
134 #define current_ngroups current->ngroups
135 #define current_groups current->groups
136
137 struct group_info *groups_alloc(int gidsetsize);
138 void groups_free(struct group_info *ginfo);
139 #else /* >= 2.6.4 */
140
141 #define current_ngroups current_cred()->group_info->ngroups
142 #define current_groups current_cred()->group_info->small_block
143
144 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) */
145
146 #ifndef page_private
147 #define page_private(page) ((page)->private)
148 #define set_page_private(page, v) ((page)->private = (v))
149 #endif
150
151 #ifndef HAVE_GFP_T
152 #define gfp_t int
153 #endif
154
155 #define lock_dentry(___dentry)          spin_lock(&(___dentry)->d_lock)
156 #define unlock_dentry(___dentry)        spin_unlock(&(___dentry)->d_lock)
157
158 #define ll_kernel_locked()      kernel_locked()
159
160 /*
161  * OBD need working random driver, thus all our
162  * initialization routines must be called after device
163  * driver initialization
164  */
165 #ifndef MODULE
166 #undef module_init
167 #define module_init(a)     late_initcall(a)
168 #endif
169
170 /* XXX our code should be using the 2.6 calls, not the other way around */
171 #ifndef HAVE_TRYLOCK_PAGE
172 #define TryLockPage(page)               TestSetPageLocked(page)
173 #else
174 #define TryLockPage(page)               (!trylock_page(page))
175 #endif
176
177 #define Page_Uptodate(page)             PageUptodate(page)
178 #define ll_redirty_page(page)           set_page_dirty(page)
179
180 #define KDEVT_INIT(val)                 (val)
181
182 #define LTIME_S(time)                   (time.tv_sec)
183 #define ll_path_lookup                  path_lookup
184
185 #ifdef HAVE_EXPORT_INODE_PERMISSION
186 #define ll_permission(inode,mask,nd)    inode_permission(inode,mask)
187 #else
188 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
189 #endif
190
191 #define ll_pgcache_lock(mapping)          spin_lock(&mapping->page_lock)
192 #define ll_pgcache_unlock(mapping)        spin_unlock(&mapping->page_lock)
193 #define ll_call_writepage(inode, page)  \
194                                 (inode)->i_mapping->a_ops->writepage(page, NULL)
195 #define ll_invalidate_inode_pages(inode) \
196                                 invalidate_inode_pages((inode)->i_mapping)
197 #define ll_truncate_complete_page(page) \
198                                 truncate_complete_page(page->mapping, page)
199
200 #define ll_vfs_create(a,b,c,d)          vfs_create(a,b,c,d)
201 #define ll_dev_t                        dev_t
202 #define kdev_t                          dev_t
203 #define to_kdev_t(dev)                  (dev)
204 #define kdev_t_to_nr(dev)               (dev)
205 #define val_to_kdev(dev)                (dev)
206 #define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, (void *)(data));
207
208 #ifdef HAVE_BLKDEV_PUT_2ARGS
209 #define ll_blkdev_put(a, b) blkdev_put(a, b)
210 #else
211 #define ll_blkdev_put(a, b) blkdev_put(a)
212 #endif
213
214 #ifdef HAVE_DENTRY_OPEN_4ARGS
215 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
216 #else
217 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
218 #endif
219
220 #include <linux/writeback.h>
221
222 static inline int cleanup_group_info(void)
223 {
224         struct group_info *ginfo;
225
226         ginfo = groups_alloc(0);
227         if (!ginfo)
228                 return -ENOMEM;
229
230         set_current_groups(ginfo);
231         put_group_info(ginfo);
232
233         return 0;
234 }
235
236 #define __set_page_ll_data(page, llap) \
237         do {       \
238                 page_cache_get(page); \
239                 SetPagePrivate(page); \
240                 set_page_private(page, (unsigned long)llap); \
241         } while (0)
242 #define __clear_page_ll_data(page) \
243         do {       \
244                 ClearPagePrivate(page); \
245                 set_page_private(page, 0); \
246                 page_cache_release(page); \
247         } while(0)
248
249 #define kiobuf bio
250
251 #include <linux/proc_fs.h>
252
253 #if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
254 #define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
255 extern void __d_rehash(struct dentry *dentry, int lock);
256 #else
257 extern void d_rehash_cond(struct dentry*, int lock);
258 #endif
259
260 #if !defined(HAVE_D_MOVE_LOCKED) && defined(HAVE___D_MOVE)
261 #define d_move_locked(dentry, target) __d_move(dentry, target)
262 extern void __d_move(struct dentry *dentry, struct dentry *target);
263 #endif
264
265 #ifdef HAVE_CAN_SLEEP_ARG
266 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
267         flock_lock_file_wait(file, lock, can_sleep)
268 #else
269 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
270         flock_lock_file_wait(file, lock)
271 #endif
272
273 #define CheckWriteback(page, cmd) \
274         ((!PageWriteback(page) && (cmd & OBD_BRW_READ)) || \
275          (PageWriteback(page) && (cmd & OBD_BRW_WRITE)))
276
277
278 #ifdef HAVE_PAGE_LIST
279 static inline int mapping_has_pages(struct address_space *mapping)
280 {
281         int rc = 1;
282
283         ll_pgcache_lock(mapping);
284         if (list_empty(&mapping->dirty_pages) &&
285             list_empty(&mapping->clean_pages) &&
286             list_empty(&mapping->locked_pages)) {
287                 rc = 0;
288         }
289         ll_pgcache_unlock(mapping);
290
291         return rc;
292 }
293 #else
294 static inline int mapping_has_pages(struct address_space *mapping)
295 {
296         return mapping->nrpages > 0;
297 }
298 #endif
299
300 #ifdef HAVE_KIOBUF_KIO_BLOCKS
301 #define KIOBUF_GET_BLOCKS(k) ((k)->kio_blocks)
302 #else
303 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
304 #endif
305
306 #ifdef HAVE_SECURITY_PLUG
307 #ifdef HAVE_VFS_SYMLINK_5ARGS
308 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
309                 vfs_symlink(dir, dentry, mnt, path, mode)
310 #else
311 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
312                 vfs_symlink(dir, dentry, mnt, path)
313 #endif
314 #else
315 #ifdef HAVE_4ARGS_VFS_SYMLINK
316 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
317                 vfs_symlink(dir, dentry, path, mode)
318 #else
319 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
320                        vfs_symlink(dir, dentry, path)
321 #endif
322 #endif /* HAVE_SECURITY_PLUG */
323
324 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
325 #define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
326 #else
327 #define ll_set_dflags(dentry, flags) do { \
328                 spin_lock(&dentry->d_lock); \
329                 dentry->d_flags |= flags; \
330                 spin_unlock(&dentry->d_lock); \
331         } while(0)
332 #endif
333
334 #ifndef container_of
335 #define container_of(ptr, type, member) ({                      \
336                 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
337                 (type *)( (char *)__mptr - offsetof(type,member) );})
338 #endif
339
340 #define UP_WRITE_I_ALLOC_SEM(i)   up_write(&(i)->i_alloc_sem)
341 #define DOWN_WRITE_I_ALLOC_SEM(i) down_write(&(i)->i_alloc_sem)
342 #define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
343
344 #define UP_READ_I_ALLOC_SEM(i)    up_read(&(i)->i_alloc_sem)
345 #define DOWN_READ_I_ALLOC_SEM(i)  down_read(&(i)->i_alloc_sem)
346 #define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
347
348 #ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
349 #define grab_cache_page_nowait_gfp(x, y, z) grab_cache_page_nowait((x), (y))
350 #endif
351
352 #include <linux/mpage.h>        /* for generic_writepages */
353 #ifndef HAVE_FILEMAP_FDATAWRITE_RANGE
354 #include <linux/backing-dev.h>  /* for mapping->backing_dev_info */
355 static inline int filemap_fdatawrite_range(struct address_space *mapping,
356                                            loff_t start, loff_t end)
357 {
358         int rc;
359         struct writeback_control wbc = {
360                 .sync_mode = WB_SYNC_ALL,
361                 .nr_to_write = (end - start + PAGE_SIZE - 1) >> PAGE_SHIFT,
362         };
363
364 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
365         wbc.range_start = start;
366         wbc.range_end = end;
367 #else
368         wbc.start = start;
369         wbc.end = end;
370 #endif
371
372 #ifdef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
373         if (!mapping_cap_writeback_dirty(mapping))
374                 rc = 0;
375 #else
376         if (mapping->backing_dev_info->memory_backed)
377                 rc = 0;
378 #endif
379         /* do_writepages() */
380         else if (mapping->a_ops->writepages)
381                 rc = mapping->a_ops->writepages(mapping, &wbc);
382         else
383                 rc = generic_writepages(mapping, &wbc);
384         return rc;
385 }
386 #else
387 int filemap_fdatawrite_range(struct address_space *mapping,
388                              loff_t start, loff_t end);
389 #endif /* HAVE_FILEMAP_FDATAWRITE_RANGE */
390
391 #ifdef HAVE_VFS_KERN_MOUNT
392 static inline struct vfsmount *
393 ll_kern_mount(const char *fstype, int flags, const char *name, void *data)
394 {
395         struct file_system_type *type = get_fs_type(fstype);
396         struct vfsmount *mnt;
397         if (!type)
398                 return ERR_PTR(-ENODEV);
399         mnt = vfs_kern_mount(type, flags, name, data);
400         module_put(type->owner);
401         return mnt;
402 }
403 #else
404 #define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data))
405 #endif
406
407 #ifdef HAVE_STATFS_DENTRY_PARAM
408 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
409 #else
410 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
411 #endif
412
413 #ifndef HAVE_D_OBTAIN_ALIAS
414 #define d_obtain_alias(inode) d_alloc_anon(inode)
415 #endif
416
417 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
418 #define ll_unregister_blkdev(a,b)       unregister_blkdev((a),(b))
419 #else
420 static inline 
421 int ll_unregister_blkdev(unsigned int dev, const char *name)
422 {
423         unregister_blkdev(dev, name);
424         return 0;
425 }
426 #endif
427
428 #ifdef HAVE_INVALIDATE_BDEV_2ARG
429 #define ll_invalidate_bdev(a,b)         invalidate_bdev((a),(b))
430 #else
431 #define ll_invalidate_bdev(a,b)         invalidate_bdev((a))
432 #endif
433
434 #ifdef HAVE_FS_RENAME_DOES_D_MOVE
435 #define LL_RENAME_DOES_D_MOVE   FS_RENAME_DOES_D_MOVE
436 #else
437 #define LL_RENAME_DOES_D_MOVE   FS_ODD_RENAME
438 #endif
439
440 #ifdef HAVE_FILE_REMOVE_SUID
441 #define ll_remove_suid(file, mnt)       file_remove_suid(file)
442 #else
443  #ifdef HAVE_SECURITY_PLUG
444   #ifdef HAVE_PATH_REMOVE_SUID
445    #define ll_remove_suid(file,mnt)      remove_suid(&file->f_path)
446   #else
447    #define ll_remove_suid(file,mnt)      remove_suid(file->f_dentry,mnt)
448   #endif
449  #else
450   #define ll_remove_suid(file,mnt)      remove_suid(file->f_dentry)
451  #endif
452 #endif
453
454 #ifndef HAVE_SYNCHRONIZE_RCU
455 /* Linux 2.6.32 provides define when !CONFIG_TREE_PREEMPT_RCU */
456 #ifndef synchronize_rcu
457 #define synchronize_rcu() synchronize_kernel()
458 #endif
459 #endif
460
461 #ifdef HAVE_SECURITY_PLUG
462 #define ll_vfs_rmdir(dir,entry,mnt)             vfs_rmdir(dir,entry,mnt)
463 #define ll_vfs_mkdir(inode,dir,mnt,mode)        vfs_mkdir(inode,dir,mnt,mode)
464 #define ll_vfs_link(old,mnt,dir,new,mnt1)       vfs_link(old,mnt,dir,new,mnt1)
465 #define ll_vfs_unlink(inode,entry,mnt)          vfs_unlink(inode,entry,mnt)
466 #define ll_vfs_mknod(dir,entry,mnt,mode,dev)            \
467                 vfs_mknod(dir,entry,mnt,mode,dev)
468 #define ll_security_inode_unlink(dir,entry,mnt)         \
469                 security_inode_unlink(dir,entry,mnt)
470 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
471                 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
472 #else
473 #define ll_vfs_rmdir(dir,entry,mnt)             vfs_rmdir(dir,entry)
474 #define ll_vfs_mkdir(inode,dir,mnt,mode)        vfs_mkdir(inode,dir,mode)
475 #define ll_vfs_link(old,mnt,dir,new,mnt1)       vfs_link(old,dir,new)
476 #define ll_vfs_unlink(inode,entry,mnt)          vfs_unlink(inode,entry)
477 #define ll_vfs_mknod(dir,entry,mnt,mode,dev)    vfs_mknod(dir,entry,mode,dev)
478 #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry)
479 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
480                 vfs_rename(old,old_dir,new,new_dir)
481 #endif /* HAVE_SECURITY_PLUG */
482
483 #ifndef for_each_possible_cpu
484 #define for_each_possible_cpu(i) for_each_cpu(i)
485 #endif
486
487 #ifndef cpu_to_node
488 #define cpu_to_node(cpu)         0
489 #endif
490
491 #ifdef HAVE_REGISTER_SHRINKER
492
493 #define SHRINKER_MASK_T gfp_t
494
495 typedef int (*shrinker_t)(int nr_to_scan, gfp_t gfp_mask);
496
497 static inline
498 struct shrinker *set_shrinker(int seek, shrinker_t func)
499 {
500         struct shrinker *s;
501
502         s = kmalloc(sizeof(*s), GFP_KERNEL);
503         if (s == NULL)
504                 return (NULL);
505
506         s->shrink = func;
507         s->seeks = seek;
508
509         register_shrinker(s);
510
511         return s;
512 }
513
514 static inline
515 void remove_shrinker(struct shrinker *shrinker) 
516 {
517         if (shrinker == NULL)
518                 return;
519
520         unregister_shrinker(shrinker);
521         kfree(shrinker);
522 }
523 #endif /* HAVE_REGISTER_SHRINKER */
524
525 #ifdef HAVE_BIO_ENDIO_2ARG
526 #define cfs_bio_io_error(a,b)   bio_io_error((a))
527 #define cfs_bio_endio(a,b,c)    bio_endio((a),(c))
528 #else
529 #define cfs_bio_io_error(a,b)   bio_io_error((a),(b))
530 #define cfs_bio_endio(a,b,c)    bio_endio((a),(b),(c))
531 #endif
532
533 #ifdef HAVE_FS_STRUCT_USE_PATH
534 #define cfs_fs_pwd(fs)       ((fs)->pwd.dentry)
535 #define cfs_fs_mnt(fs)       ((fs)->pwd.mnt)
536 #define cfs_path_put(nd)     path_put(&(nd)->path)
537 #else
538 #define cfs_fs_pwd(fs)       ((fs)->pwd)
539 #define cfs_fs_mnt(fs)       ((fs)->pwdmnt)
540 #define cfs_path_put(nd)     path_release(nd)
541 #endif
542
543 #ifndef list_for_each_safe_rcu
544 #define list_for_each_safe_rcu(a,b,c) list_for_each_rcu(a, c)
545 #endif
546
547 #ifndef abs
548 static inline int abs(int x)
549 {
550         return (x < 0) ? -x : x;
551 }
552 #endif
553
554 #ifndef labs
555 static inline long labs(long x)
556 {
557         return (x < 0) ? -x : x;
558 }
559 #endif
560
561 /* Using kernel fls(). Userspace will use one defined in user-bitops.h. */
562 #ifndef __fls
563 #define __fls fls
564 #endif
565
566 #ifdef HAVE_INVALIDATE_INODE_PAGES
567 #define invalidate_mapping_pages(mapping,s,e) invalidate_inode_pages(mapping)
568 #endif
569
570 #ifndef SLAB_DESTROY_BY_RCU
571 #define SLAB_DESTROY_BY_RCU 0
572 #endif
573
574 #ifdef HAVE_INODE_IPRIVATE
575 #define INODE_PRIVATE_DATA(inode)       ((inode)->i_private)
576 #else
577 #define INODE_PRIVATE_DATA(inode)       ((inode)->u.generic_ip)
578 #endif
579
580 #ifndef HAVE_SYSCTL_VFS_CACHE_PRESSURE
581 #define sysctl_vfs_cache_pressure       100
582 #endif
583
584 #ifdef HAVE_SB_HAS_QUOTA_ACTIVE
585 #define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type)
586 #else
587 #define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
588 #endif
589
590 #ifdef HAVE_SB_ANY_QUOTA_ACTIVE
591 #define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
592 #else
593 #define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
594 #endif
595
596 static inline int
597 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
598 {
599         if (sb->s_qcop->quota_on) {
600                 return sb->s_qcop->quota_on(sb, off, ver, name
601 #ifdef HAVE_QUOTA_ON_5ARGS
602                                             , remount
603 #endif
604                                            );
605         }
606         else
607                 return -ENOSYS;
608 }
609
610 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
611 {
612         if (sb->s_qcop->quota_off) {
613                 return sb->s_qcop->quota_off(sb, off
614 #ifdef HAVE_QUOTA_OFF_3ARGS
615                                              , remount
616 #endif
617                                             );
618         }
619         else
620                 return -ENOSYS;
621 }
622
623 #ifndef HAVE_BI_HW_SEGMENTS
624 #define bio_hw_segments(q, bio) 0
625 #endif
626
627 #ifdef HAVE_FILE_UPDATE_TIME
628 #define ll_update_time(file) file_update_time(file)
629 #else
630 #define ll_update_time(file) inode_update_time(file->f_mapping->host, 1)
631 #endif
632
633 /* Needed for sles9 */
634 #ifndef HAVE_ATOMIC_CMPXCHG
635 #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
636 #endif
637
638 /* Needed for rhel4 and sles9 */
639 #ifndef HAVE_ATOMIC_INC_NOT_ZERO
640 /**
641  * atomic_add_unless - add unless the number is a given value
642  * @v: pointer of type atomic_t
643  * @a: the amount to add to v...
644  * @u: ...unless v is equal to u.
645  *
646  * Atomically adds @a to @v, so long as it was not @u.
647  * Returns non-zero if @v was not @u, and zero otherwise.
648  */
649 #define atomic_add_unless(v, a, u)                              \
650 ({                                                              \
651         int c, old;                                             \
652         c = atomic_read(v);                                     \
653         while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
654                 c = old;                                        \
655         c != (u);                                               \
656 })
657 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
658 #endif /* !atomic_inc_not_zero */
659
660 #ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
661 #define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
662 #endif
663
664 #ifdef HAVE_DQUOT_INIT
665 #define ll_vfs_dq_init DQUOT_INIT
666 #define ll_vfs_dq_drop DQUOT_DROP
667 #else
668 #define ll_vfs_dq_init vfs_dq_init
669 #define ll_vfs_dq_drop vfs_dq_drop
670 #endif
671
672 #ifndef HAVE_REQUEST_QUEUE_LIMITS
673 #define queue_max_sectors(rq)           ((rq)->max_sectors)
674 #define queue_max_hw_sectors(rq)        ((rq)->max_hw_sectors)
675 #define queue_max_hw_segments(rq)       ((rq)->max_hw_segments)
676 #define queue_max_phys_segments(rq)     ((rq)->max_phys_segments)
677 #endif
678
679 #endif /* __KERNEL__ */
680 #endif /* _COMPAT25_H */