1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef _LINUX_COMPAT25_H
38 #define _LINUX_COMPAT25_H
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
43 #error sorry, lustre requires at least linux kernel 2.6.9 or later
46 #include <linux/fs_struct.h>
47 #include <libcfs/linux/portals_compat25.h>
49 #include <linux/lustre_patchless_compat.h>
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
54 unsigned int ia_attr_flags;
57 #define ll_iattr iattr
58 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
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)
69 write_lock(&fs->lock);
73 write_unlock(&fs->lock);
81 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
82 struct dentry *dentry)
84 struct dentry *old_pwd;
85 struct vfsmount *old_pwdmnt;
87 cfs_write_lock(&fs->lock);
89 old_pwdmnt = fs->pwdmnt;
90 fs->pwdmnt = mntget(mnt);
91 fs->pwd = dget(dentry);
92 cfs_write_unlock(&fs->lock);
102 * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
103 * ATTR_* attributes (see bug 13828)
105 #define ATTR_BLOCKS (1 << 27)
107 #if HAVE_INODE_I_MUTEX
108 #define UNLOCK_INODE_MUTEX(inode) \
109 do {cfs_mutex_unlock(&(inode)->i_mutex); } while(0)
110 #define LOCK_INODE_MUTEX(inode) \
111 do {cfs_mutex_lock(&(inode)->i_mutex); } while(0)
112 #define LOCK_INODE_MUTEX_PARENT(inode) \
113 do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
114 #define TRYLOCK_INODE_MUTEX(inode) cfs_mutex_trylock(&(inode)->i_mutex)
116 #define UNLOCK_INODE_MUTEX(inode) do cfs_up(&(inode)->i_sem); } while(0)
117 #define LOCK_INODE_MUTEX(inode) do cfs_down(&(inode)->i_sem); } while(0)
118 #define TRYLOCK_INODE_MUTEX(inode) (!down_trylock(&(inode)->i_sem))
119 #define LOCK_INODE_MUTEX_PARENT(inode) LOCK_INODE_MUTEX(inode)
120 #endif /* HAVE_INODE_I_MUTEX */
123 #define LL_SEQ_LOCK(seq) cfs_mutex_lock(&(seq)->lock)
124 #define LL_SEQ_UNLOCK(seq) cfs_mutex_unlock(&(seq)->lock)
126 #define LL_SEQ_LOCK(seq) cfs_down(&(seq)->sem)
127 #define LL_SEQ_UNLOCK(seq) cfs_up(&(seq)->sem)
130 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
131 #define d_child d_u.d_child
132 #define d_rcu d_u.d_rcu
135 #ifdef HAVE_DQUOTOFF_MUTEX
136 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_unlock(&(dqopt)->dqonoff_mutex)
137 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_lock(&(dqopt)->dqonoff_mutex)
139 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_up(&(dqopt)->dqonoff_sem)
140 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
141 #endif /* HAVE_DQUOTOFF_MUTEX */
143 #define current_ngroups current_cred()->group_info->ngroups
144 #define current_groups current_cred()->group_info->small_block
147 #define page_private(page) ((page)->private)
148 #define set_page_private(page, v) ((page)->private = (v))
155 #define lock_dentry(___dentry) cfs_spin_lock(&(___dentry)->d_lock)
156 #define unlock_dentry(___dentry) cfs_spin_unlock(&(___dentry)->d_lock)
158 #define ll_kernel_locked() kernel_locked()
161 * OBD need working random driver, thus all our
162 * initialization routines must be called after device
163 * driver initialization
167 #define module_init(a) late_initcall(a)
170 /* XXX our code should be using the 2.6 calls, not the other way around */
171 #ifdef HAVE_TRYLOCK_PAGE
172 #define TestSetPageLocked(page) (!trylock_page(page))
175 #define Page_Uptodate(page) PageUptodate(page)
176 #define ll_redirty_page(page) set_page_dirty(page)
178 #define KDEVT_INIT(val) (val)
180 #define LTIME_S(time) (time.tv_sec)
181 #define ll_path_lookup path_lookup
182 #define ll_permission(inode,mask,nd) permission(inode,mask,nd)
184 #define ll_pgcache_lock(mapping) cfs_spin_lock(&mapping->page_lock)
185 #define ll_pgcache_unlock(mapping) cfs_spin_unlock(&mapping->page_lock)
186 #define ll_call_writepage(inode, page) \
187 (inode)->i_mapping->a_ops->writepage(page, NULL)
188 #define ll_invalidate_inode_pages(inode) \
189 invalidate_inode_pages((inode)->i_mapping)
190 #define ll_truncate_complete_page(page) \
191 truncate_complete_page(page->mapping, page)
193 #define ll_vfs_create(a,b,c,d) vfs_create(a,b,c,d)
194 #define ll_dev_t dev_t
196 #define to_kdev_t(dev) (dev)
197 #define kdev_t_to_nr(dev) (dev)
198 #define val_to_kdev(dev) (dev)
199 #define ILOOKUP(sb, ino, test, data) ilookup5(sb, ino, test, (void *)(data));
201 #ifdef HAVE_BLKDEV_PUT_2ARGS
202 #define ll_blkdev_put(a, b) blkdev_put(a, b)
204 #define ll_blkdev_put(a, b) blkdev_put(a)
207 #ifdef HAVE_DENTRY_OPEN_4ARGS
208 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
210 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
213 #include <linux/writeback.h>
215 static inline int cfs_cleanup_group_info(void)
217 struct group_info *ginfo;
219 ginfo = groups_alloc(0);
223 set_current_groups(ginfo);
224 put_group_info(ginfo);
229 #define __set_page_ll_data(page, llap) \
231 page_cache_get(page); \
232 SetPagePrivate(page); \
233 set_page_private(page, (unsigned long)llap); \
235 #define __clear_page_ll_data(page) \
237 ClearPagePrivate(page); \
238 set_page_private(page, 0); \
239 page_cache_release(page); \
244 #include <linux/proc_fs.h>
246 #if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
247 #define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
248 extern void __d_rehash(struct dentry *dentry, int lock);
251 #if !defined(HAVE_D_MOVE_LOCKED) && defined(HAVE___D_MOVE)
252 #define d_move_locked(dentry, target) __d_move(dentry, target)
253 extern void __d_move(struct dentry *dentry, struct dentry *target);
256 #ifdef HAVE_CAN_SLEEP_ARG
257 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
258 flock_lock_file_wait(file, lock, can_sleep)
260 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
261 flock_lock_file_wait(file, lock)
264 #define CheckWriteback(page, cmd) \
265 ((!PageWriteback(page) && (cmd & OBD_BRW_READ)) || \
266 (PageWriteback(page) && (cmd & OBD_BRW_WRITE)))
268 #ifdef HAVE_PAGE_LIST
269 static inline int mapping_has_pages(struct address_space *mapping)
273 ll_pgcache_lock(mapping);
274 if (cfs_list_empty(&mapping->dirty_pages) &&
275 cfs_list_empty(&mapping->clean_pages) &&
276 cfs_list_empty(&mapping->locked_pages)) {
279 ll_pgcache_unlock(mapping);
284 static inline int mapping_has_pages(struct address_space *mapping)
286 return mapping->nrpages > 0;
290 #ifdef HAVE_KIOBUF_KIO_BLOCKS
291 #define KIOBUF_GET_BLOCKS(k) ((k)->kio_blocks)
293 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
296 #ifdef HAVE_SECURITY_PLUG
297 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
298 vfs_symlink(dir, dentry, mnt, path, mode)
300 #ifdef HAVE_4ARGS_VFS_SYMLINK
301 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
302 vfs_symlink(dir, dentry, path, mode)
304 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
305 vfs_symlink(dir, dentry, path)
309 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
310 #define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
312 #define ll_set_dflags(dentry, flags) do { \
313 cfs_spin_lock(&dentry->d_lock); \
314 dentry->d_flags |= flags; \
315 cfs_spin_unlock(&dentry->d_lock); \
320 #define container_of(ptr, type, member) ({ \
321 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
322 (type *)( (char *)__mptr - offsetof(type,member) );})
325 #define UP_WRITE_I_ALLOC_SEM(i) up_write(&(i)->i_alloc_sem)
326 #define DOWN_WRITE_I_ALLOC_SEM(i) down_write(&(i)->i_alloc_sem)
327 #define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
329 #define UP_READ_I_ALLOC_SEM(i) up_read(&(i)->i_alloc_sem)
330 #define DOWN_READ_I_ALLOC_SEM(i) down_read(&(i)->i_alloc_sem)
331 #define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
333 #ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
334 #define grab_cache_page_nowait_gfp(x, y, z) grab_cache_page_nowait((x), (y))
337 #include <linux/mpage.h> /* for generic_writepages */
338 #ifndef HAVE_FILEMAP_FDATAWRITE_RANGE
339 #include <linux/backing-dev.h> /* for mapping->backing_dev_info */
340 static inline int filemap_fdatawrite_range(struct address_space *mapping,
341 loff_t start, loff_t end)
344 struct writeback_control wbc = {
345 .sync_mode = WB_SYNC_ALL,
346 .nr_to_write = (end - start + PAGE_SIZE - 1) >> PAGE_SHIFT,
349 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
350 wbc.range_start = start;
357 #ifdef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
358 if (!mapping_cap_writeback_dirty(mapping))
361 if (mapping->backing_dev_info->memory_backed)
364 /* do_writepages() */
365 else if (mapping->a_ops->writepages)
366 rc = mapping->a_ops->writepages(mapping, &wbc);
368 rc = generic_writepages(mapping, &wbc);
372 int filemap_fdatawrite_range(struct address_space *mapping,
373 loff_t start, loff_t end);
374 #endif /* HAVE_FILEMAP_FDATAWRITE_RANGE */
376 #ifdef HAVE_VFS_KERN_MOUNT
377 static inline struct vfsmount *
378 ll_kern_mount(const char *fstype, int flags, const char *name, void *data)
380 struct file_system_type *type = get_fs_type(fstype);
381 struct vfsmount *mnt;
383 return ERR_PTR(-ENODEV);
384 mnt = vfs_kern_mount(type, flags, name, data);
385 cfs_module_put(type->owner);
389 #define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data))
392 #ifdef HAVE_STATFS_DENTRY_PARAM
393 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
395 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
398 #ifndef HAVE_SB_TIME_GRAN
399 #ifndef HAVE_S_TIME_GRAN
400 #error Need s_time_gran patch!
402 static inline u32 get_sb_time_gran(struct super_block *sb)
404 return sb->s_time_gran;
408 #ifdef HAVE_RW_TREE_LOCK
409 #define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock)
410 #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
412 #define TREE_READ_LOCK_IRQ(mapping) cfs_spin_lock_irq(&(mapping)->tree_lock)
413 #define TREE_READ_UNLOCK_IRQ(mapping) cfs_spin_unlock_irq(&(mapping)->tree_lock)
416 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
417 #define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b))
420 int ll_unregister_blkdev(unsigned int dev, const char *name)
422 unregister_blkdev(dev, name);
427 #ifdef HAVE_INVALIDATE_BDEV_2ARG
428 #define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b))
430 #define ll_invalidate_bdev(a,b) invalidate_bdev((a))
433 #ifdef HAVE_INODE_BLKSIZE
434 #define ll_inode_blksize(a) (a)->i_blksize
436 #define ll_inode_blksize(a) (1<<(a)->i_blkbits)
439 #ifdef HAVE_FS_RENAME_DOES_D_MOVE
440 #define LL_RENAME_DOES_D_MOVE FS_RENAME_DOES_D_MOVE
442 #define LL_RENAME_DOES_D_MOVE FS_ODD_RENAME
445 #ifndef HAVE_D_OBTAIN_ALIAS
446 #define d_obtain_alias(inode) d_alloc_anon(inode)
449 /* add a lustre compatible layer for crypto API */
450 #include <linux/crypto.h>
451 #ifdef HAVE_ASYNC_BLOCK_CIPHER
452 #define ll_crypto_hash crypto_hash
453 #define ll_crypto_cipher crypto_blkcipher
454 #define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask)
455 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen)
456 #define ll_crypto_hash_init(desc) crypto_hash_init(desc)
457 #define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes)
458 #define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out)
459 #define ll_crypto_alloc_blkcipher(name, type, mask) \
460 crypto_alloc_blkcipher(name ,type, mask)
461 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
462 crypto_blkcipher_setkey(tfm, key, keylen)
463 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
464 crypto_blkcipher_set_iv(tfm, src, len)
465 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
466 crypto_blkcipher_get_iv(tfm, dst, len)
467 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
468 crypto_blkcipher_encrypt(desc, dst, src, bytes)
469 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
470 crypto_blkcipher_decrypt(desc, dst, src, bytes)
471 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
472 crypto_blkcipher_encrypt_iv(desc, dst, src, bytes)
473 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
474 crypto_blkcipher_decrypt_iv(desc, dst, src, bytes)
476 static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm,
477 u8 *key, unsigned int *keylen,
478 struct scatterlist *sg,
479 unsigned int size, u8 *result)
481 struct hash_desc desc;
485 rv = crypto_hash_setkey(desc.tfm, key, *keylen);
487 CERROR("failed to hash setkey: %d\n", rv);
490 return crypto_hash_digest(&desc, sg, size, result);
493 unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm)
495 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize;
498 unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
500 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
503 #define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm)
504 #define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm)
505 #define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm)
506 #define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm)
507 #define ll_crypto_free_hash(tfm) crypto_free_hash(tfm)
508 #define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm)
509 #else /* HAVE_ASYNC_BLOCK_CIPHER */
510 #include <linux/scatterlist.h>
511 #define ll_crypto_hash crypto_tfm
512 #define ll_crypto_cipher crypto_tfm
513 #ifndef HAVE_STRUCT_HASH_DESC
515 struct ll_crypto_hash *tfm;
519 #ifndef HAVE_STRUCT_BLKCIPHER_DESC
520 struct blkcipher_desc {
521 struct ll_crypto_cipher *tfm;
526 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
527 crypto_cipher_setkey(tfm, key, keylen)
528 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
529 crypto_cipher_set_iv(tfm, src, len)
530 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
531 crypto_cipher_get_iv(tfm, dst, len)
532 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
533 crypto_cipher_encrypt((desc)->tfm, dst, src, bytes)
534 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
535 crypto_cipher_decrypt((desc)->tfm, dst, src, bytes)
536 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
537 crypto_cipher_decrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
538 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
539 crypto_cipher_encrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
542 struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char * algname,
545 char buf[CRYPTO_MAX_ALG_NAME + 1];
546 const char *pan = algname;
549 if (strncmp("cbc(", algname, 4) == 0)
550 flag |= CRYPTO_TFM_MODE_CBC;
551 else if (strncmp("ecb(", algname, 4) == 0)
552 flag |= CRYPTO_TFM_MODE_ECB;
554 char *vp = strnchr(algname, CRYPTO_MAX_ALG_NAME, ')');
556 memcpy(buf, algname + 4, vp - algname - 4);
557 buf[vp - algname - 4] = '\0';
563 return crypto_alloc_tfm(pan, flag);
567 struct ll_crypto_hash *ll_crypto_alloc_hash(const char *alg, u32 type, u32 mask)
569 char buf[CRYPTO_MAX_ALG_NAME + 1];
570 const char *pan = alg;
572 if (strncmp("hmac(", alg, 5) == 0) {
573 char *vp = strnchr(alg, CRYPTO_MAX_ALG_NAME, ')');
575 memcpy(buf, alg+ 5, vp - alg- 5);
576 buf[vp - alg - 5] = 0x00;
580 return crypto_alloc_tfm(pan, 0);
582 static inline int ll_crypto_hash_init(struct hash_desc *desc)
584 crypto_digest_init(desc->tfm); return 0;
586 static inline int ll_crypto_hash_update(struct hash_desc *desc,
587 struct scatterlist *sg,
590 struct scatterlist *sl = sg;
593 * This way is very weakness. We must ensure that
594 * the sum of sg[0..i]->length isn't greater than nbytes.
595 * In the upstream kernel the crypto_hash_update() also
596 * via the nbytes computed the count of sg[...].
597 * The old style is more safely. but it gone.
599 for (count = 0; nbytes > 0; count ++, sl ++) {
600 nbytes -= sl->length;
602 crypto_digest_update(desc->tfm, sg, count); return 0;
604 static inline int ll_crypto_hash_final(struct hash_desc *desc, u8 *out)
606 crypto_digest_final(desc->tfm, out); return 0;
608 static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
609 u8 *key, unsigned int *keylen,
610 struct scatterlist *sg,
614 struct scatterlist *sl = sg;
616 for (count = 0; nbytes > 0; count ++, sl ++) {
617 nbytes -= sl->length;
619 crypto_hmac(tfm, key, keylen, sg, count, out);
623 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_digest_setkey(tfm, key, keylen)
624 #define ll_crypto_blkcipher_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
625 #define ll_crypto_blkcipher_ivsize(tfm) crypto_tfm_alg_ivsize(tfm)
626 #define ll_crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
627 #define ll_crypto_hash_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
628 #define ll_crypto_free_hash(tfm) crypto_free_tfm(tfm)
629 #define ll_crypto_free_blkcipher(tfm) crypto_free_tfm(tfm)
630 #define ll_crypto_tfm_alg_min_keysize crypto_tfm_alg_min_keysize
631 #define ll_crypto_tfm_alg_max_keysize crypto_tfm_alg_max_keysize
632 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
634 #ifndef HAVE_SYNCHRONIZE_RCU
635 #define synchronize_rcu() synchronize_kernel()
638 #ifdef HAVE_FILE_REMOVE_SUID
639 # define ll_remove_suid(file, mnt) file_remove_suid(file)
641 # ifdef HAVE_SECURITY_PLUG
642 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry,mnt)
644 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry)
648 #ifdef HAVE_SECURITY_PLUG
649 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry,mnt)
650 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mnt,mode)
651 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,mnt,dir,new,mnt1)
652 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry,mnt)
653 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) \
654 vfs_mknod(dir,entry,mnt,mode,dev)
655 #define ll_security_inode_unlink(dir,entry,mnt) \
656 security_inode_unlink(dir,entry,mnt)
657 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
658 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
660 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry)
661 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode)
662 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new)
663 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry)
664 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev)
665 #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry)
666 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
667 vfs_rename(old,old_dir,new,new_dir)
668 #endif /* HAVE_SECURITY_PLUG */
670 #ifdef for_each_possible_cpu
671 #define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
672 #elif defined(for_each_cpu)
673 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
677 #define cpu_to_node(cpu) 0
680 #ifdef HAVE_REGISTER_SHRINKER
681 typedef int (*cfs_shrinker_t)(int nr_to_scan, gfp_t gfp_mask);
684 struct shrinker *cfs_set_shrinker(int seek, cfs_shrinker_t func)
688 s = kmalloc(sizeof(*s), GFP_KERNEL);
695 register_shrinker(s);
701 void cfs_remove_shrinker(struct shrinker *shrinker)
703 if (shrinker == NULL)
706 unregister_shrinker(shrinker);
711 #ifdef HAVE_BIO_ENDIO_2ARG
712 #define cfs_bio_io_error(a,b) bio_io_error((a))
713 #define cfs_bio_endio(a,b,c) bio_endio((a),(c))
715 #define cfs_bio_io_error(a,b) bio_io_error((a),(b))
716 #define cfs_bio_endio(a,b,c) bio_endio((a),(b),(c))
719 #ifdef HAVE_FS_STRUCT_USE_PATH
720 #define cfs_fs_pwd(fs) ((fs)->pwd.dentry)
721 #define cfs_fs_mnt(fs) ((fs)->pwd.mnt)
722 #define cfs_path_put(nd) path_put(&(nd)->path)
724 #define cfs_fs_pwd(fs) ((fs)->pwd)
725 #define cfs_fs_mnt(fs) ((fs)->pwdmnt)
726 #define cfs_path_put(nd) path_release(nd)
730 static inline int abs(int x)
732 return (x < 0) ? -x : x;
737 static inline long labs(long x)
739 return (x < 0) ? -x : x;
741 #endif /* HAVE_REGISTER_SHRINKER */
743 #ifdef HAVE_INVALIDATE_INODE_PAGES
744 #define invalidate_mapping_pages(mapping,s,e) invalidate_inode_pages(mapping)
747 #ifdef HAVE_INODE_IPRIVATE
748 #define INODE_PRIVATE_DATA(inode) ((inode)->i_private)
750 #define INODE_PRIVATE_DATA(inode) ((inode)->u.generic_ip)
753 #ifndef SLAB_DESTROY_BY_RCU
754 #define CFS_SLAB_DESTROY_BY_RCU 0
756 #define CFS_SLAB_DESTROY_BY_RCU SLAB_DESTROY_BY_RCU
759 #ifdef HAVE_SB_HAS_QUOTA_ACTIVE
760 #define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type)
762 #define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
765 #ifdef HAVE_SB_ANY_QUOTA_ACTIVE
766 #define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
768 #define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
772 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
774 if (sb->s_qcop->quota_on) {
775 return sb->s_qcop->quota_on(sb, off, ver, name
776 #ifdef HAVE_QUOTA_ON_5ARGS
785 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
787 if (sb->s_qcop->quota_off) {
788 return sb->s_qcop->quota_off(sb, off
789 #ifdef HAVE_QUOTA_OFF_3ARGS
798 #ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
799 #define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
802 #endif /* __KERNEL__ */
803 #endif /* _COMPAT25_H */