ext4: Set the bio REQ_NOENCRYPT flag

Sets the REQ_NOENCRYPT flag for I/O requests that ext4 has already
encrypted.  Lower layers such as dm-crypt can observe that flag to
avoid encrypting again if that's how the user configures the
environment.

Change-Id: I62a93e480a9f5788070446bd94694dfb9f83c277
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Git-repo: https://android.googlesource.com/kernel/common/
Git-commit: 7af2a1358e1577379c04d08b5c1d2ac4565c9418
[stummala@codeaurora.org: resolve merge conflicts]
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 8d4ec1a..228baa5 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -341,6 +341,8 @@
 	if (bio) {
 		int io_op_flags = io->io_wbc->sync_mode == WB_SYNC_ALL ?
 				  WRITE_SYNC : 0;
+		if (io->io_flags & EXT4_IO_ENCRYPTED)
+			io_op_flags |= REQ_NOENCRYPT;
 		bio_set_op_attrs(io->io_bio, REQ_OP_WRITE, io_op_flags);
 		submit_bio(io->io_bio);
 	}
@@ -350,6 +352,7 @@
 void ext4_io_submit_init(struct ext4_io_submit *io,
 			 struct writeback_control *wbc)
 {
+	io->io_flags = 0;
 	io->io_wbc = wbc;
 	io->io_bio = NULL;
 	io->io_end = NULL;
@@ -492,6 +495,8 @@
 	do {
 		if (!buffer_async_write(bh))
 			continue;
+		if (data_page)
+			io->io_flags |= EXT4_IO_ENCRYPTED;
 		ret = io_submit_add_bh(io, inode,
 				       data_page ? data_page : page, bh);
 		if (ret) {