diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-05 19:34:31 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-22 16:07:23 -0800 |
commit | ce855a3bd0922f548a3c4937d6447c2ed4d4b1bc (patch) | |
tree | a4a5d291f7d244f9320aac1371644df485c5d381 /fs/f2fs/crypto.c | |
parent | 0fac2d501b0d13216c4bdd25c9d535edf306451f (diff) |
f2fs crypto: f2fs_page_crypto() doesn't need a encryption context
This patch adopts:
ext4 crypto: ext4_page_crypto() doesn't need a encryption context
Since ext4_page_crypto() doesn't need an encryption context (at least
not any more), this allows us to simplify a number function signature
and also allows us to avoid needing to allocate a context in
ext4_block_write_begin(). It also means we no longer need a separate
ext4_decrypt_one() function.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/crypto.c')
-rw-r--r-- | fs/f2fs/crypto.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c index d879c6c846b7..3ef37868d0c7 100644 --- a/fs/f2fs/crypto.c +++ b/fs/f2fs/crypto.c @@ -156,7 +156,7 @@ static void completion_pages(struct work_struct *work) bio_for_each_segment_all(bv, bio, i) { struct page *page = bv->bv_page; - int ret = f2fs_decrypt(ctx, page); + int ret = f2fs_decrypt(page); if (ret) { WARN_ON_ONCE(1); @@ -320,8 +320,7 @@ typedef enum { F2FS_ENCRYPT, } f2fs_direction_t; -static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx, - struct inode *inode, +static int f2fs_page_crypto(struct inode *inode, f2fs_direction_t rw, pgoff_t index, struct page *src_page, @@ -418,7 +417,7 @@ struct page *f2fs_encrypt(struct inode *inode, goto err_out; ctx->w.control_page = plaintext_page; - err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page->index, + err = f2fs_page_crypto(inode, F2FS_ENCRYPT, plaintext_page->index, plaintext_page, ciphertext_page); if (err) { ciphertext_page = ERR_PTR(err); @@ -446,30 +445,14 @@ err_out: * * Return: Zero on success, non-zero otherwise. */ -int f2fs_decrypt(struct f2fs_crypto_ctx *ctx, struct page *page) +int f2fs_decrypt(struct page *page) { BUG_ON(!PageLocked(page)); - return f2fs_page_crypto(ctx, page->mapping->host, + return f2fs_page_crypto(page->mapping->host, F2FS_DECRYPT, page->index, page, page); } -/* - * Convenience function which takes care of allocating and - * deallocating the encryption context - */ -int f2fs_decrypt_one(struct inode *inode, struct page *page) -{ - struct f2fs_crypto_ctx *ctx = f2fs_get_crypto_ctx(inode); - int ret; - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); - ret = f2fs_decrypt(ctx, page); - f2fs_release_crypto_ctx(ctx); - return ret; -} - bool f2fs_valid_contents_enc_mode(uint32_t mode) { return (mode == F2FS_ENCRYPTION_MODE_AES_256_XTS); |