ext4 crypto: use per-inode tfm structure
authorTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:34:22 +0000 (13:34 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:34:22 +0000 (13:34 -0400)
commitc936e1ec2879e43599d801dfa6fe58e7ccfee433
treea09688def0b1c75f7e23a9b1c98848f41e043d2e
parent71dea01ea2edb73f3c5d9a0cd7ba028bb9313287
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>
fs/ext4/crypto.c
fs/ext4/crypto_fname.c
fs/ext4/crypto_key.c
fs/ext4/dir.c
fs/ext4/ext4.h
fs/ext4/ext4_crypto.h
fs/ext4/namei.c
fs/ext4/super.c
fs/ext4/symlink.c