I don't think there's any need for the ecryptfs_readpage -> ecryptfs_read_lower_page_segment -> ecryptfs_read_lower sequence, as we know that we just need to encrypt a bunch of zeroes. Fixing that will improve performance, but the CPU is still likely to be pegged pretty high while doing all the encryption operations.
Improving the truncate path would really be a nice-to-have improvement, but I will probably not be able to devote much time to it. If someone wants to try to tackle it, I'll be more than happy to provide any help that I can.
After taking a look at the call trace during a truncate that extends a file, eCryptfs could probably handle this in a more efficient way.
-> ecryptfs_setattr get_locked_ page read_lower_ page_segment read_lower_ page_segment get_locked_ page encrypt_ page node"). call node"). return encrypt_ extent calculate_ md5 calculate_ md5 encrypt_ extent write_lower write_lower encrypt_ page
-> ecryptfs_truncate
-> ecryptfs_write
...
-> ecryptfs_
-> ecryptfs_readpage
-> ecryptfs_
-> kmap
<- kmap
-> ecryptfs_read_lower
<- ecryptfs_read_lower
<- ecryptfs_
<- ecryptfs_readpage
<- ecryptfs_
-> ecryptfs_
-> alloc_pages_
<- alloc_pages_
-> kmap
<- kmap
-> ecryptfs_
-> ecryptfs_derive_iv
-> ecryptfs_
<- ecryptfs_
<- ecryptfs_derive_iv
<- ecryptfs_
-> ecryptfs_
<- ecryptfs_
<- ecryptfs_
...
<- ecryptfs_write
<- ecryptfs_truncate
<- ecryptfs_setattr
I don't think there's any need for the ecryptfs_readpage -> ecryptfs_ read_lower_ page_segment -> ecryptfs_read_lower sequence, as we know that we just need to encrypt a bunch of zeroes. Fixing that will improve performance, but the CPU is still likely to be pegged pretty high while doing all the encryption operations.
Improving the truncate path would really be a nice-to-have improvement, but I will probably not be able to devote much time to it. If someone wants to try to tackle it, I'll be more than happy to provide any help that I can.