ext4 crypto: use per-inode tfm structure

As suggested by Herbert Xu, we shouldn't allocate a new tfm each time
we read or write a page.  Instead we can use a single tfm hanging off
the inode's crypt_info structure for all of our encryption needs for
that inode, since the tfm can be used by multiple crypto requests in
parallel.

Also use cmpxchg() to avoid races that could result in crypt_info
structure getting doubly allocated or doubly freed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o
2015-05-31 13:34:22 -04:00
parent 71dea01ea2
commit c936e1ec28
9 changed files with 96 additions and 156 deletions

View File

@@ -37,7 +37,7 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd)
if (!ext4_encrypted_inode(inode))
return page_follow_link_light(dentry, nd);
res = ext4_setup_fname_crypto(inode);
res = ext4_get_encryption_info(inode);
if (res)
return ERR_PTR(res);