Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / include / linux / lustre_compat25.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef _LINUX_COMPAT25_H
24 #define _LINUX_COMPAT25_H
25
26 #ifdef __KERNEL__
27
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
29 #error sorry, lustre requires at least linux kernel 2.6.9 or later
30 #endif
31
32 #include <libcfs/linux/portals_compat25.h>
33
34 #include <linux/lustre_patchless_compat.h>
35
36 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
37 struct ll_iattr {
38         struct iattr    iattr;
39         unsigned int    ia_attr_flags;
40 };
41 #else
42 #define ll_iattr iattr
43 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
44
45 #ifndef HAVE_SET_FS_PWD
46 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
47                 struct dentry *dentry)
48 {
49         struct dentry *old_pwd;
50         struct vfsmount *old_pwdmnt;
51
52         write_lock(&fs->lock);
53         old_pwd = fs->pwd;
54         old_pwdmnt = fs->pwdmnt;
55         fs->pwdmnt = mntget(mnt);
56         fs->pwd = dget(dentry);
57         write_unlock(&fs->lock);
58
59         if (old_pwd) {
60                 dput(old_pwd);
61                 mntput(old_pwdmnt);
62         }
63 }
64 #else
65 #define ll_set_fs_pwd set_fs_pwd
66 #endif /* HAVE_SET_FS_PWD */
67
68 /*
69  * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
70  * ATTR_* attributes (see bug 13828)
71  */
72 #define ATTR_BLOCKS    (1 << 27)
73
74 #if HAVE_INODE_I_MUTEX
75 #define UNLOCK_INODE_MUTEX(inode) do {mutex_unlock(&(inode)->i_mutex); } while(0)
76 #define LOCK_INODE_MUTEX(inode) do {mutex_lock(&(inode)->i_mutex); } while(0)
77 #define TRYLOCK_INODE_MUTEX(inode) mutex_trylock(&(inode)->i_mutex)
78 #else
79 #define UNLOCK_INODE_MUTEX(inode) do {up(&(inode)->i_sem); } while(0)
80 #define LOCK_INODE_MUTEX(inode) do {down(&(inode)->i_sem); } while(0)
81 #define TRYLOCK_INODE_MUTEX(inode) (!down_trylock(&(inode)->i_sem))
82 #endif /* HAVE_INODE_I_MUTEX */
83
84 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
85 #define d_child d_u.d_child
86 #define d_rcu d_u.d_rcu
87 #endif
88
89 #ifdef HAVE_DQUOTOFF_MUTEX
90 #define UNLOCK_DQONOFF_MUTEX(dqopt) do {mutex_unlock(&(dqopt)->dqonoff_mutex); } while(0)
91 #define LOCK_DQONOFF_MUTEX(dqopt) do {mutex_lock(&(dqopt)->dqonoff_mutex); } while(0)
92 #else
93 #define UNLOCK_DQONOFF_MUTEX(dqopt) do {up(&(dqopt)->dqonoff_sem); } while(0)
94 #define LOCK_DQONOFF_MUTEX(dqopt) do {down(&(dqopt)->dqonoff_sem); } while(0)
95 #endif /* HAVE_DQUOTOFF_MUTEX */
96
97 #define current_ngroups current->group_info->ngroups
98 #define current_groups current->group_info->small_block
99
100 #ifndef page_private
101 #define page_private(page) ((page)->private)
102 #define set_page_private(page, v) ((page)->private = (v))
103 #endif
104
105 #ifndef HAVE_GFP_T
106 #define gfp_t int
107 #endif
108
109 #define lock_dentry(___dentry)          spin_lock(&(___dentry)->d_lock)
110 #define unlock_dentry(___dentry)        spin_unlock(&(___dentry)->d_lock)
111
112 #define ll_kernel_locked()      kernel_locked()
113
114 /*
115  * OBD need working random driver, thus all our
116  * initialization routines must be called after device
117  * driver initialization
118  */
119 #ifndef MODULE
120 #undef module_init
121 #define module_init(a)     late_initcall(a)
122 #endif
123
124 /* XXX our code should be using the 2.6 calls, not the other way around */
125 #define TryLockPage(page)               TestSetPageLocked(page)
126 #define Page_Uptodate(page)             PageUptodate(page)
127 #define ll_redirty_page(page)           set_page_dirty(page)
128
129 #define KDEVT_INIT(val)                 (val)
130
131 #define LTIME_S(time)                   (time.tv_sec)
132 #define ll_path_lookup                  path_lookup
133 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
134
135 #define ll_pgcache_lock(mapping)          spin_lock(&mapping->page_lock)
136 #define ll_pgcache_unlock(mapping)        spin_unlock(&mapping->page_lock)
137 #define ll_call_writepage(inode, page)  \
138                                 (inode)->i_mapping->a_ops->writepage(page, NULL)
139 #define ll_invalidate_inode_pages(inode) \
140                                 invalidate_inode_pages((inode)->i_mapping)
141 #define ll_truncate_complete_page(page) \
142                                 truncate_complete_page(page->mapping, page)
143
144 #define ll_vfs_create(a,b,c,d)          vfs_create(a,b,c,d)
145 #define ll_dev_t                        dev_t
146 #define kdev_t                          dev_t
147 #define to_kdev_t(dev)                  (dev)
148 #define kdev_t_to_nr(dev)               (dev)
149 #define val_to_kdev(dev)                (dev)
150 #define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, data);
151
152 #include <linux/writeback.h>
153
154 static inline int cleanup_group_info(void)
155 {
156         struct group_info *ginfo;
157
158         ginfo = groups_alloc(0);
159         if (!ginfo)
160                 return -ENOMEM;
161
162         set_current_groups(ginfo);
163         put_group_info(ginfo);
164
165         return 0;
166 }
167
168 #define __set_page_ll_data(page, llap) \
169         do {       \
170                 page_cache_get(page); \
171                 SetPagePrivate(page); \
172                 set_page_private(page, (unsigned long)llap); \
173         } while (0)
174 #define __clear_page_ll_data(page) \
175         do {       \
176                 ClearPagePrivate(page); \
177                 set_page_private(page, 0); \
178                 page_cache_release(page); \
179         } while(0)
180
181 #define kiobuf bio
182
183 #include <linux/proc_fs.h>
184
185 #if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
186 #define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
187 extern void __d_rehash(struct dentry *dentry, int lock);
188 #endif
189
190 #if !defined(HAVE_D_MOVE_LOCKED) && defined(HAVE___D_MOVE)
191 #define d_move_locked(dentry, target) __d_move(dentry, target)
192 extern void __d_move(struct dentry *dentry, struct dentry *target);
193 #endif
194
195 #ifdef HAVE_CAN_SLEEP_ARG
196 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
197         flock_lock_file_wait(file, lock, can_sleep)
198 #else
199 #define ll_flock_lock_file_wait(file, lock, can_sleep) \
200         flock_lock_file_wait(file, lock)
201 #endif
202
203 #define CheckWriteback(page, cmd) \
204         ((!PageWriteback(page) && (cmd & OBD_BRW_READ)) || \
205          (PageWriteback(page) && (cmd & OBD_BRW_WRITE)))
206
207 #ifdef HAVE_PAGE_LIST
208 static inline int mapping_has_pages(struct address_space *mapping)
209 {
210         int rc = 1;
211
212         ll_pgcache_lock(mapping);
213         if (list_empty(&mapping->dirty_pages) &&
214             list_empty(&mapping->clean_pages) &&
215             list_empty(&mapping->locked_pages)) {
216                 rc = 0;
217         }
218         ll_pgcache_unlock(mapping);
219
220         return rc;
221 }
222 #else
223 static inline int mapping_has_pages(struct address_space *mapping)
224 {
225         return mapping->nrpages > 0;
226 }
227 #endif
228
229 #ifdef HAVE_KIOBUF_KIO_BLOCKS
230 #define KIOBUF_GET_BLOCKS(k) ((k)->kio_blocks)
231 #else
232 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
233 #endif
234
235 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
236 #define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
237 #define ll_vfs_symlink(dir, dentry, path, mode) vfs_symlink(dir, dentry, path)
238 #else
239 #define ll_set_dflags(dentry, flags) do { \
240                 spin_lock(&dentry->d_lock); \
241                 dentry->d_flags |= flags; \
242                 spin_unlock(&dentry->d_lock); \
243         } while(0)
244 #define ll_vfs_symlink(dir, dentry, path, mode) vfs_symlink(dir, dentry, path, mode)
245 #endif
246
247 #ifndef container_of
248 #define container_of(ptr, type, member) ({                      \
249                 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
250                 (type *)( (char *)__mptr - offsetof(type,member) );})
251 #endif
252
253 #ifdef HAVE_I_ALLOC_SEM
254 #define UP_WRITE_I_ALLOC_SEM(i)   do { up_write(&(i)->i_alloc_sem); } while (0)
255 #define DOWN_WRITE_I_ALLOC_SEM(i) do { down_write(&(i)->i_alloc_sem); } while(0)
256 #define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
257
258 #define UP_READ_I_ALLOC_SEM(i)    do { up_read(&(i)->i_alloc_sem); } while (0)
259 #define DOWN_READ_I_ALLOC_SEM(i)  do { down_read(&(i)->i_alloc_sem); } while (0)
260 #define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
261 #else
262 #define UP_READ_I_ALLOC_SEM(i)              do { } while (0)
263 #define DOWN_READ_I_ALLOC_SEM(i)            do { } while (0)
264 #define LASSERT_I_ALLOC_SEM_READ_LOCKED(i)  do { } while (0)
265
266 #define UP_WRITE_I_ALLOC_SEM(i)             do { } while (0)
267 #define DOWN_WRITE_I_ALLOC_SEM(i)           do { } while (0)
268 #define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) do { } while (0)
269 #endif
270
271 #ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
272 #define grab_cache_page_nowait_gfp(x, y, z) grab_cache_page_nowait((x), (y))
273 #endif
274
275 #ifndef HAVE_FILEMAP_FDATAWRITE
276 #define filemap_fdatawrite(mapping)      filemap_fdatasync(mapping)
277 #endif
278
279 #ifdef HAVE_VFS_KERN_MOUNT
280 static inline 
281 struct vfsmount *
282 ll_kern_mount(const char *fstype, int flags, const char *name, void *data)
283 {
284         struct file_system_type *type = get_fs_type(fstype);
285         struct vfsmount *mnt;
286         if (!type)
287                 return ERR_PTR(-ENODEV);
288         mnt = vfs_kern_mount(type, flags, name, data);
289         module_put(type->owner);
290         return mnt;
291 }
292 #else
293 #define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data))
294 #endif
295
296 #ifndef HAVE_GENERIC_FILE_READ
297 static inline
298 ssize_t
299 generic_file_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
300 {
301         struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = len };
302         struct kiocb kiocb;
303         ssize_t ret;
304
305         init_sync_kiocb(&kiocb, filp);
306         kiocb.ki_pos = *ppos;
307         kiocb.ki_left = len;
308
309         ret = generic_file_aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
310         *ppos = kiocb.ki_pos;
311         return ret;
312 }
313 #endif
314
315 #ifndef HAVE_GENERIC_FILE_WRITE
316 static inline
317 ssize_t
318 generic_file_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
319 {
320         struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = len };
321         struct kiocb kiocb;
322         ssize_t ret;
323
324         init_sync_kiocb(&kiocb, filp);
325         kiocb.ki_pos = *ppos;
326         kiocb.ki_left = len;
327
328         ret = generic_file_aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
329         *ppos = kiocb.ki_pos;
330
331         return ret;
332 }
333 #endif
334
335 #ifdef HAVE_STATFS_DENTRY_PARAM
336 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
337 #else
338 #define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
339 #endif
340
341 /* task_struct */
342 #ifndef HAVE_TASK_PPTR
343 #define p_pptr parent
344 #endif
345
346 #ifndef HAVE_SB_TIME_GRAN
347 #ifndef HAVE_S_TIME_GRAN
348 #error Need s_time_gran patch!
349 #endif
350 static inline u32 get_sb_time_gran(struct super_block *sb)
351 {
352         return sb->s_time_gran;
353 }
354 #endif
355
356 #ifdef HAVE_RW_TREE_LOCK
357 #define TREE_READ_LOCK_IRQ(mapping)     read_lock_irq(&(mapping)->tree_lock)
358 #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
359 #else
360 #define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock)
361 #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock)
362 #endif
363
364 #ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
365 #define ll_unregister_blkdev(a,b)       unregister_blkdev((a),(b))
366 #else
367 static inline 
368 int ll_unregister_blkdev(unsigned int dev, const char *name)
369 {
370         unregister_blkdev(dev, name);
371         return 0;
372 }
373 #endif
374
375 #ifdef HAVE_INVALIDATE_BDEV_2ARG
376 #define ll_invalidate_bdev(a,b)         invalidate_bdev((a),(b))
377 #else
378 #define ll_invalidate_bdev(a,b)         invalidate_bdev((a))
379 #endif
380
381 #ifdef HAVE_INODE_BLKSIZE
382 #define ll_inode_blksize(a)     (a)->i_blksize
383 #else
384 #define ll_inode_blksize(a)     (1<<(a)->i_blkbits)
385 #endif
386
387 #ifndef HAVE_EXPORT_NR_FREE_BUFFER_PAGES
388 static inline unsigned int ll_nr_free_buffer_pages(void)
389 {
390         struct sysinfo si;
391
392         si_meminfo(&si);
393         return (unsigned int)(si.freeram - si.freehigh);
394 }
395 #else
396 #define ll_nr_free_buffer_pages()       nr_free_buffer_pages()
397 #endif
398
399 #ifdef HAVE_FS_RENAME_DOES_D_MOVE
400 #define LL_RENAME_DOES_D_MOVE   FS_RENAME_DOES_D_MOVE
401 #else
402 #define LL_RENAME_DOES_D_MOVE   FS_ODD_RENAME
403 #endif
404
405 /* add a lustre compatible layer for crypto API */
406 #include <linux/crypto.h>
407 #ifdef HAVE_ASYNC_BLOCK_CIPHER
408 #define ll_crypto_hash          crypto_hash
409 #define ll_crypto_cipher        crypto_blkcipher
410 #define ll_crypto_alloc_hash(name, type, mask)  crypto_alloc_hash(name, type, mask)
411 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen)
412 #define ll_crypto_hash_init(desc)               crypto_hash_init(desc)
413 #define ll_crypto_hash_update(desc, sl, bytes)  crypto_hash_update(desc, sl, bytes)
414 #define ll_crypto_hash_final(desc, out)         crypto_hash_final(desc, out)
415 #define ll_crypto_alloc_blkcipher(name, type, mask) \
416                 crypto_alloc_blkcipher(name ,type, mask)
417 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
418                 crypto_blkcipher_setkey(tfm, key, keylen)
419 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
420                 crypto_blkcipher_set_iv(tfm, src, len)
421 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
422                 crypto_blkcipher_get_iv(tfm, dst, len)
423 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
424                 crypto_blkcipher_encrypt(desc, dst, src, bytes)
425 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
426                 crypto_blkcipher_decrypt(desc, dst, src, bytes)
427 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
428                 crypto_blkcipher_encrypt_iv(desc, dst, src, bytes)
429 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
430                 crypto_blkcipher_decrypt_iv(desc, dst, src, bytes)
431
432 static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm,
433                                  u8 *key, unsigned int *keylen,
434                                  struct scatterlist *sg,
435                                  unsigned int size, u8 *result)
436 {
437         struct hash_desc desc;
438         int              rv;
439         desc.tfm   = tfm;
440         desc.flags = 0;
441         rv = crypto_hash_setkey(desc.tfm, key, *keylen);
442         if (rv) {
443                 CERROR("failed to hash setkey: %d\n", rv);
444                 return rv;
445         }
446         return crypto_hash_digest(&desc, sg, size, result);
447 }
448 static inline
449 unsigned int crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm)
450 {
451         return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize;
452 }
453 static inline
454 unsigned int crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
455 {
456         return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
457 }
458
459 #define ll_crypto_hash_blocksize(tfm)       crypto_hash_blocksize(tfm)
460 #define ll_crypto_hash_digestsize(tfm)      crypto_hash_digestsize(tfm)
461 #define ll_crypto_blkcipher_ivsize(tfm)     crypto_blkcipher_ivsize(tfm)
462 #define ll_crypto_blkcipher_blocksize(tfm)  crypto_blkcipher_blocksize(tfm)
463 #define ll_crypto_free_hash(tfm)            crypto_free_hash(tfm)
464 #define ll_crypto_free_blkcipher(tfm)       crypto_free_blkcipher(tfm)
465 #else /* HAVE_ASYNC_BLOCK_CIPHER */
466 #include <linux/scatterlist.h>
467 #define ll_crypto_hash          crypto_tfm
468 #define ll_crypto_cipher        crypto_tfm
469 struct hash_desc {
470         struct ll_crypto_hash *tfm;
471         u32                    flags;
472 };
473 struct blkcipher_desc {
474         struct ll_crypto_cipher *tfm;
475         void                    *info;
476         u32                      flags;
477 };
478 #define ll_crypto_blkcipher_setkey(tfm, key, keylen) \
479         crypto_cipher_setkey(tfm, key, keylen)
480 #define ll_crypto_blkcipher_set_iv(tfm, src, len) \
481         crypto_cipher_set_iv(tfm, src, len)
482 #define ll_crypto_blkcipher_get_iv(tfm, dst, len) \
483         crypto_cipher_get_iv(tfm, dst, len)
484 #define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \
485         crypto_cipher_encrypt((desc)->tfm, dst, src, bytes)
486 #define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \
487         crypto_cipher_decrypt((desc)->tfm, dst, src, bytes)
488 #define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \
489         crypto_cipher_decrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
490 #define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \
491         crypto_cipher_encrypt_iv((desc)->tfm, dst, src, bytes, (desc)->info)
492
493 extern struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(
494                             const char * algname, u32 type, u32 mask);
495 static inline 
496 struct ll_crypto_hash *ll_crypto_alloc_hash(const char *alg, u32 type, u32 mask)
497 {
498         char        buf[CRYPTO_MAX_ALG_NAME + 1];
499         const char *pan = alg;
500
501         if (strncmp("hmac(", alg, 5) == 0) {
502                 char *vp = strnchr(alg, CRYPTO_MAX_ALG_NAME, ')');
503                 if (vp) {
504                         memcpy(buf, alg+ 5, vp - alg- 5);
505                         buf[vp - alg - 5] = 0x00;
506                         pan = buf;
507                 }
508         }
509         return crypto_alloc_tfm(pan, 0);
510 }
511 static inline int ll_crypto_hash_init(struct hash_desc *desc)
512 {
513        crypto_digest_init(desc->tfm); return 0;
514 }
515 static inline int ll_crypto_hash_update(struct hash_desc *desc,
516                                         struct scatterlist *sg,
517                                         unsigned int nbytes)
518 {
519         struct scatterlist *sl = sg;
520         unsigned int        count;
521                 /* 
522                  * This way is very weakness. We must ensure that
523                  * the sum of sg[0..i]->length isn't greater than nbytes.
524                  * In the upstream kernel the crypto_hash_update() also 
525                  * via the nbytes computed the count of sg[...].
526                  * The old style is more safely. but it gone.
527                  */
528         for (count = 0; nbytes > 0; count ++, sl ++) {
529                 nbytes -= sl->length;
530         }
531         crypto_digest_update(desc->tfm, sg, count); return 0;
532 }
533 static inline int ll_crypto_hash_final(struct hash_desc *desc, u8 *out)
534 {
535         crypto_digest_final(desc->tfm, out); return 0;
536 }
537 static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
538                                  u8 *key, unsigned int *keylen,
539                                  struct scatterlist *sg,
540                                  unsigned int nbytes,
541                                  u8 *out)
542 {
543         struct scatterlist *sl = sg;
544         int                 count;
545         for (count = 0; nbytes > 0; count ++, sl ++) {
546                 nbytes -= sl->length;
547         }
548         crypto_hmac(tfm, key, keylen, sg, count, out);
549         return 0;
550 }
551
552 #define ll_crypto_hash_setkey(tfm, key, keylen) crypto_digest_setkey(tfm, key, keylen)
553 #define ll_crypto_blkcipher_blocksize(tfm)      crypto_tfm_alg_blocksize(tfm)
554 #define ll_crypto_blkcipher_ivsize(tfm) crypto_tfm_alg_ivsize(tfm)
555 #define ll_crypto_hash_digestsize(tfm)  crypto_tfm_alg_digestsize(tfm)
556 #define ll_crypto_hash_blocksize(tfm)   crypto_tfm_alg_blocksize(tfm)
557 #define ll_crypto_free_hash(tfm)        crypto_free_tfm(tfm)
558 #define ll_crypto_free_blkcipher(tfm)   crypto_free_tfm(tfm)
559 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
560
561 #endif /* __KERNEL__ */
562 #endif /* _COMPAT25_H */