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 */
142 #define LL_SEQ_LOCK(seq) cfs_mutex_lock(&(seq)->lock)
143 #define LL_SEQ_UNLOCK(seq) cfs_mutex_unlock(&(seq)->lock)
145 #define LL_SEQ_LOCK(seq) cfs_down(&(seq)->sem)
146 #define LL_SEQ_UNLOCK(seq) cfs_up(&(seq)->sem)
149 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
150 #define d_child d_u.d_child
151 #define d_rcu d_u.d_rcu
154 #ifdef HAVE_DQUOTOFF_MUTEX
155 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_unlock(&(dqopt)->dqonoff_mutex)
156 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_mutex_lock(&(dqopt)->dqonoff_mutex)
158 #define UNLOCK_DQONOFF_MUTEX(dqopt) cfs_up(&(dqopt)->dqonoff_sem)
159 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
160 #endif /* HAVE_DQUOTOFF_MUTEX */
162 #define current_ngroups current_cred()->group_info->ngroups
163 #define current_groups current_cred()->group_info->small_block
166 #define page_private(page) ((page)->private)
167 #define set_page_private(page, v) ((page)->private = (v))
174 #define lock_dentry(___dentry) cfs_spin_lock(&(___dentry)->d_lock)
175 #define unlock_dentry(___dentry) cfs_spin_unlock(&(___dentry)->d_lock)
177 #define ll_kernel_locked() kernel_locked()
180 * OBD need working random driver, thus all our
181 * initialization routines must be called after device
182 * driver initialization
186 #define module_init(a) late_initcall(a)
189 /* XXX our code should be using the 2.6 calls, not the other way around */
190 #ifdef HAVE_TRYLOCK_PAGE
191 #define TestSetPageLocked(page) (!trylock_page(page))
194 #define Page_Uptodate(page) PageUptodate(page)
195 #define ll_redirty_page(page) set_page_dirty(page)
197 #define KDEVT_INIT(val) (val)
199 #define LTIME_S(time) (time.tv_sec)
200 #define ll_path_lookup path_lookup
202 #ifdef HAVE_EXPORT_INODE_PERMISSION
203 #define ll_permission(inode,mask,nd) inode_permission(inode,mask)
205 #define ll_permission(inode,mask,nd) permission(inode,mask,nd)
208 #ifdef HAVE_GENERIC_PERMISSION_4ARGS
209 #define ll_generic_permission(inode, mask, flags, check_acl) \
210 generic_permission(inode, mask, flags, check_acl)
212 #define ll_generic_permission(inode, mask, flags, check_acl) \
213 generic_permission(inode, mask, check_acl)
216 #define ll_pgcache_lock(mapping) cfs_spin_lock(&mapping->page_lock)
217 #define ll_pgcache_unlock(mapping) cfs_spin_unlock(&mapping->page_lock)
218 #define ll_call_writepage(inode, page) \
219 (inode)->i_mapping->a_ops->writepage(page, NULL)
220 #define ll_invalidate_inode_pages(inode) \
221 invalidate_inode_pages((inode)->i_mapping)
223 #define ll_vfs_create(a,b,c,d) vfs_create(a,b,c,d)
224 #define ll_dev_t dev_t
226 #define to_kdev_t(dev) (dev)
227 #define kdev_t_to_nr(dev) (dev)
228 #define val_to_kdev(dev) (dev)
230 #ifdef HAVE_BLKDEV_PUT_2ARGS
231 #define ll_blkdev_put(a, b) blkdev_put(a, b)
233 #define ll_blkdev_put(a, b) blkdev_put(a)
236 #ifdef HAVE_DENTRY_OPEN_4ARGS
237 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
239 #define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
242 #include <linux/writeback.h>
244 static inline int cfs_cleanup_group_info(void)
246 struct group_info *ginfo;
248 ginfo = groups_alloc(0);
252 set_current_groups(ginfo);
253 put_group_info(ginfo);
258 #define __set_page_ll_data(page, llap) \
260 page_cache_get(page); \
261 SetPagePrivate(page); \
262 set_page_private(page, (unsigned long)llap); \
264 #define __clear_page_ll_data(page) \
266 ClearPagePrivate(page); \
267 set_page_private(page, 0); \
268 page_cache_release(page); \
273 #include <linux/proc_fs.h>
275 #if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
276 #define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
277 extern void __d_rehash(struct dentry *dentry, int lock);
280 #ifdef HAVE_CAN_SLEEP_ARG
281 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
282 flock_lock_file_wait(file, lock, can_sleep)
284 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
285 flock_lock_file_wait(file, lock)
288 #define CheckWriteback(page, cmd) \
289 ((!PageWriteback(page) && (cmd & OBD_BRW_READ)) || \
290 (PageWriteback(page) && (cmd & OBD_BRW_WRITE)))
292 #ifdef HAVE_PAGE_LIST
293 static inline int mapping_has_pages(struct address_space *mapping)
297 ll_pgcache_lock(mapping);
298 if (cfs_list_empty(&mapping->dirty_pages) &&
299 cfs_list_empty(&mapping->clean_pages) &&
300 cfs_list_empty(&mapping->locked_pages)) {
303 ll_pgcache_unlock(mapping);
308 static inline int mapping_has_pages(struct address_space *mapping)
310 return mapping->nrpages > 0;
314 #ifdef HAVE_KIOBUF_KIO_BLOCKS
315 #define KIOBUF_GET_BLOCKS(k) ((k)->kio_blocks)
317 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
320 #ifdef HAVE_SECURITY_PLUG
321 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
322 vfs_symlink(dir, dentry, mnt, path, mode)
324 #ifdef HAVE_4ARGS_VFS_SYMLINK
325 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
326 vfs_symlink(dir, dentry, path, mode)
328 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
329 vfs_symlink(dir, dentry, path)
332 #define ll_set_dflags(dentry, flags) do { \
333 cfs_spin_lock(&dentry->d_lock); \
334 dentry->d_flags |= flags; \
335 cfs_spin_unlock(&dentry->d_lock); \
340 #define container_of(ptr, type, member) ({ \
341 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
342 (type *)( (char *)__mptr - offsetof(type,member) );})
345 #define UP_WRITE_I_ALLOC_SEM(i) up_write(&(i)->i_alloc_sem)
346 #define DOWN_WRITE_I_ALLOC_SEM(i) down_write(&(i)->i_alloc_sem)
347 #define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
349 #define UP_READ_I_ALLOC_SEM(i) up_read(&(i)->i_alloc_sem)
350 #define DOWN_READ_I_ALLOC_SEM(i) down_read(&(i)->i_alloc_sem)
351 #define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
353 #ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
354 #define grab_cache_page_nowait_gfp(x, y, z) grab_cache_page_nowait((x), (y))
357 #include <linux/mpage.h> /* for generic_writepages */
358 #ifndef HAVE_FILEMAP_FDATAWRITE_RANGE
359 #include <linux/backing-dev.h> /* for mapping->backing_dev_info */
360 static inline int filemap_fdatawrite_range(struct address_space *mapping,
361 loff_t start, loff_t end)
364 struct writeback_control wbc = {
365 .sync_mode = WB_SYNC_ALL,
366 .nr_to_write = (end - start + PAGE_SIZE - 1) >> PAGE_SHIFT,
369 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
370 wbc.range_start = start;
377 #ifdef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
378 if (!mapping_cap_writeback_dirty(mapping))
381 if (mapping->backing_dev_info->memory_backed)
384 /* do_writepages() */
385 else if (mapping->a_ops->writepages)
386 rc = mapping->a_ops->writepages(mapping, &wbc);
388 rc = generic_writepages(mapping, &wbc);
392 int filemap_fdatawrite_range(struct address_space *mapping,
393 loff_t start, loff_t end);
394 #endif /* HAVE_FILEMAP_FDATAWRITE_RANGE */
396 #ifdef HAVE_VFS_KERN_MOUNT
397 static inline struct vfsmount *
398 ll_kern_mount(const char *fstype, int flags, const char *name, void *data)
400 struct file_system_type *type = get_fs_type(fstype);
401 struct vfsmount *mnt;
403 return ERR_PTR(-ENODEV);
404 mnt = vfs_kern_mount(type, flags, name, data);
405 cfs_module_put(type->owner);
409 #define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data))
412 #ifndef HAVE_ATOMIC_MNT_COUNT
413 static inline unsigned int mnt_get_count(struct vfsmount *mnt)
416 unsigned int count = 0;
419 for_each_possible_cpu(cpu) {
420 count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count;
425 return mnt->mnt_count;
429 # define mnt_get_count(mnt) cfs_atomic_read(&mnt->mnt_count)
432 #ifdef HAVE_STATFS_DENTRY_PARAM
433 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
435 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
438 #ifndef HAVE_SB_TIME_GRAN
439 #ifndef HAVE_S_TIME_GRAN
440 #error Need s_time_gran patch!
442 static inline u32 get_sb_time_gran(struct super_block *sb)
444 return sb->s_time_gran;
448 #ifdef HAVE_RW_TREE_LOCK
449 #define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock)
450 #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
452 #define TREE_READ_LOCK_IRQ(mapping) cfs_spin_lock_irq(&(mapping)->tree_lock)
453 #define TREE_READ_UNLOCK_IRQ(mapping) cfs_spin_unlock_irq(&(mapping)->tree_lock)
456 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
457 #define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b))
460 int ll_unregister_blkdev(unsigned int dev, const char *name)
462 unregister_blkdev(dev, name);
467 #ifdef HAVE_INVALIDATE_BDEV_2ARG
468 #define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b))
470 #define ll_invalidate_bdev(a,b) invalidate_bdev((a))
473 #ifdef HAVE_INODE_BLKSIZE
474 #define ll_inode_blksize(a) (a)->i_blksize
476 #define ll_inode_blksize(a) (1<<(a)->i_blkbits)
479 #ifdef HAVE_FS_RENAME_DOES_D_MOVE
480 #define LL_RENAME_DOES_D_MOVE FS_RENAME_DOES_D_MOVE
482 #define LL_RENAME_DOES_D_MOVE FS_ODD_RENAME
485 #ifndef HAVE_D_OBTAIN_ALIAS
486 /* The old d_alloc_anon() didn't free the inode reference on error
487 * like d_obtain_alias(). Hide that difference/inconvenience here. */
488 static inline struct dentry *d_obtain_alias(struct inode *inode)
490 struct dentry *anon = d_alloc_anon(inode);
494 anon = ERR_PTR(-ENOMEM);
501 /* add a lustre compatible layer for crypto API */
502 #include <linux/crypto.h>
503 #ifdef HAVE_ASYNC_BLOCK_CIPHER
504 #define ll_crypto_hash crypto_hash
505 #define ll_crypto_cipher crypto_blkcipher
506 #define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask)
507 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen)
508 #define ll_crypto_hash_init(desc) crypto_hash_init(desc)
509 #define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes)
510 #define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out)
511 #define ll_crypto_alloc_blkcipher(name, type, mask) \
512 crypto_alloc_blkcipher(name ,type, mask)
513 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
514 crypto_blkcipher_setkey(tfm, key, keylen)
515 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
516 crypto_blkcipher_set_iv(tfm, src, len)
517 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
518 crypto_blkcipher_get_iv(tfm, dst, len)
519 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
520 crypto_blkcipher_encrypt(desc, dst, src, bytes)
521 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
522 crypto_blkcipher_decrypt(desc, dst, src, bytes)
523 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
524 crypto_blkcipher_encrypt_iv(desc, dst, src, bytes)
525 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
526 crypto_blkcipher_decrypt_iv(desc, dst, src, bytes)
528 static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm,
529 u8 *key, unsigned int *keylen,
530 struct scatterlist *sg,
531 unsigned int size, u8 *result)
533 struct hash_desc desc;
537 rv = crypto_hash_setkey(desc.tfm, key, *keylen);
539 CERROR("failed to hash setkey: %d\n", rv);
542 return crypto_hash_digest(&desc, sg, size, result);
545 unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm)
547 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize;
550 unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
552 return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
555 #define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm)
556 #define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm)
557 #define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm)
558 #define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm)
559 #define ll_crypto_free_hash(tfm) crypto_free_hash(tfm)
560 #define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm)
561 #else /* HAVE_ASYNC_BLOCK_CIPHER */
562 #include <linux/scatterlist.h>
563 #define ll_crypto_hash crypto_tfm
564 #define ll_crypto_cipher crypto_tfm
565 #ifndef HAVE_STRUCT_HASH_DESC
567 struct ll_crypto_hash *tfm;
571 #ifndef HAVE_STRUCT_BLKCIPHER_DESC
572 struct blkcipher_desc {
573 struct ll_crypto_cipher *tfm;
578 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
579 crypto_cipher_setkey(tfm, key, keylen)
580 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
581 crypto_cipher_set_iv(tfm, src, len)
582 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
583 crypto_cipher_get_iv(tfm, dst, len)
584 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
585 crypto_cipher_encrypt((desc)->tfm, dst, src, bytes)
586 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
587 crypto_cipher_decrypt((desc)->tfm, dst, src, bytes)
588 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
589 crypto_cipher_decrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
590 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
591 crypto_cipher_encrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
594 struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char * algname,
597 char buf[CRYPTO_MAX_ALG_NAME + 1];
598 const char *pan = algname;
601 if (strncmp("cbc(", algname, 4) == 0)
602 flag |= CRYPTO_TFM_MODE_CBC;
603 else if (strncmp("ecb(", algname, 4) == 0)
604 flag |= CRYPTO_TFM_MODE_ECB;
606 char *vp = strnchr(algname, CRYPTO_MAX_ALG_NAME, ')');
608 memcpy(buf, algname + 4, vp - algname - 4);
609 buf[vp - algname - 4] = '\0';
615 return crypto_alloc_tfm(pan, flag);
619 struct ll_crypto_hash *ll_crypto_alloc_hash(const char *alg, u32 type, u32 mask)
621 char buf[CRYPTO_MAX_ALG_NAME + 1];
622 const char *pan = alg;
624 if (strncmp("hmac(", alg, 5) == 0) {
625 char *vp = strnchr(alg, CRYPTO_MAX_ALG_NAME, ')');
627 memcpy(buf, alg+ 5, vp - alg- 5);
628 buf[vp - alg - 5] = 0x00;
632 return crypto_alloc_tfm(pan, 0);
634 static inline int ll_crypto_hash_init(struct hash_desc *desc)
636 crypto_digest_init(desc->tfm); return 0;
638 static inline int ll_crypto_hash_update(struct hash_desc *desc,
639 struct scatterlist *sg,
642 struct scatterlist *sl = sg;
645 * This way is very weakness. We must ensure that
646 * the sum of sg[0..i]->length isn't greater than nbytes.
647 * In the upstream kernel the crypto_hash_update() also
648 * via the nbytes computed the count of sg[...].
649 * The old style is more safely. but it gone.
651 for (count = 0; nbytes > 0; count ++, sl ++) {
652 nbytes -= sl->length;
654 crypto_digest_update(desc->tfm, sg, count); return 0;
656 static inline int ll_crypto_hash_final(struct hash_desc *desc, u8 *out)
658 crypto_digest_final(desc->tfm, out); return 0;
660 static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
661 u8 *key, unsigned int *keylen,
662 struct scatterlist *sg,
666 struct scatterlist *sl = sg;
668 for (count = 0; nbytes > 0; count ++, sl ++) {
669 nbytes -= sl->length;
671 crypto_hmac(tfm, key, keylen, sg, count, out);
675 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_digest_setkey(tfm, key, keylen)
676 #define ll_crypto_blkcipher_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
677 #define ll_crypto_blkcipher_ivsize(tfm) crypto_tfm_alg_ivsize(tfm)
678 #define ll_crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
679 #define ll_crypto_hash_blocksize(tfm) crypto_tfm_alg_blocksize(tfm)
680 #define ll_crypto_free_hash(tfm) crypto_free_tfm(tfm)
681 #define ll_crypto_free_blkcipher(tfm) crypto_free_tfm(tfm)
682 #define ll_crypto_tfm_alg_min_keysize crypto_tfm_alg_min_keysize
683 #define ll_crypto_tfm_alg_max_keysize crypto_tfm_alg_max_keysize
684 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
686 #ifdef HAVE_FILE_REMOVE_SUID
687 # define ll_remove_suid(file, mnt) file_remove_suid(file)
689 # ifdef HAVE_SECURITY_PLUG
690 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry,mnt)
692 # define ll_remove_suid(file,mnt) remove_suid(file->f_dentry)
696 #ifdef HAVE_SECURITY_PLUG
697 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry,mnt)
698 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mnt,mode)
699 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,mnt,dir,new,mnt1)
700 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry,mnt)
701 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) \
702 vfs_mknod(dir,entry,mnt,mode,dev)
703 #define ll_security_inode_unlink(dir,entry,mnt) \
704 security_inode_unlink(dir,entry,mnt)
705 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
706 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
708 #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry)
709 #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode)
710 #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new)
711 #define ll_vfs_unlink(inode,entry,mnt) vfs_unlink(inode,entry)
712 #define ll_vfs_mknod(dir,entry,mnt,mode,dev) vfs_mknod(dir,entry,mode,dev)
713 #define ll_security_inode_unlink(dir,entry,mnt) security_inode_unlink(dir,entry)
714 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
715 vfs_rename(old,old_dir,new,new_dir)
716 #endif /* HAVE_SECURITY_PLUG */
718 #ifdef for_each_possible_cpu
719 #define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
720 #elif defined(for_each_cpu)
721 #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
724 #ifdef HAVE_BIO_ENDIO_2ARG
725 #define cfs_bio_io_error(a,b) bio_io_error((a))
726 #define cfs_bio_endio(a,b,c) bio_endio((a),(c))
728 #define cfs_bio_io_error(a,b) bio_io_error((a),(b))
729 #define cfs_bio_endio(a,b,c) bio_endio((a),(b),(c))
732 #ifdef HAVE_FS_STRUCT_USE_PATH
733 #define cfs_fs_pwd(fs) ((fs)->pwd.dentry)
734 #define cfs_fs_mnt(fs) ((fs)->pwd.mnt)
735 #define cfs_path_put(nd) path_put(&(nd)->path)
737 #define cfs_fs_pwd(fs) ((fs)->pwd)
738 #define cfs_fs_mnt(fs) ((fs)->pwdmnt)
739 #define cfs_path_put(nd) path_release(nd)
743 static inline int abs(int x)
745 return (x < 0) ? -x : x;
750 static inline long labs(long x)
752 return (x < 0) ? -x : x;
754 #endif /* HAVE_REGISTER_SHRINKER */
756 #ifdef HAVE_INVALIDATE_INODE_PAGES
757 #define invalidate_mapping_pages(mapping,s,e) invalidate_inode_pages(mapping)
760 #ifdef HAVE_INODE_IPRIVATE
761 #define INODE_PRIVATE_DATA(inode) ((inode)->i_private)
763 #define INODE_PRIVATE_DATA(inode) ((inode)->u.generic_ip)
766 #ifndef HAVE_SIMPLE_SETATTR
767 #define simple_setattr(dentry, ops) inode_setattr((dentry)->d_inode, ops)
770 #ifndef SLAB_DESTROY_BY_RCU
771 #define CFS_SLAB_DESTROY_BY_RCU 0
773 #define CFS_SLAB_DESTROY_BY_RCU SLAB_DESTROY_BY_RCU
776 #ifdef HAVE_SB_HAS_QUOTA_ACTIVE
777 #define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type)
779 #define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
782 #ifdef HAVE_SB_ANY_QUOTA_LOADED
783 #define ll_sb_any_quota_active(sb) sb_any_quota_loaded(sb)
784 #elif defined(HAVE_SB_ANY_QUOTA_ACTIVE)
785 #define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
787 #define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
791 ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
795 if (sb->s_qcop->quota_on) {
796 #ifdef HAVE_QUOTA_ON_USE_PATH
799 rc = kern_path(name, LOOKUP_FOLLOW, &path);
803 rc = sb->s_qcop->quota_on(sb, off, ver
804 #ifdef HAVE_QUOTA_ON_USE_PATH
809 #ifdef HAVE_QUOTA_ON_5ARGS
813 #ifdef HAVE_QUOTA_ON_USE_PATH
822 static inline int ll_quota_off(struct super_block *sb, int off, int remount)
824 if (sb->s_qcop->quota_off) {
825 return sb->s_qcop->quota_off(sb, off
826 #ifdef HAVE_QUOTA_OFF_3ARGS
835 #ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
836 #define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
839 #ifndef HAVE_VFS_DQ_OFF
840 # define ll_vfs_dq_init DQUOT_INIT
841 # define ll_vfs_dq_drop DQUOT_DROP
842 # define ll_vfs_dq_transfer DQUOT_TRANSFER
843 # define ll_vfs_dq_off(sb, remount) DQUOT_OFF(sb)
845 # define ll_vfs_dq_init vfs_dq_init
846 # define ll_vfs_dq_drop vfs_dq_drop
847 # define ll_vfs_dq_transfer vfs_dq_transfer
848 # define ll_vfs_dq_off(sb, remount) vfs_dq_off(sb, remount)
852 #define ll_bdi_init(bdi) bdi_init(bdi)
853 #define ll_bdi_destroy(bdi) bdi_destroy(bdi)
855 #define ll_bdi_init(bdi) 0
856 #define ll_bdi_destroy(bdi) do { } while(0)
859 #ifdef HAVE_NEW_BACKING_DEV_INFO
860 # define ll_bdi_wb_cnt(bdi) ((bdi).wb_cnt)
862 # define ll_bdi_wb_cnt(bdi) 1
865 #ifdef HAVE_BLK_QUEUE_MAX_SECTORS /* removed in rhel6 */
866 #define blk_queue_max_hw_sectors(q, sect) blk_queue_max_sectors(q, sect)
869 #ifndef HAVE_BLKDEV_GET_BY_DEV
870 # define blkdev_get_by_dev(dev, mode, holder) open_by_devnum(dev, mode)
873 #ifndef HAVE_REQUEST_QUEUE_LIMITS
874 #define queue_max_sectors(rq) ((rq)->max_sectors)
875 #define queue_max_hw_sectors(rq) ((rq)->max_hw_sectors)
876 #define queue_max_phys_segments(rq) ((rq)->max_phys_segments)
877 #define queue_max_hw_segments(rq) ((rq)->max_hw_segments)
880 #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
881 #define blk_queue_max_segments(rq, seg) \
882 do { blk_queue_max_phys_segments(rq, seg); \
883 blk_queue_max_hw_segments(rq, seg); } while (0)
885 #define queue_max_phys_segments(rq) queue_max_segments(rq)
886 #define queue_max_hw_segments(rq) queue_max_segments(rq)
890 #ifndef HAVE_BI_HW_SEGMENTS
891 #define bio_hw_segments(q, bio) 0
894 #ifndef HAVE_PAGEVEC_LRU_ADD_FILE
895 #define pagevec_lru_add_file pagevec_lru_add
898 #ifdef HAVE_ADD_TO_PAGE_CACHE_LRU
899 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
900 add_to_page_cache_lru(pg, mapping, off, gfp)
901 #define ll_pagevec_init(pv, cold) do {} while (0)
902 #define ll_pagevec_add(pv, pg) (0)
903 #define ll_pagevec_lru_add_file(pv) do {} while (0)
905 #define ll_add_to_page_cache_lru(pg, mapping, off, gfp) \
906 add_to_page_cache(pg, mapping, off, gfp)
907 #define ll_pagevec_init(pv, cold) pagevec_init(&lru_pvec, cold);
908 #define ll_pagevec_add(pv, pg) pagevec_add(pv, pg)
909 #define ll_pagevec_lru_add_file(pv) pagevec_lru_add_file(pv)
912 #if !defined(HAVE_NODE_TO_CPUMASK) && defined(HAVE_CPUMASK_OF_NODE)
913 #define node_to_cpumask(i) (*(cpumask_of_node(i)))
914 #define HAVE_NODE_TO_CPUMASK
921 # define NO_QUOTA (-EDQUOT)
924 #if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
925 # define ext2_set_bit __test_and_set_bit_le
926 # define ext2_clear_bit __test_and_clear_bit_le
927 # define ext2_test_bit test_bit_le
928 # define ext2_find_first_zero_bit find_first_zero_bit_le
929 # define ext2_find_next_zero_bit find_next_zero_bit_le
932 #ifdef ATTR_TIMES_SET
933 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
935 # define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET)
938 #endif /* __KERNEL__ */
939 #endif /* _COMPAT25_H */