On Tue, Mar 14, 2023 at 04:12:39PM -0700, Eric Biggers wrote: > > I think large folio support for fscrypt and fsverity is not that far away. I > already made the following changes in 6.3: > > 51e4e3153ebc ("fscrypt: support decrypting data from large folios") > 5d0f0e57ed90 ("fsverity: support verifying data from large folios") Cool! I was thinking that fscrypt and fsverity might end up lagging as far as the large folio support was concerned, but I'm glad that this might not be the case. > AFAICT, absent actual testing of course, the only major thing that's still > needed is that fscrypt_encrypt_pagecache_blocks() needs to support large folios. > I'm not sure how it should work, exactly. Matthew gave a couple options. > Another option is to just continue to use bounce *pages*, and keep track of all > the bounce pages for each folio. We don't have to solve that right away; it is possible to support reads of large folios, but not writes. If someone reads in a 128k folio, and then modifies a 4k page in the middle of the page, we could just split up the 128k folio and then writing out either the single 4k page that was modified. (It might very well be that in that case, we *want* to break up the folio anyway, to avoid the write amplification problem.) In any case, I suspect that how we would support large folios for ext4 by first is to support using iomap for buffer I/O --- but only for file systems where page size == block size, with no fscrypt, no fsverity, no data=journal, and only for buffered reads. And for buffered writes, we'll break apart the folio and then use the existing ext4_writepages() code path. We can then gradually start relying on iomap and using large folios for additional scenarios, both on the read and eventually, on the write side. I suspect we'll want to have a way of enabling and disabling large folios on a fine-grained manner, as well has potentially proactively breaking up large folios in page_mkwrite (so that a 4k random page modification doesn't get amplified into the entire contents of a large folio needing to be written back). - Ted