From patchwork Wed Jun 14 23:40:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Halcrow X-Patchwork-Id: 9787635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA3886038F for ; Wed, 14 Jun 2017 23:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDFD728210 for ; Wed, 14 Jun 2017 23:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D173F2022C; Wed, 14 Jun 2017 23:41:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79C0C27F9F for ; Wed, 14 Jun 2017 23:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbdFNXlA (ORCPT ); Wed, 14 Jun 2017 19:41:00 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:35215 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752826AbdFNXk4 (ORCPT ); Wed, 14 Jun 2017 19:40:56 -0400 Received: by mail-pf0-f181.google.com with SMTP id l89so7565541pfi.2 for ; Wed, 14 Jun 2017 16:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=UDvUZPusVTsOMapdYXTNHUqJag3O1naZpQrO8Bukwz4=; b=KhuZpZGshmogDKGneNmybhmYJTpmUrcymQ68KfubVv4ymUWnxo4/cfmxe1js5qFTzk tL3P51IfhY/p5KxYep/sXAsXmtOUBbGf7lwxMuT72QLIkTnSND16ujM7dsBRZgJHJHUU Ua4S1RE+2TI9WflNrRs2jiFC6caiciOsJ5J8FB39AnRXpnpvHCX/ErNWxVmwZH/qwidN /Xq977FQ/Tqq6xD9axZGFNLIkK4dpau4DNh9PRbFOAVEvE7TAHCv9ceQhEctvhSJjnN8 /eGBGjSlp79KFUWmdLVwzFfZCoIDj5Ki4FSZqClvRUbumArtsk4jyv4HnCKQDejN2gP7 2cqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=UDvUZPusVTsOMapdYXTNHUqJag3O1naZpQrO8Bukwz4=; b=ZI3aTQRv2vrEtNsqa1UL0JGXMlRRFZAHlJxUeHs/MsvxpUABu/dIhili76R8TyjxLx uI08Z34AOXTxYbQYQ8lbMv/ZNJwdq0FDkmBEe7UzmyL36xUGbAAvEkFmut+WGhHjHKxX dI30PLMbZLzXUb3L/t71cKfKtz4qk6JBCAukRbBDmzQTrDhaZWT6u6L0BATZlxmXgG+e 3diR0XGls+8MQ9CAEeLGMJjFI+mPb6AlEPNBvKGPFm8uua2PjF9+0miUGGbf+lnHQ7s6 yBeK1GlQaPlzlPl4vSwbOY3BKvZ/pF7kMB9ezEGi/KJWt+l/q9yGVfB6aso7z12YGMer y9uA== X-Gm-Message-State: AKS2vOwYKwuGX5vucnrnZPrGO/SMcErRS6Vm2gwcFfyc9mWg2u3TeJNe YGpXBV/uD+ElDSax X-Received: by 10.99.121.13 with SMTP id u13mr2403720pgc.147.1497483655448; Wed, 14 Jun 2017 16:40:55 -0700 (PDT) Received: from mhalcrow-linux.kir.corp.google.com ([100.66.175.61]) by smtp.gmail.com with ESMTPSA id z66sm2141286pfl.13.2017.06.14.16.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 16:40:54 -0700 (PDT) From: Michael Halcrow To: Michael Halcrow , "Theodore Y . Ts'o" , Eric Biggers , Jaegeuk Kim , linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, linux-ext4@vger.kernel.org, Tyler Hicks Subject: [RFC PATCH 4/4] f2fs: Set the bio REQ_NOENCRYPT flag Date: Wed, 14 Jun 2017 16:40:40 -0700 Message-Id: <20170614234040.4326-5-mhalcrow@google.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170614234040.4326-1-mhalcrow@google.com> References: <20170614234040.4326-1-mhalcrow@google.com> Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When lower layers such as dm-crypt observe the REQ_NOENCRYPT flag, it helps the I/O stack avoid redundant encryption, improving performance and power utilization. Note that lower layers must be consistent in their observation of this flag in order to avoid the possibility of data corruption. Signed-off-by: Michael Halcrow --- fs/f2fs/data.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 7c0f6bdf817d..2a000c0ec7e1 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -359,6 +359,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) bio_put(bio); return -EFAULT; } + fio->op_flags |= fio->encrypted_page ? REQ_NOENCRYPT : 0; bio_set_op_attrs(bio, fio->op, fio->op_flags); __submit_bio(fio->sbi, bio, fio->type); @@ -384,6 +385,7 @@ int f2fs_submit_page_mbio(struct f2fs_io_info *fio) verify_block_addr(sbi, fio->new_blkaddr); bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page; + fio->op_flags |= fio->encrypted_page ? REQ_NOENCRYPT : 0; /* set submitted = 1 as a return value */ fio->submitted = 1; @@ -1242,7 +1244,10 @@ static int f2fs_mpage_readpages(struct address_space *mapping, bio = NULL; goto set_error_page; } - bio_set_op_attrs(bio, REQ_OP_READ, 0); + bio_set_op_attrs(bio, REQ_OP_READ, + (f2fs_encrypted_inode(inode) ? + REQ_NOENCRYPT : + 0)); } if (bio_add_page(bio, page, blocksize, 0) < blocksize) @@ -1914,7 +1919,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, err = PTR_ERR(bio); goto fail; } - bio->bi_opf = REQ_OP_READ; + bio->bi_opf = REQ_OP_READ | + (f2fs_encrypted_inode(inode) ? REQ_NOENCRYPT : 0); if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { bio_put(bio); err = -EFAULT;