Whamcloud - gitweb
LU-15003 sec: use enc pool for bounce pages
[fs/lustre-release.git] / libcfs / libcfs / crypto / crypto.c
index d079b81..3d18715 100644 (file)
@@ -272,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
@@ -285,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
@@ -341,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
@@ -353,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