summaryrefslogtreecommitdiff
path: root/fs/crypto
diff options
context:
space:
mode:
authorDavid Gstir <david@sigma-star.at>2016-12-07 01:53:57 +0300
committerTheodore Ts'o <tytso@mit.edu>2016-12-12 00:33:11 +0300
commitf32d7ac20a5864483c1f96e4970daa083e18bfd1 (patch)
treef381a5707d80076055bb23c14a5a2c134f3ae7df /fs/crypto
parentbd7b8290388dd58a8c0a3710b171e58ef952ca4d (diff)
downloadlinux-f32d7ac20a5864483c1f96e4970daa083e18bfd1.tar.xz
fscrypt: Delay bounce page pool allocation until needed
Since fscrypt users can now indicated if fscrypt_encrypt_page() should use a bounce page, we can delay the bounce page pool initialization util it is really needed. That is until fscrypt_operations has no FS_CFLG_OWN_PAGES flag set. Signed-off-by: David Gstir <david@sigma-star.at> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/crypto')
-rw-r--r--fs/crypto/crypto.c9
-rw-r--r--fs/crypto/fscrypt_private.h2
-rw-r--r--fs/crypto/keyinfo.c2
3 files changed, 9 insertions, 4 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 5ffc59436397..bc1d4781b9ec 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -525,17 +525,22 @@ static void fscrypt_destroy(void)
/**
* fscrypt_initialize() - allocate major buffers for fs encryption.
+ * @cop_flags: fscrypt operations flags
*
* We only call this when we start accessing encrypted files, since it
* results in memory getting allocated that wouldn't otherwise be used.
*
* Return: Zero on success, non-zero otherwise.
*/
-int fscrypt_initialize(void)
+int fscrypt_initialize(unsigned int cop_flags)
{
int i, res = -ENOMEM;
- if (fscrypt_bounce_page_pool)
+ /*
+ * No need to allocate a bounce page pool if there already is one or
+ * this FS won't use it.
+ */
+ if (cop_flags & FS_CFLG_OWN_PAGES || fscrypt_bounce_page_pool)
return 0;
mutex_lock(&fscrypt_init_mutex);
diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
index c98b2a7fb6d3..7ba10cd45a2e 100644
--- a/fs/crypto/fscrypt_private.h
+++ b/fs/crypto/fscrypt_private.h
@@ -85,7 +85,7 @@ struct fscrypt_completion_result {
/* crypto.c */
-int fscrypt_initialize(void);
+int fscrypt_initialize(unsigned int cop_flags);
/* keyinfo.c */
extern int fscrypt_get_crypt_info(struct inode *);
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 35d3317a27b3..6eeea1dcba41 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -188,7 +188,7 @@ int fscrypt_get_crypt_info(struct inode *inode)
u8 *raw_key = NULL;
int res;
- res = fscrypt_initialize();
+ res = fscrypt_initialize(inode->i_sb->s_cop->flags);
if (res)
return res;