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.
32 * Copyright (c) 2011, 2012, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
39 #ifndef _LINUX_COMPAT25_H
40 #define _LINUX_COMPAT25_H
44 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
45 #error sorry, lustre requires at least linux kernel 2.6.9 or later
48 #include <linux/fs_struct.h>
49 #include <linux/namei.h>
50 #include <libcfs/linux/portals_compat25.h>
52 #include <linux/lustre_patchless_compat.h>
54 /* Some old kernels (like 2.6.9) may not define such SEEK_XXX. So the
55 * definition allows to compile lustre client on more OS platforms. */
62 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
65 unsigned int ia_attr_flags;
68 #define ll_iattr iattr
69 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
71 #ifdef HAVE_FS_STRUCT_RWLOCK
72 # define LOCK_FS_STRUCT(fs) cfs_write_lock(&(fs)->lock)
73 # define UNLOCK_FS_STRUCT(fs) cfs_write_unlock(&(fs)->lock)
75 # define LOCK_FS_STRUCT(fs) cfs_spin_lock(&(fs)->lock)
76 # define UNLOCK_FS_STRUCT(fs) cfs_spin_unlock(&(fs)->lock)
79 #ifdef HAVE_FS_STRUCT_USE_PATH
80 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
81 struct dentry *dentry)
100 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
101 struct dentry *dentry)
103 struct dentry *old_pwd;
104 struct vfsmount *old_pwdmnt;
108 old_pwdmnt = fs->pwdmnt;
109 fs->pwdmnt = mntget(mnt);
110 fs->pwd = dget(dentry);
111 UNLOCK_FS_STRUCT(fs);
121 * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
122 * ATTR_* attributes (see bug 13828)
124 #define ATTR_BLOCKS (1 << 27)
126 #if HAVE_INODE_I_MUTEX
127 #define UNLOCK_INODE_MUTEX(inode) \
128 do {cfs_mutex_unlock(&(inode)->i_mutex); } while(0)
129 #define LOCK_INODE_MUTEX(inode) \
130 do {cfs_mutex_lock(&(inode)->i_mutex); } while(0)
131 #define LOCK_INODE_MUTEX_PARENT(inode) \
132 do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
133 #define TRYLOCK_INODE_MUTEX(inode) cfs_mutex_trylock(&(inode)->i_mutex)
135 #define UNLOCK_INODE_MUTEX(inode) do cfs_up(&(inode)->i_sem); } while(0)
136 #define LOCK_INODE_MUTEX(inode) do cfs_down(&(inode)->i_sem); } while(0)
137 #define TRYLOCK_INODE_MUTEX(inode) (!down_trylock(&(inode)->i_sem))
138 #define LOCK_INODE_MUTEX_PARENT(inode) LOCK_INODE_MUTEX(inode)
139 #endif /* HAVE_INODE_I_MUTEX */
141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
142 #define d_child d_u.d_child
143 #define d_rcu d_u.d_rcu
146 #ifdef HAVE_DQUOTOFF_MUTEX
147 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_unlock(&(dqopt)->dqonoff_mutex)
148 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_lock(&(dqopt)->dqonoff_mutex)
150 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_up(&(dqopt)->dqonoff_sem)
151 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
152 #endif /* HAVE_DQUOTOFF_MUTEX */
154 #define current_ngroups current_cred()->group_info->ngroups
155 #define current_groups current_cred()->group_info->small_block
158 #define page_private(page) ((page)->private)
159 #define set_page_private(page, v) ((page)->private = (v))
162 #define lock_dentry(___dentry) cfs_spin_lock(&(___dentry)->d_lock)
163 #define unlock_dentry(___dentry) cfs_spin_unlock(&(___dentry)->d_lock)
165 #define ll_kernel_locked() kernel_locked()
168 * OBD need working random driver, thus all our
169 * initialization routines must be called after device
170 * driver initialization
174 #define module_init(a) late_initcall(a)
177 /* XXX our code should be using the 2.6 calls, not the other way around */
178 #ifdef HAVE_TRYLOCK_PAGE
179 #define TestSetPageLocked(page) (!trylock_page(page))
182 #define Page_Uptodate(page) PageUptodate(page)
183 #define ll_redirty_page(page) set_page_dirty(page)
185 #define KDEVT_INIT(val) (val)
187 #define LTIME_S(time) (time.tv_sec)
188 #define ll_path_lookup path_lookup
190 #ifdef HAVE_EXPORT_INODE_PERMISSION
191 #define ll_permission(inode,mask,nd) inode_permission(inode,mask)
193 #define ll_permission(inode,mask,nd) permission(inode,mask,nd)
196 #ifdef HAVE_GENERIC_PERMISSION_4ARGS
197 #define ll_generic_permission(inode, mask, flags, check_acl) \
198 generic_permission(inode, mask, flags, check_acl)
200 #define ll_generic_permission(inode, mask, flags, check_acl) \
201 generic_permission(inode, mask, check_acl)
204 #define ll_pgcache_lock(mapping) cfs_spin_lock(&mapping->page_lock)
205 #define ll_pgcache_unlock(mapping) cfs_spin_unlock(&mapping->page_lock)
206 #define ll_call_writepage(inode, page) \
207 (inode)->i_mapping->a_ops->writepage(page, NULL)
208 #define ll_invalidate_inode_pages(inode) \
209 invalidate_inode_pages((inode)->i_mapping)
211 #define ll_vfs_create(a,b,c,d) vfs_create(a,b,c,d)
212 #define ll_dev_t dev_t
214 #define to_kdev_t(dev) (dev)
215 #define kdev_t_to_nr(dev) (dev)
216 #define val_to_kdev(dev) (dev)
218 #ifdef HAVE_BLKDEV_PUT_2ARGS
219 #define ll_blkdev_put(a, b) blkdev_put(a, b)
221 #define ll_blkdev_put(a, b) blkdev_put(a)
224 #ifdef HAVE_DENTRY_OPEN_4ARGS
225 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
227 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
230 #include <linux/writeback.h>
232 static inline int cfs_cleanup_group_info(void)
234 struct group_info *ginfo;
236 ginfo = groups_alloc(0);
240 set_current_groups(ginfo);
241 put_group_info(ginfo);
246 #define __set_page_ll_data(page, llap) \
248 page_cache_get(page); \
249 SetPagePrivate(page); \
250 set_page_private(page, (unsigned long)llap); \
252 #define __clear_page_ll_data(page) \
254 ClearPagePrivate(page); \
255 set_page_private(page, 0); \
256 page_cache_release(page); \
261 #include <linux/proc_fs.h>
263 #if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
264 #define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
265 extern void __d_rehash(struct dentry *dentry, int lock);
268 #define CheckWriteback(page, cmd) \
269 ((!PageWriteback(page) && (cmd & OBD_BRW_READ)) || \
270 (PageWriteback(page) && (cmd & OBD_BRW_WRITE)))
272 #ifdef HAVE_PAGE_LIST
273 static inline int mapping_has_pages(struct address_space *mapping)
277 ll_pgcache_lock(mapping);
278 if (cfs_list_empty(&mapping->dirty_pages) &&
279 cfs_list_empty(&mapping->clean_pages) &&
280 cfs_list_empty(&mapping->locked_pages)) {
283 ll_pgcache_unlock(mapping);
288 static inline int mapping_has_pages(struct address_space *mapping)
290 return mapping->nrpages > 0;
294 #ifdef HAVE_KIOBUF_KIO_BLOCKS
295 #define KIOBUF_GET_BLOCKS(k) ((k)->kio_blocks)
297 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
300 #ifdef HAVE_SECURITY_PLUG
301 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
302 vfs_symlink(dir, dentry, mnt, path, mode)
304 #ifdef HAVE_4ARGS_VFS_SYMLINK
305 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
306 vfs_symlink(dir, dentry, path, mode)
308 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
309 vfs_symlink(dir, dentry, path)
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 #include <linux/mpage.h> /* for generic_writepages */
335 #ifndef HAVE_ATOMIC_MNT_COUNT
336 static inline unsigned int mnt_get_count(struct vfsmount *mnt)
339 unsigned int count = 0;
342 for_each_possible_cpu(cpu) {
343 count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count;
348 return mnt->mnt_count;
352 # define mnt_get_count(mnt) cfs_atomic_read(&mnt->mnt_count)
355 #ifdef HAVE_STATFS_DENTRY_PARAM
356 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
358 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
361 #ifndef HAVE_SB_TIME_GRAN
362 #ifndef HAVE_S_TIME_GRAN
363 #error Need s_time_gran patch!
365 static inline u32 get_sb_time_gran(struct super_block *sb)
367 return sb->s_time_gran;
371 #ifdef HAVE_RW_TREE_LOCK
372 #define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock)
373 #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
375 #define TREE_READ_LOCK_IRQ(mapping) cfs_spin_lock_irq(&(mapping)->tree_lock)
376 #define TREE_READ_UNLOCK_IRQ(mapping) cfs_spin_unlock_irq(&(mapping)->tree_lock)
379 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
380 #define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b))
383 int ll_unregister_blkdev(unsigned int dev, const char *name)
385 unregister_blkdev(dev, name);
390 #ifdef HAVE_INVALIDATE_BDEV_2ARG
391 #define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b))
393 #define ll_invalidate_bdev(a,b) invalidate_bdev((a))
396 #ifdef HAVE_INODE_BLKSIZE
397 #define ll_inode_blksize(a) (a)->i_blksize
399 #define ll_inode_blksize(a) (1<<(a)->i_blkbits)
402 #ifdef HAVE_FS_RENAME_DOES_D_MOVE
403 #define LL_RENAME_DOES_D_MOVE FS_RENAME_DOES_D_MOVE
405 #define LL_RENAME_DOES_D_MOVE FS_ODD_RENAME
408 #ifndef HAVE_D_OBTAIN_ALIAS
409 /* The old d_alloc_anon() didn't free the inode reference on error
410 * like d_obtain_alias(). Hide that difference/inconvenience here. */
411 static inline struct dentry *d_obtain_alias(struct inode *inode)
413 struct dentry *anon = d_alloc_anon(inode);
417 anon = ERR_PTR(-ENOMEM);
424 /* add a lustre compatible layer for crypto API */
425 #include <linux/crypto.h>
426 #ifdef HAVE_ASYNC_BLOCK_CIPHER
427 #define ll_crypto_hash crypto_hash
428 #define ll_crypto_cipher crypto_blkcipher
429 #define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask)
430 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen)
431 #define ll_crypto_hash_init(desc) crypto_hash_init(desc)
432 #define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes)
433 #define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out)
434 #define ll_crypto_alloc_blkcipher(name, type, mask) \
435 crypto_alloc_blkcipher(name ,type, mask)
436 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
437 crypto_blkcipher_setkey(tfm, key, keylen)
438 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
439 crypto_blkcipher_set_iv(tfm, src, len)
440 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
441 crypto_blkcipher_get_iv(tfm, dst, len)
442 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
443 crypto_blkcipher_encrypt(desc, dst, src, bytes)
444 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
445 crypto_blkcipher_decrypt(desc, dst, src, bytes)
446 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
447 crypto_blkcipher_encrypt_iv(desc, dst, src, bytes)
448 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
449 crypto_blkcipher_decrypt_iv(desc, dst, src, bytes)
451 static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm,
452 u8 *key, unsigned int *keylen,
453 struct scatterlist *sg,
454 unsigned int size, u8 *result)
456 struct hash_desc desc;
460 rv = crypto_hash_setkey(desc.tfm, key, *keylen);
462 CERROR("failed to hash setkey: %d\n", rv);
465 return crypto_hash_digest(&desc, sg, size, result);
468 unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm)
470 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize;
473 unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
475 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
478 #define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm)
479 #define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm)
480 #define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm)
481 #define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm)
482 #define ll_crypto_free_hash(tfm) crypto_free_hash(tfm)
483 #define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm)
484 #else /* HAVE_ASYNC_BLOCK_CIPHER */
485 #include <linux/scatterlist.h>
486 #define ll_crypto_hash crypto_tfm
487 #define ll_crypto_cipher crypto_tfm
488 #ifndef HAVE_STRUCT_HASH_DESC
490 struct ll_crypto_hash *tfm;
494 #ifndef HAVE_STRUCT_BLKCIPHER_DESC
495 struct blkcipher_desc {
496 struct ll_crypto_cipher *tfm;
501 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
502 crypto_cipher_setkey(tfm, key, keylen)
503 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
504 crypto_cipher_set_iv(tfm, src, len)
505 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
506 crypto_cipher_get_iv(tfm, dst, len)
507 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
508 crypto_cipher_encrypt((desc)->tfm, dst, src, bytes)
509 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
510 crypto_cipher_decrypt((desc)->tfm, dst, src, bytes)
511 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
512 crypto_cipher_decrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
513 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
514 crypto_cipher_encrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
517 struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char * algname,
520 char buf[CRYPTO_MAX_ALG_NAME + 1];
521 const char *pan = algname;
524 if (strncmp("cbc(", algname, 4) == 0)
525 flag |= CRYPTO_TFM_MODE_CBC;
526 else if (strncmp("ecb(", algname, 4) == 0)
527 flag |= CRYPTO_TFM_MODE_ECB;
529 char *vp = strnchr(algname, CRYPTO_MAX_ALG_NAME, ')');
531 memcpy(buf, algname + 4, vp - algname - 4);
532 buf[vp - algname - 4] = '\0';
538 return crypto_alloc_tfm(pan, flag);
542 struct ll_crypto_hash *ll_crypto_alloc_hash(const char *alg, u32 type, u32 mask)
544 char buf[CRYPTO_MAX_ALG_NAME + 1];
545 const char *pan = alg;
547 if (strncmp("hmac(", alg, 5) == 0) {
548 char *vp = strnchr(alg, CRYPTO_MAX_ALG_NAME, ')');
550 memcpy(buf, alg+ 5, vp - alg- 5);
551 buf[vp - alg - 5] = 0x00;
555 return crypto_alloc_tfm(pan, 0);
557 static inline int ll_crypto_hash_init(struct hash_desc *desc)
559 crypto_digest_init(desc->tfm); return 0;
561 static inline int ll_crypto_hash_update(struct hash_desc *desc,
562 struct scatterlist *sg,
565 struct scatterlist *sl = sg;
568 * This way is very weakness. We must ensure that
569 * the sum of sg[0..i]->length isn't greater than nbytes.
570 * In the upstream kernel the crypto_hash_update() also
571 * via the nbytes computed the count of sg[...].
572 * The old style is more safely. but it gone.
574 for (count = 0; nbytes > 0; count ++, sl ++) {
575 nbytes -= sl->length;
577 crypto_digest_update(desc->tfm, sg, count); return 0;
579 static inline int ll_crypto_hash_final(struct hash_desc *desc, u8 *out)
581 crypto_digest_final(desc->tfm, out); return 0;
583 static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
584 u8 *key, unsigned int *keylen,
585 struct scatterlist *sg,
589 struct scatterlist *sl = sg;
591 for (count = 0; nbytes > 0; count ++, sl ++) {
592 nbytes -= sl->length;
594 crypto_hmac(tfm, key, keylen, sg, count, out);
598 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_digest_setkey(tfm, key, keylen)
599 #define ll_crypto_blkcipher_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
600 #define ll_crypto_blkcipher_ivsize(tfm) crypto_tfm_alg_ivsize(tfm)
601 #define ll_crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
602 #define ll_crypto_hash_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
603 #define ll_crypto_free_hash(tfm) crypto_free_tfm(tfm)
604 #define ll_crypto_free_blkcipher(tfm) crypto_free_tfm(tfm)
605 #define ll_crypto_tfm_alg_min_keysize crypto_tfm_alg_min_keysize
606 #define ll_crypto_tfm_alg_max_keysize crypto_tfm_alg_max_keysize
607 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
609 #ifdef HAVE_FILE_REMOVE_SUID
610 # define ll_remove_suid(file, mnt) file_remove_suid(file)
612 # ifdef HAVE_SECURITY_PLUG
613 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry,mnt)
615 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry)
619 #ifdef HAVE_SECURITY_PLUG
620 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry,mnt)
621 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mnt,mode)
622 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,mnt,dir,new,mnt1)
623 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry,mnt)
624 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) \
625 vfs_mknod(dir,entry,mnt,mode,dev)
626 #define ll_security_inode_unlink(dir,entry,mnt) \
627 security_inode_unlink(dir,entry,mnt)
628 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
629 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
631 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry)
632 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode)
633 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new)
634 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry)
635 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev)
636 #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry)
637 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
638 vfs_rename(old,old_dir,new,new_dir)
639 #endif /* HAVE_SECURITY_PLUG */
641 #ifdef for_each_possible_cpu
642 #define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
643 #elif defined(for_each_cpu)
644 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
647 #ifdef HAVE_BIO_ENDIO_2ARG
648 #define cfs_bio_io_error(a,b) bio_io_error((a))
649 #define cfs_bio_endio(a,b,c) bio_endio((a),(c))
651 #define cfs_bio_io_error(a,b) bio_io_error((a),(b))
652 #define cfs_bio_endio(a,b,c) bio_endio((a),(b),(c))
655 #ifdef HAVE_FS_STRUCT_USE_PATH
656 #define cfs_fs_pwd(fs) ((fs)->pwd.dentry)
657 #define cfs_fs_mnt(fs) ((fs)->pwd.mnt)
658 #define cfs_path_put(nd) path_put(&(nd)->path)
660 #define cfs_fs_pwd(fs) ((fs)->pwd)
661 #define cfs_fs_mnt(fs) ((fs)->pwdmnt)
662 #define cfs_path_put(nd) path_release(nd)
666 static inline int abs(int x)
668 return (x < 0) ? -x : x;
673 static inline long labs(long x)
675 return (x < 0) ? -x : x;
677 #endif /* HAVE_REGISTER_SHRINKER */
679 #ifdef HAVE_INVALIDATE_INODE_PAGES
680 #define invalidate_mapping_pages(mapping,s,e) invalidate_inode_pages(mapping)
683 #ifdef HAVE_INODE_IPRIVATE
684 #define INODE_PRIVATE_DATA(inode) ((inode)->i_private)
686 #define INODE_PRIVATE_DATA(inode) ((inode)->u.generic_ip)
689 #ifndef HAVE_SIMPLE_SETATTR
690 #define simple_setattr(dentry, ops) inode_setattr((dentry)->d_inode, ops)
693 #ifndef SLAB_DESTROY_BY_RCU
694 #define CFS_SLAB_DESTROY_BY_RCU 0
696 #define CFS_SLAB_DESTROY_BY_RCU SLAB_DESTROY_BY_RCU
699 #ifdef HAVE_SB_HAS_QUOTA_ACTIVE
700 #define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type)
702 #define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
705 #ifdef HAVE_SB_ANY_QUOTA_LOADED
706 #define ll_sb_any_quota_active(sb) sb_any_quota_loaded(sb)
707 #elif defined(HAVE_SB_ANY_QUOTA_ACTIVE)
708 #define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
710 #define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
714 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
718 if (sb->s_qcop->quota_on) {
719 #ifdef HAVE_QUOTA_ON_USE_PATH
722 rc = kern_path(name, LOOKUP_FOLLOW, &path);
726 rc = sb->s_qcop->quota_on(sb, off, ver
727 #ifdef HAVE_QUOTA_ON_USE_PATH
732 #ifdef HAVE_QUOTA_ON_5ARGS
736 #ifdef HAVE_QUOTA_ON_USE_PATH
745 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
747 if (sb->s_qcop->quota_off) {
748 return sb->s_qcop->quota_off(sb, off
749 #ifdef HAVE_QUOTA_OFF_3ARGS
758 #ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
759 #define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
762 #ifndef HAVE_VFS_DQ_OFF
763 # define ll_vfs_dq_init DQUOT_INIT
764 # define ll_vfs_dq_drop DQUOT_DROP
765 # define ll_vfs_dq_transfer DQUOT_TRANSFER
766 # define ll_vfs_dq_off(sb, remount) DQUOT_OFF(sb)
768 # define ll_vfs_dq_init vfs_dq_init
769 # define ll_vfs_dq_drop vfs_dq_drop
770 # define ll_vfs_dq_transfer vfs_dq_transfer
771 # define ll_vfs_dq_off(sb, remount) vfs_dq_off(sb, remount)
775 #define ll_bdi_init(bdi) bdi_init(bdi)
776 #define ll_bdi_destroy(bdi) bdi_destroy(bdi)
778 #define ll_bdi_init(bdi) 0
779 #define ll_bdi_destroy(bdi) do { } while(0)
782 #ifdef HAVE_NEW_BACKING_DEV_INFO
783 # define ll_bdi_wb_cnt(bdi) ((bdi).wb_cnt)
785 # define ll_bdi_wb_cnt(bdi) 1
788 #ifdef HAVE_BLK_QUEUE_MAX_SECTORS /* removed in rhel6 */
789 #define blk_queue_max_hw_sectors(q, sect) blk_queue_max_sectors(q, sect)
792 #ifndef HAVE_BLKDEV_GET_BY_DEV
793 # define blkdev_get_by_dev(dev, mode, holder) open_by_devnum(dev, mode)
796 #ifndef HAVE_REQUEST_QUEUE_LIMITS
797 #define queue_max_sectors(rq) ((rq)->max_sectors)
798 #define queue_max_hw_sectors(rq) ((rq)->max_hw_sectors)
799 #define queue_max_phys_segments(rq) ((rq)->max_phys_segments)
800 #define queue_max_hw_segments(rq) ((rq)->max_hw_segments)
803 #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
804 #define blk_queue_max_segments(rq, seg) \
805 do { blk_queue_max_phys_segments(rq, seg); \
806 blk_queue_max_hw_segments(rq, seg); } while (0)
808 #define queue_max_phys_segments(rq) queue_max_segments(rq)
809 #define queue_max_hw_segments(rq) queue_max_segments(rq)
813 #ifndef HAVE_BI_HW_SEGMENTS
814 #define bio_hw_segments(q, bio) 0
817 #ifndef HAVE_PAGEVEC_LRU_ADD_FILE
818 #define pagevec_lru_add_file pagevec_lru_add
821 #ifdef HAVE_ADD_TO_PAGE_CACHE_LRU
822 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
823 add_to_page_cache_lru(pg, mapping, off, gfp)
824 #define ll_pagevec_init(pv, cold) do {} while (0)
825 #define ll_pagevec_add(pv, pg) (0)
826 #define ll_pagevec_lru_add_file(pv) do {} while (0)
828 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
829 add_to_page_cache(pg, mapping, off, gfp)
830 #define ll_pagevec_init(pv, cold) pagevec_init(&lru_pvec, cold);
831 #define ll_pagevec_add(pv, pg) pagevec_add(pv, pg)
832 #define ll_pagevec_lru_add_file(pv) pagevec_lru_add_file(pv)
835 #if !defined(HAVE_NODE_TO_CPUMASK) && defined(HAVE_CPUMASK_OF_NODE)
836 #define node_to_cpumask(i) (*(cpumask_of_node(i)))
837 #define HAVE_NODE_TO_CPUMASK
844 # define NO_QUOTA (-EDQUOT)
847 #if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
848 # define ext2_set_bit __test_and_set_bit_le
849 # define ext2_clear_bit __test_and_clear_bit_le
850 # define ext2_test_bit test_bit_le
851 # define ext2_find_first_zero_bit find_first_zero_bit_le
852 # define ext2_find_next_zero_bit find_next_zero_bit_le
855 #ifdef ATTR_TIMES_SET
856 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
858 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET)
861 #ifndef HAVE_SELINUX_IS_ENABLED
862 static inline bool selinux_is_enabled(void)
868 #endif /* __KERNEL__ */
869 #endif /* _COMPAT25_H */