From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 685D8C43219 for ; Tue, 30 Apr 2019 17:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CC8F21734 for ; Tue, 30 Apr 2019 17:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556643715; bh=oVoGpCRk3e9cMGbhChpi4VM9WziRJ8IUbj1IO6W9b30=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=GNR6xaoYycRgcgX43uon8xNGhBm2+z3L3rw6tBIEHavUZEiTMv5AFPTT1+WLL/K8D BuRxTRQTOXkXGxImzeGueBp66fEIYjrqgx6vMlKSHPcsFA0/s+gn50rAtxuuTUGOA7 jIIZ/KlFPeIDnj43JuCArkFU6DQVs8xqP3QkSMtk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726155AbfD3RBy (ORCPT ); Tue, 30 Apr 2019 13:01:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:39714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbfD3RBy (ORCPT ); Tue, 30 Apr 2019 13:01:54 -0400 Received: from gmail.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 416392075E; Tue, 30 Apr 2019 17:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556643713; bh=oVoGpCRk3e9cMGbhChpi4VM9WziRJ8IUbj1IO6W9b30=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1bUb7kJbzNOTKFj04oKViKl6iUVKgyDzhaJEYERMY0d+9XjzIRMUEe2L65NvXZ7eU 1gXP07Tk2C/6mLOZ5hWvk2+t/TmKA9gEX/C77XGLGNI+3p3CCT3SL/RbI8Wgq1Fx4J ukvS0zQ6c1vJocSzlV58WS0Ro0pIi7E/a6g4jhpk= Date: Tue, 30 Apr 2019 10:01:51 -0700 From: Eric Biggers To: Chandan Rajendra Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, yuchao0@huawei.com, hch@infradead.org Subject: Re: [PATCH V2 11/13] ext4: Compute logical block and the page range to be encrypted Message-ID: <20190430170151.GB48973@gmail.com> References: <20190428043121.30925-1-chandan@linux.ibm.com> <20190428043121.30925-12-chandan@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190428043121.30925-12-chandan@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sun, Apr 28, 2019 at 10:01:19AM +0530, Chandan Rajendra wrote: > For subpage-sized blocks, the initial logical block number mapped by a > page can be different from page->index. Hence this commit adds code to > compute the first logical block mapped by the page and also the page > range to be encrypted. > > Signed-off-by: Chandan Rajendra > --- > fs/ext4/page-io.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c > index 3e9298e6a705..75485ee9e800 100644 > --- a/fs/ext4/page-io.c > +++ b/fs/ext4/page-io.c > @@ -418,6 +418,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, > { > struct page *data_page = NULL; > struct inode *inode = page->mapping->host; > + u64 page_blk; > unsigned block_start; > struct buffer_head *bh, *head; > int ret = 0; > @@ -478,10 +479,14 @@ int ext4_bio_write_page(struct ext4_io_submit *io, > > if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode) && nr_to_submit) { > gfp_t gfp_flags = GFP_NOFS; > + unsigned int page_bytes; > + page_blk should be declared here, just after page_bytes. > + page_bytes = round_up(len, i_blocksize(inode)); > + page_blk = page->index << (PAGE_SHIFT - inode->i_blkbits); Although block numbers are 32-bit in ext4, if you're going to make 'page_blk' a u64 anyway, then for consistency page->index should be cast to u64 here. > > retry_encrypt: > - data_page = fscrypt_encrypt_page(inode, page, PAGE_SIZE, 0, > - page->index, gfp_flags); > + data_page = fscrypt_encrypt_page(inode, page, page_bytes, 0, > + page_blk, gfp_flags); > if (IS_ERR(data_page)) { > ret = PTR_ERR(data_page); > if (ret == -ENOMEM && wbc->sync_mode == WB_SYNC_ALL) { > -- > 2.19.1 >