Commit f47fcbb2 authored by Eric Biggers's avatar Eric Biggers

fscrypt: rename fscrypt_do_page_crypto() to fscrypt_crypt_block()

fscrypt_do_page_crypto() only does a single encryption or decryption
operation, with a single logical block number (single IV).  So it
actually operates on a filesystem block, not a "page" per se.  To
reflect this, rename it to fscrypt_crypt_block().
Reviewed-by: default avatarChandan Rajendra <chandan@linux.ibm.com>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 2a415a02
...@@ -83,7 +83,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, ...@@ -83,7 +83,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
return -ENOMEM; return -ENOMEM;
while (len--) { while (len--) {
err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk, err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk,
ZERO_PAGE(0), ciphertext_page, ZERO_PAGE(0), ciphertext_page,
PAGE_SIZE, 0, GFP_NOFS); PAGE_SIZE, 0, GFP_NOFS);
if (err) if (err)
......
...@@ -148,7 +148,8 @@ void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num, ...@@ -148,7 +148,8 @@ void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num,
crypto_cipher_encrypt_one(ci->ci_essiv_tfm, iv->raw, iv->raw); crypto_cipher_encrypt_one(ci->ci_essiv_tfm, iv->raw, iv->raw);
} }
int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, /* Encrypt or decrypt a single filesystem block of file contents */
int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw,
u64 lblk_num, struct page *src_page, u64 lblk_num, struct page *src_page,
struct page *dest_page, unsigned int len, struct page *dest_page, unsigned int len,
unsigned int offs, gfp_t gfp_flags) unsigned int offs, gfp_t gfp_flags)
...@@ -228,7 +229,7 @@ struct page *fscrypt_encrypt_page(const struct inode *inode, ...@@ -228,7 +229,7 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) { if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) {
/* with inplace-encryption we just encrypt the page */ /* with inplace-encryption we just encrypt the page */
err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, page, err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, page,
ciphertext_page, len, offs, ciphertext_page, len, offs,
gfp_flags); gfp_flags);
if (err) if (err)
...@@ -244,9 +245,8 @@ struct page *fscrypt_encrypt_page(const struct inode *inode, ...@@ -244,9 +245,8 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
if (!ciphertext_page) if (!ciphertext_page)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, page,
page, ciphertext_page, len, offs, ciphertext_page, len, offs, gfp_flags);
gfp_flags);
if (err) { if (err) {
fscrypt_free_bounce_page(ciphertext_page); fscrypt_free_bounce_page(ciphertext_page);
return ERR_PTR(err); return ERR_PTR(err);
...@@ -278,7 +278,7 @@ int fscrypt_decrypt_page(const struct inode *inode, struct page *page, ...@@ -278,7 +278,7 @@ int fscrypt_decrypt_page(const struct inode *inode, struct page *page,
if (!(inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES)) if (!(inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES))
BUG_ON(!PageLocked(page)); BUG_ON(!PageLocked(page));
return fscrypt_do_page_crypto(inode, FS_DECRYPT, lblk_num, page, page, return fscrypt_crypt_block(inode, FS_DECRYPT, lblk_num, page, page,
len, offs, GFP_NOFS); len, offs, GFP_NOFS);
} }
EXPORT_SYMBOL(fscrypt_decrypt_page); EXPORT_SYMBOL(fscrypt_decrypt_page);
......
...@@ -116,10 +116,9 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode, ...@@ -116,10 +116,9 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode,
/* crypto.c */ /* crypto.c */
extern struct kmem_cache *fscrypt_info_cachep; extern struct kmem_cache *fscrypt_info_cachep;
extern int fscrypt_initialize(unsigned int cop_flags); extern int fscrypt_initialize(unsigned int cop_flags);
extern int fscrypt_do_page_crypto(const struct inode *inode, extern int fscrypt_crypt_block(const struct inode *inode,
fscrypt_direction_t rw, u64 lblk_num, fscrypt_direction_t rw, u64 lblk_num,
struct page *src_page, struct page *src_page, struct page *dest_page,
struct page *dest_page,
unsigned int len, unsigned int offs, unsigned int len, unsigned int offs,
gfp_t gfp_flags); gfp_t gfp_flags);
extern struct page *fscrypt_alloc_bounce_page(gfp_t gfp_flags); extern struct page *fscrypt_alloc_bounce_page(gfp_t gfp_flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment