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: 9787637 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 4620D60325 for ; Wed, 14 Jun 2017 23:41:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AB032022C for ; Wed, 14 Jun 2017 23:41:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E2332853B; Wed, 14 Jun 2017 23:41:17 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 BA95A28539 for ; Wed, 14 Jun 2017 23:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbdFNXlA (ORCPT ); Wed, 14 Jun 2017 19:41:00 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33653 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752820AbdFNXk4 (ORCPT ); Wed, 14 Jun 2017 19:40:56 -0400 Received: by mail-pf0-f176.google.com with SMTP id 83so7583169pfr.0 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=q/0tskr4bihL+orKxZ+dZV+xcESy5TGoCs4DNVUsy8juQhai2tjsp04GXhhjcBbpLn rxs9eoq5/wT35G5M8DSsFOvkvo5HPiOzDUPl7UaCTODWFZjEg5eW7OJuo4qlIqawqu5E xkoiHS7AseoVuisyI993e1WgZPtg8m3uBYBd5X4/Hk9F6nH/7u/45fR28QR7FsbjAE3B 6cdSGDjexL6hf/hbSQ75JQssVGfJ3NWhOmiKgHhe5T7WSHJglvEhWzoiIs+9XTK1fjQy xXG97mRen91JKWntC5VdTiGiHhNmkjul9NndfD+06l4zYO42VN2cZdrXShQ1F5l4TDL/ MqmQ== X-Gm-Message-State: AKS2vOwaW+5Q6s6vwdxKFT6GRWntJYli6tZj+j2acNlxVr2ID4tqXghL JvCZJHQ8KH9csCs+ 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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;