Eric Biggers 09075917fb ANDROID: fscrypt: handle direct I/O with IV_INO_LBLK_32
With the existing fscrypt IV generation methods, each file's data blocks
have contiguous DUNs.  Therefore the direct I/O code "just worked"
because it only submits logically contiguous bios.  But with
IV_INO_LBLK_32, the direct I/O code breaks because the DUN can wrap from
0xffffffff to 0.  We can't submit bios across such boundaries.

This is especially difficult to handle when block_size != PAGE_SIZE,
since in that case the DUN can wrap in the middle of a page.  Punt on
this case for now and just handle block_size == PAGE_SIZE.

Add and use a new function fscrypt_dio_supported() to check whether a
direct I/O request is unsupported due to encryption constraints.

Then, update fs/direct-io.c (used by f2fs, and by ext4 in kernel v5.4
and earlier) and fs/iomap/direct-io.c (used by ext4 in kernel v5.5 and
later) to avoid submitting I/O across a DUN discontinuity.

(This is needed in ACK now because ACK already supports direct I/O with
inline crypto.  I'll be sending this upstream along with the encrypted
direct I/O support itself once its prerequisites are closer to landing.)

(cherry picked from android-mainline commit
 8d6c90c9d68b985fa809626d12f8c9aff3c9dcb1)

Conflicts:
	fs/ext4/file.c
	fs/iomap/direct-io.c

(Dropped the iomap changes because in kernel v5.4 and earlier,
 ext4 doesn't use iomap for direct I/O)

Test: For now, just manually tested direct I/O on ext4 and f2fs in the
      DUN discontinuity case.
Bug: 144046242
Change-Id: I0c0b0b20a73ade35c3660cc6f9c09d49d3853ba5
Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-05-26 17:54:48 +00:00
..
2019-10-11 19:06:20 +02:00
2020-04-03 08:18:27 +02:00
2020-05-06 09:01:56 +02:00
2020-05-03 08:51:19 +02:00
2019-08-06 19:05:23 +02:00
2019-12-17 20:38:33 +01:00
2019-12-05 15:48:19 +01:00
2019-12-17 21:13:36 +01:00
2020-04-24 08:41:10 +02:00
2019-12-17 21:13:36 +01:00
2020-05-06 09:01:56 +02:00
2020-04-24 08:41:10 +02:00
2020-05-03 08:51:19 +02:00
2020-02-13 15:17:48 -08:00
2018-12-21 14:13:04 +01:00
2017-09-04 19:05:15 -04:00
2020-04-24 08:41:10 +02:00
2020-05-20 12:15:34 +02:00
2020-03-11 18:02:43 +01:00
2020-05-20 12:15:34 +02:00
2020-04-03 08:18:27 +02:00
2020-04-03 08:18:27 +02:00
2020-03-11 19:30:15 +01:00
2020-03-20 12:19:46 +01:00
2020-05-03 08:51:19 +02:00
2018-02-22 19:18:40 +00:00