4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Whamcloud, Inc.
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
40 #include <linux/fs_struct.h>
41 #include <linux/namei.h>
42 #include <libcfs/linux/portals_compat25.h>
44 #include <linux/lustre_patchless_compat.h>
46 #ifdef HAVE_FS_STRUCT_RWLOCK
47 # define LOCK_FS_STRUCT(fs) write_lock(&(fs)->lock)
48 # define UNLOCK_FS_STRUCT(fs) write_unlock(&(fs)->lock)
50 # define LOCK_FS_STRUCT(fs) spin_lock(&(fs)->lock)
51 # define UNLOCK_FS_STRUCT(fs) spin_unlock(&(fs)->lock)
54 #ifdef HAVE_FS_STRUCT_USE_PATH
55 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
56 struct dentry *dentry)
75 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
76 struct dentry *dentry)
78 struct dentry *old_pwd;
79 struct vfsmount *old_pwdmnt;
83 old_pwdmnt = fs->pwdmnt;
84 fs->pwdmnt = mntget(mnt);
85 fs->pwd = dget(dentry);
96 * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
97 * ATTR_* attributes (see bug 13828)
99 #define ATTR_BLOCKS (1 << 27)
101 #define current_ngroups current_cred()->group_info->ngroups
102 #define current_groups current_cred()->group_info->small_block
105 * OBD need working random driver, thus all our
106 * initialization routines must be called after device
107 * driver initialization
111 #define module_init(a) late_initcall(a)
114 #ifndef HAVE_TRYLOCK_PAGE
115 #define trylock_page(page) (!TestSetPageLocked(page))
118 #define LTIME_S(time) (time.tv_sec)
120 #ifdef HAVE_EXPORT_INODE_PERMISSION
121 #define ll_permission(inode,mask,nd) inode_permission(inode,mask)
123 #define ll_permission(inode,mask,nd) permission(inode,mask,nd)
126 #ifdef HAVE_GENERIC_PERMISSION_2ARGS
127 # define ll_generic_permission(inode, mask, flags, check_acl) \
128 generic_permission(inode, mask)
129 #elif defined HAVE_GENERIC_PERMISSION_4ARGS
130 # define ll_generic_permission(inode, mask, flags, check_acl) \
131 generic_permission(inode, mask, flags, check_acl)
133 # define ll_generic_permission(inode, mask, flags, check_acl) \
134 generic_permission(inode, mask, check_acl)
137 #ifdef HAVE_BLKDEV_PUT_2ARGS
138 #define ll_blkdev_put(a, b) blkdev_put(a, b)
140 #define ll_blkdev_put(a, b) blkdev_put(a)
143 #ifdef HAVE_DENTRY_OPEN_4ARGS
144 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
146 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
149 #ifdef HAVE_SECURITY_PLUG
150 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
151 vfs_symlink(dir, dentry, mnt, path, mode)
153 #ifdef HAVE_4ARGS_VFS_SYMLINK
154 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
155 vfs_symlink(dir, dentry, path, mode)
157 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
158 vfs_symlink(dir, dentry, path)
163 #ifdef HAVE_INODE_DIO_WAIT
164 /* inode_dio_wait(i) use as-is for write lock */
165 # define inode_dio_write_done(i) do {} while (0) /* for write unlock */
166 # define inode_dio_read(i) atomic_inc(&(i)->i_dio_count)
167 /* inode_dio_done(i) use as-is for read unlock */
169 # define inode_dio_wait(i) down_write(&(i)->i_alloc_sem)
170 # define inode_dio_write_done(i) up_write(&(i)->i_alloc_sem)
171 # define inode_dio_read(i) down_read(&(i)->i_alloc_sem)
172 # define inode_dio_done(i) up_read(&(i)->i_alloc_sem)
175 #ifdef HAVE_HIDE_VFSMOUNT_GUTS
176 # include <../fs/mount.h>
178 # define real_mount(mnt) (mnt)
181 static inline const char *mnt_get_devname(struct vfsmount *mnt)
183 return real_mount(mnt)->mnt_devname;
186 #ifndef HAVE_ATOMIC_MNT_COUNT
187 static inline unsigned int mnt_get_count(struct vfsmount *mnt)
190 unsigned int count = 0;
193 for_each_possible_cpu(cpu) {
194 count += per_cpu_ptr(real_mount(mnt)->mnt_pcp, cpu)->mnt_count;
199 return real_mount(mnt)->mnt_count;
203 # define mnt_get_count(mnt) cfs_atomic_read(&(real_mount(mnt)->mnt_count))
206 #ifdef HAVE_RW_TREE_LOCK
207 #define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock)
208 #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
210 #define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock)
211 #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock)
214 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
215 #define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b))
218 int ll_unregister_blkdev(unsigned int dev, const char *name)
220 unregister_blkdev(dev, name);
225 #ifdef HAVE_INVALIDATE_BDEV_2ARG
226 #define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b))
228 #define ll_invalidate_bdev(a,b) invalidate_bdev((a))
231 #ifndef FS_HAS_FIEMAP
232 #define FS_HAS_FIEMAP (0)
235 #ifndef HAVE_FS_RENAME_DOES_D_MOVE
236 #define FS_RENAME_DOES_D_MOVE FS_ODD_RENAME
239 #ifndef HAVE_D_OBTAIN_ALIAS
240 /* The old d_alloc_anon() didn't free the inode reference on error
241 * like d_obtain_alias(). Hide that difference/inconvenience here. */
242 static inline struct dentry *d_obtain_alias(struct inode *inode)
244 struct dentry *anon = d_alloc_anon(inode);
248 anon = ERR_PTR(-ENOMEM);
255 /* add a lustre compatible layer for crypto API */
256 #include <linux/crypto.h>
257 #ifdef HAVE_ASYNC_BLOCK_CIPHER
258 #define ll_crypto_hash crypto_hash
259 #define ll_crypto_cipher crypto_blkcipher
260 #define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask)
261 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen)
262 #define ll_crypto_hash_init(desc) crypto_hash_init(desc)
263 #define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes)
264 #define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out)
265 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
266 crypto_blkcipher_setkey(tfm, key, keylen)
267 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
268 crypto_blkcipher_set_iv(tfm, src, len)
269 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
270 crypto_blkcipher_get_iv(tfm, dst, len)
271 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
272 crypto_blkcipher_encrypt(desc, dst, src, bytes)
273 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
274 crypto_blkcipher_decrypt(desc, dst, src, bytes)
275 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
276 crypto_blkcipher_encrypt_iv(desc, dst, src, bytes)
277 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
278 crypto_blkcipher_decrypt_iv(desc, dst, src, bytes)
281 struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char *name,
284 struct ll_crypto_cipher *rtn = crypto_alloc_blkcipher(name, type, mask);
286 return (rtn == NULL ? ERR_PTR(-ENOMEM) : rtn);
289 static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm,
290 u8 *key, unsigned int *keylen,
291 struct scatterlist *sg,
292 unsigned int size, u8 *result)
294 struct hash_desc desc;
298 rv = crypto_hash_setkey(desc.tfm, key, *keylen);
300 CERROR("failed to hash setkey: %d\n", rv);
303 return crypto_hash_digest(&desc, sg, size, result);
306 unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm)
308 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize;
311 unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
313 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
316 #define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm)
317 #define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm)
318 #define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm)
319 #define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm)
320 #define ll_crypto_free_hash(tfm) crypto_free_hash(tfm)
321 #define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm)
322 #else /* HAVE_ASYNC_BLOCK_CIPHER */
323 #include <linux/scatterlist.h>
324 #define ll_crypto_hash crypto_tfm
325 #define ll_crypto_cipher crypto_tfm
326 #ifndef HAVE_STRUCT_HASH_DESC
328 struct ll_crypto_hash *tfm;
332 #ifndef HAVE_STRUCT_BLKCIPHER_DESC
333 struct blkcipher_desc {
334 struct ll_crypto_cipher *tfm;
339 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
340 crypto_cipher_setkey(tfm, key, keylen)
341 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
342 crypto_cipher_set_iv(tfm, src, len)
343 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
344 crypto_cipher_get_iv(tfm, dst, len)
345 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
346 crypto_cipher_encrypt((desc)->tfm, dst, src, bytes)
347 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
348 crypto_cipher_decrypt((desc)->tfm, dst, src, bytes)
349 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
350 crypto_cipher_decrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
351 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
352 crypto_cipher_encrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
355 struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char * algname,
358 struct ll_crypto_cipher *rtn;
359 char buf[CRYPTO_MAX_ALG_NAME + 1];
360 const char *pan = algname;
363 if (strncmp("cbc(", algname, 4) == 0)
364 flag |= CRYPTO_TFM_MODE_CBC;
365 else if (strncmp("ecb(", algname, 4) == 0)
366 flag |= CRYPTO_TFM_MODE_ECB;
368 char *vp = strnchr(algname, CRYPTO_MAX_ALG_NAME, ')');
370 memcpy(buf, algname + 4, vp - algname - 4);
371 buf[vp - algname - 4] = '\0';
377 rtn = crypto_alloc_tfm(pan, flag);
378 return (rtn == NULL ? ERR_PTR(-ENOMEM) : rtn);
382 struct ll_crypto_hash *ll_crypto_alloc_hash(const char *alg, u32 type, u32 mask)
384 char buf[CRYPTO_MAX_ALG_NAME + 1];
385 const char *pan = alg;
387 if (strncmp("hmac(", alg, 5) == 0) {
388 char *vp = strnchr(alg, CRYPTO_MAX_ALG_NAME, ')');
390 memcpy(buf, alg+ 5, vp - alg- 5);
391 buf[vp - alg - 5] = 0x00;
395 return crypto_alloc_tfm(pan, 0);
397 static inline int ll_crypto_hash_init(struct hash_desc *desc)
399 crypto_digest_init(desc->tfm); return 0;
401 static inline int ll_crypto_hash_update(struct hash_desc *desc,
402 struct scatterlist *sg,
405 struct scatterlist *sl = sg;
408 * This way is very weakness. We must ensure that
409 * the sum of sg[0..i]->length isn't greater than nbytes.
410 * In the upstream kernel the crypto_hash_update() also
411 * via the nbytes computed the count of sg[...].
412 * The old style is more safely. but it gone.
414 for (count = 0; nbytes > 0; count ++, sl ++) {
415 nbytes -= sl->length;
417 crypto_digest_update(desc->tfm, sg, count); return 0;
419 static inline int ll_crypto_hash_final(struct hash_desc *desc, u8 *out)
421 crypto_digest_final(desc->tfm, out); return 0;
423 static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
424 u8 *key, unsigned int *keylen,
425 struct scatterlist *sg,
429 struct scatterlist *sl = sg;
431 for (count = 0; nbytes > 0; count ++, sl ++) {
432 nbytes -= sl->length;
434 crypto_hmac(tfm, key, keylen, sg, count, out);
438 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_digest_setkey(tfm, key, keylen)
439 #define ll_crypto_blkcipher_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
440 #define ll_crypto_blkcipher_ivsize(tfm) crypto_tfm_alg_ivsize(tfm)
441 #define ll_crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
442 #define ll_crypto_hash_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
443 #define ll_crypto_free_hash(tfm) crypto_free_tfm(tfm)
444 #define ll_crypto_free_blkcipher(tfm) crypto_free_tfm(tfm)
445 #define ll_crypto_tfm_alg_min_keysize crypto_tfm_alg_min_keysize
446 #define ll_crypto_tfm_alg_max_keysize crypto_tfm_alg_max_keysize
447 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
449 #ifdef HAVE_SECURITY_PLUG
450 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry,mnt)
451 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mnt,mode)
452 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,mnt,dir,new,mnt1)
453 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry,mnt)
454 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) \
455 vfs_mknod(dir,entry,mnt,mode,dev)
456 #define ll_security_inode_unlink(dir,entry,mnt) \
457 security_inode_unlink(dir,entry,mnt)
458 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
459 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
461 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry)
462 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode)
463 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new)
464 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry)
465 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev)
466 #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry)
467 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
468 vfs_rename(old,old_dir,new,new_dir)
469 #endif /* HAVE_SECURITY_PLUG */
471 #ifdef for_each_possible_cpu
472 #define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
473 #elif defined(for_each_cpu)
474 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
477 #ifdef HAVE_BIO_ENDIO_2ARG
478 #define cfs_bio_io_error(a,b) bio_io_error((a))
479 #define cfs_bio_endio(a,b,c) bio_endio((a),(c))
481 #define cfs_bio_io_error(a,b) bio_io_error((a),(b))
482 #define cfs_bio_endio(a,b,c) bio_endio((a),(b),(c))
485 #ifdef HAVE_FS_STRUCT_USE_PATH
486 #define cfs_fs_pwd(fs) ((fs)->pwd.dentry)
487 #define cfs_fs_mnt(fs) ((fs)->pwd.mnt)
488 #define cfs_path_put(nd) path_put(&(nd)->path)
490 #define cfs_fs_pwd(fs) ((fs)->pwd)
491 #define cfs_fs_mnt(fs) ((fs)->pwdmnt)
492 #define cfs_path_put(nd) path_release(nd)
495 #ifndef HAVE_SIMPLE_SETATTR
496 #define simple_setattr(dentry, ops) inode_setattr((dentry)->d_inode, ops)
499 #ifndef SLAB_DESTROY_BY_RCU
500 #define SLAB_DESTROY_BY_RCU 0
503 #ifndef HAVE_SB_HAS_QUOTA_ACTIVE
504 #define sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
507 #ifndef HAVE_SB_ANY_QUOTA_LOADED
508 # ifdef HAVE_SB_ANY_QUOTA_ACTIVE
509 # define sb_any_quota_loaded(sb) sb_any_quota_active(sb)
511 # define sb_any_quota_loaded(sb) sb_any_quota_enabled(sb)
516 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
520 if (sb->s_qcop->quota_on) {
521 #ifdef HAVE_QUOTA_ON_USE_PATH
524 rc = kern_path(name, LOOKUP_FOLLOW, &path);
528 rc = sb->s_qcop->quota_on(sb, off, ver
529 #ifdef HAVE_QUOTA_ON_USE_PATH
534 #ifdef HAVE_QUOTA_ON_5ARGS
538 #ifdef HAVE_QUOTA_ON_USE_PATH
547 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
549 if (sb->s_qcop->quota_off) {
550 return sb->s_qcop->quota_off(sb, off
551 #ifdef HAVE_QUOTA_OFF_3ARGS
560 #ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
561 #define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
564 #ifndef HAVE_VFS_DQ_OFF
565 # define ll_vfs_dq_init DQUOT_INIT
566 # define ll_vfs_dq_drop DQUOT_DROP
567 # define ll_vfs_dq_transfer DQUOT_TRANSFER
568 # define ll_vfs_dq_off(sb, remount) DQUOT_OFF(sb)
570 # define ll_vfs_dq_init vfs_dq_init
571 # define ll_vfs_dq_drop vfs_dq_drop
572 # define ll_vfs_dq_transfer vfs_dq_transfer
573 # define ll_vfs_dq_off(sb, remount) vfs_dq_off(sb, remount)
577 #define ll_bdi_init(bdi) bdi_init(bdi)
578 #define ll_bdi_destroy(bdi) bdi_destroy(bdi)
580 #define ll_bdi_init(bdi) 0
581 #define ll_bdi_destroy(bdi) do { } while(0)
584 #ifdef HAVE_NEW_BACKING_DEV_INFO
585 # define ll_bdi_wb_cnt(bdi) ((bdi).wb_cnt)
587 # define ll_bdi_wb_cnt(bdi) 1
590 #ifdef HAVE_BLK_QUEUE_MAX_SECTORS /* removed in rhel6 */
591 #define blk_queue_max_hw_sectors(q, sect) blk_queue_max_sectors(q, sect)
594 #ifndef HAVE_BLKDEV_GET_BY_DEV
595 # define blkdev_get_by_dev(dev, mode, holder) open_by_devnum(dev, mode)
598 #ifndef HAVE_REQUEST_QUEUE_LIMITS
599 #define queue_max_sectors(rq) ((rq)->max_sectors)
600 #define queue_max_hw_sectors(rq) ((rq)->max_hw_sectors)
601 #define queue_max_phys_segments(rq) ((rq)->max_phys_segments)
602 #define queue_max_hw_segments(rq) ((rq)->max_hw_segments)
605 #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
606 #define blk_queue_max_segments(rq, seg) \
607 do { blk_queue_max_phys_segments(rq, seg); \
608 blk_queue_max_hw_segments(rq, seg); } while (0)
610 #define queue_max_phys_segments(rq) queue_max_segments(rq)
611 #define queue_max_hw_segments(rq) queue_max_segments(rq)
614 #ifdef HAVE_KMAP_ATOMIC_HAS_1ARG
615 #define ll_kmap_atomic(a, b) kmap_atomic(a)
616 #define ll_kunmap_atomic(a, b) kunmap_atomic(a)
618 #define ll_kmap_atomic(a, b) kmap_atomic(a, b)
619 #define ll_kunmap_atomic(a, b) kunmap_atomic(a, b)
622 #ifndef HAVE_CLEAR_INODE
623 #define clear_inode(i) end_writeback(i)
626 #ifdef HAVE_DENTRY_D_ALIAS_HLIST
627 #define ll_d_hlist_node hlist_node
628 #define ll_d_hlist_empty(list) hlist_empty(list)
629 #define ll_d_hlist_entry(ptr, type, name) hlist_entry(ptr.first, type, name)
630 #define ll_d_hlist_for_each(tmp, i_dentry) hlist_for_each(tmp, i_dentry)
631 #define ll_d_hlist_for_each_entry(dentry, p, i_dentry, alias) \
632 hlist_for_each_entry(dentry, p, i_dentry, alias)
634 #define ll_d_hlist_node list_head
635 #define ll_d_hlist_empty(list) list_empty(list)
636 #define ll_d_hlist_entry(ptr, type, name) list_entry(ptr.next, type, name)
637 #define ll_d_hlist_for_each(tmp, i_dentry) list_for_each(tmp, i_dentry)
638 #define ll_d_hlist_for_each_entry(dentry, p, i_dentry, alias) \
639 p = NULL; list_for_each_entry(dentry, i_dentry, alias)
643 #ifndef HAVE_BI_HW_SEGMENTS
644 #define bio_hw_segments(q, bio) 0
647 #ifndef HAVE_PAGEVEC_LRU_ADD_FILE
648 #define pagevec_lru_add_file pagevec_lru_add
651 #ifdef HAVE_ADD_TO_PAGE_CACHE_LRU
652 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
653 add_to_page_cache_lru(pg, mapping, off, gfp)
654 #define ll_pagevec_init(pv, cold) do {} while (0)
655 #define ll_pagevec_add(pv, pg) (0)
656 #define ll_pagevec_lru_add_file(pv) do {} while (0)
658 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
659 add_to_page_cache(pg, mapping, off, gfp)
660 #define ll_pagevec_init(pv, cold) pagevec_init(&lru_pvec, cold);
661 #define ll_pagevec_add(pv, pg) \
665 page_cache_get(pg); \
666 __ret = pagevec_add(pv, pg); \
668 #define ll_pagevec_lru_add_file(pv) pagevec_lru_add_file(pv)
671 #if !defined(HAVE_NODE_TO_CPUMASK) && defined(HAVE_CPUMASK_OF_NODE)
672 #define node_to_cpumask(i) (*(cpumask_of_node(i)))
673 #define HAVE_NODE_TO_CPUMASK
680 # define NO_QUOTA (-EDQUOT)
683 #if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
684 # define ext2_set_bit __test_and_set_bit_le
685 # define ext2_clear_bit __test_and_clear_bit_le
686 # define ext2_test_bit test_bit_le
687 # define ext2_find_first_zero_bit find_first_zero_bit_le
688 # define ext2_find_next_zero_bit find_next_zero_bit_le
691 #ifdef ATTR_TIMES_SET
692 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
694 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET)
697 #ifndef HAVE_SELINUX_IS_ENABLED
698 static inline bool selinux_is_enabled(void)
704 #ifndef HAVE_LM_XXX_LOCK_MANAGER_OPS
705 # define lm_compare_owner fl_compare_owner
709 * After 3.1, kernel's nameidata.intent.open.flags is different
710 * with lustre's lookup_intent.it_flags, as lustre's it_flags'
711 * lower bits equal to FMODE_xxx while kernel doesn't transliterate
712 * lower bits of nameidata.intent.open.flags to FMODE_xxx.
714 #include <linux/version.h>
715 static inline int ll_namei_to_lookup_intent_flag(int flag)
717 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
718 flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
723 #ifdef HAVE_VOID_MAKE_REQUEST_FN
724 # define ll_mrf_ret void
725 # define LL_MRF_RETURN(rc)
727 # define ll_mrf_ret int
728 # define LL_MRF_RETURN(rc) RETURN(rc)
731 #include <linux/fs.h>
732 #ifndef HAVE_PROTECT_I_NLINK
733 static inline void set_nlink(struct inode *inode, unsigned int nlink)
735 inode->i_nlink = nlink;
739 #ifdef HAVE_INODEOPS_USE_UMODE_T
740 # define ll_umode_t umode_t
742 # define ll_umode_t int
745 #include <linux/dcache.h>
746 #ifndef HAVE_D_MAKE_ROOT
747 static inline struct dentry *d_make_root(struct inode *root)
749 struct dentry *res = d_alloc_root(root);
751 if (res == NULL && root)
758 #endif /* _COMPAT25_H */