From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Biggers Subject: Re: [PATCH V2 11/13] ext4: Compute logical block and the page range to be encrypted Date: Tue, 30 Apr 2019 10:01:51 -0700 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-Transfer-Encoding: 7bit Return-path: Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hLW8m-000543-9A for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Apr 2019 17:02:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hLW8l-001H7u-4c for linux-f2fs-devel@lists.sourceforge.net; Tue, 30 Apr 2019 17:02:00 +0000 Content-Disposition: inline In-Reply-To: <20190428043121.30925-12-chandan@linux.ibm.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Chandan Rajendra Cc: tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, hch@infradead.org, linux-fscrypt@vger.kernel.org, adilger.kernel@dilger.ca, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, linux-ext4@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 >