Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5157669yba; Tue, 30 Apr 2019 10:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4NeDsy0qdsJRKzPygH1ePaywvqdtdLKqPp5lr+pXKyWTX0x1SJqrJTik0t170ilnuvXKg X-Received: by 2002:a65:4481:: with SMTP id l1mr67248630pgq.66.1556643786982; Tue, 30 Apr 2019 10:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556643786; cv=none; d=google.com; s=arc-20160816; b=DrEENE0/BNk2LensshH22kOXdRz32te6sIJtiKGd5DFQQFmvWl8d39Rc5OJbgbS7y5 AflOzGF82XlGfx+C2s1EnIwuU3cv+UsbCrAZyeiyBLMe/Gy5KBm9AIVgVyzWmSSUo4X2 vGCSTrBmvV4PTMEwyR7N3MrCDI4ZsShhKJAB3xrD0Z8jMshC+njAgcm/bY2QRskljH5W udNdlvqzd7xZQDochdunVCkADaQPCZybbM3c5T0kBBNKQpSlNPi9UwEVQ+Oc7q8DJYXC 3YYNNe5Qr0AAwuIL8iajxaYAVMtMJqvZYWBg02C6dzUvuA9WRXdoScaergokyH2Nx4fa 7mBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eIlcxJrKt3NRwRCEOBjRNPNfUwLTC3YBaZTtbhJ7YlQ=; b=uWLkhcO5le4c073p53uDNkbmWYAWYg/dHmT4sNcRNem1nrnbeODX2bLJo8QgNNAHgx Mrkt4Y/ThqRHoRefSQQ3fKjhcR9QYoY5FedhhAcH+o6VzevUQQeYiYWfOCLdqeiZbPfb 5p4MSo1fc7AHZYJbJHCm7IBpeLoDkGq93hJcKAoXNBtLBYH6edcD/DS+yC2Zzw58aIJ7 zdSHsO/ovO4zB9mP+TtBt3UM828FriydhhjIyF1oAF/DMIRsr0rKFkaqeBAhrBODugzD VE5rB8VkAf7v92CQwW10N5LcNM8UM6K0A98HtQ4TkydZlPZhIwn5CFNtLB2QS6piVHv2 uU1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1bUb7kJb; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si28948899pgg.536.2019.04.30.10.02.48; Tue, 30 Apr 2019 10:03:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1bUb7kJb; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725950AbfD3RBy (ORCPT + 99 others); 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-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: 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 >