X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=libcfs%2Flibcfs%2Fcrypto%2Fcrypto.c;h=3d18715a06c3d2ed8544e2c3eb6ca0f8f2a9dc8a;hb=f3fe144b8572e9e75bb55076e29057227476ebf5;hp=bc888cc755b4520758d28a2f120efbb82f6ee8bd;hpb=c60b7d9f571748fb055d29cd019709f9e965a84d;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/crypto/crypto.c b/libcfs/libcfs/crypto/crypto.c index bc888cc..3d18715 100644 --- a/libcfs/libcfs/crypto/crypto.c +++ b/libcfs/libcfs/crypto/crypto.c @@ -35,6 +35,12 @@ #include #include "llcrypt_private.h" +#ifdef HAVE_CIPHER_H +#include + +MODULE_IMPORT_NS(CRYPTO_INTERNAL); +#endif + static unsigned int num_prealloc_crypto_pages = 32; static unsigned int num_prealloc_crypto_ctxs = 128; @@ -266,9 +272,10 @@ struct page *llcrypt_encrypt_pagecache_blocks(struct page *page, EXPORT_SYMBOL(llcrypt_encrypt_pagecache_blocks); /** - * llcrypt_encrypt_block_inplace() - Encrypt a filesystem block in-place + * llcrypt_encrypt_block() - Encrypt a filesystem block in a page * @inode: The inode to which this block belongs - * @page: The page containing the block to encrypt + * @src: The page containing the block to encrypt + * @dst: The page which will contain the encrypted data * @len: Size of block to encrypt. Doesn't need to be a multiple of the * fs block size, but must be a multiple of LL_CRYPTO_BLOCK_SIZE. * @offs: Byte offset within @page at which the block to encrypt begins @@ -279,17 +286,18 @@ EXPORT_SYMBOL(llcrypt_encrypt_pagecache_blocks); * Encrypt a possibly-compressed filesystem block that is located in an * arbitrary page, not necessarily in the original pagecache page. The @inode * and @lblk_num must be specified, as they can't be determined from @page. + * The decrypted data will be stored in @dst. * * Return: 0 on success; -errno on failure */ -int llcrypt_encrypt_block_inplace(const struct inode *inode, struct page *page, - unsigned int len, unsigned int offs, - u64 lblk_num, gfp_t gfp_flags) +int llcrypt_encrypt_block(const struct inode *inode, struct page *src, + struct page *dst, unsigned int len, unsigned int offs, + u64 lblk_num, gfp_t gfp_flags) { - return llcrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, page, page, + return llcrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, src, dst, len, offs, gfp_flags); } -EXPORT_SYMBOL(llcrypt_encrypt_block_inplace); +EXPORT_SYMBOL(llcrypt_encrypt_block); /** * llcrypt_decrypt_pagecache_blocks() - Decrypt filesystem blocks in a pagecache page @@ -335,9 +343,10 @@ int llcrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len, EXPORT_SYMBOL(llcrypt_decrypt_pagecache_blocks); /** - * llcrypt_decrypt_block_inplace() - Decrypt a filesystem block in-place + * llcrypt_decrypt_block() - Cache a decrypted filesystem block in a page * @inode: The inode to which this block belongs - * @page: The page containing the block to decrypt + * @src: The page containing the block to decrypt + * @dst: The page which will contain the plain data * @len: Size of block to decrypt. Doesn't need to be a multiple of the * fs block size, but must be a multiple of LL_CRYPTO_BLOCK_SIZE. * @offs: Byte offset within @page at which the block to decrypt begins @@ -347,17 +356,18 @@ EXPORT_SYMBOL(llcrypt_decrypt_pagecache_blocks); * Decrypt a possibly-compressed filesystem block that is located in an * arbitrary page, not necessarily in the original pagecache page. The @inode * and @lblk_num must be specified, as they can't be determined from @page. + * The encrypted data will be stored in @dst. * * Return: 0 on success; -errno on failure */ -int llcrypt_decrypt_block_inplace(const struct inode *inode, struct page *page, - unsigned int len, unsigned int offs, - u64 lblk_num) +int llcrypt_decrypt_block(const struct inode *inode, struct page *src, + struct page *dst, unsigned int len, unsigned int offs, + u64 lblk_num, gfp_t gfp_flags) { - return llcrypt_crypt_block(inode, FS_DECRYPT, lblk_num, page, page, - len, offs, GFP_NOFS); + return llcrypt_crypt_block(inode, FS_DECRYPT, lblk_num, src, dst, + len, offs, gfp_flags); } -EXPORT_SYMBOL(llcrypt_decrypt_block_inplace); +EXPORT_SYMBOL(llcrypt_decrypt_block); /* * Validate dentries in encrypted directories to make sure we aren't potentially