Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2334265yba; Sat, 27 Apr 2019 21:33:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8GLtEAR7GEK1ugzEOgWlAlfL06+VnE12AoYWsuPS6m0dLbZ1VcP9oLPj9RnDqCZSx0dPR X-Received: by 2002:a17:902:23:: with SMTP id 32mr40036125pla.116.1556425984633; Sat, 27 Apr 2019 21:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556425984; cv=none; d=google.com; s=arc-20160816; b=YVwWLmx+UA1omFzOSdnc3eonEzaXO8nSQqleDse+OAeaDJQfm1aDUr6Yibfr0w7HAs cH9Ur7J7jrpGJzec3Rf2JFAtHf688zz0TiSMYR0Um2yCevqYLAIzaCp1ce4Ci6Ji/pzY x4UPvcWIiu0Zhur0HcfcWMKm+YQyRsy+AWc0wpetkFgUNRS71B0mJ/UFmEt9LmlMeSCN qs7L6QeU6V3eYBPxwB2zDk2IjMaPdkxxSW3CRiSpO5twTJMgH5tM93aigp6NcmnF/pD3 KeSOgXC2YKq3c1257FNY4TW/Ux6ySudN+4TZkou/Dacz5gQR5GHjbCDyQvM8VmbYnaz+ Qq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=INMgVy2GezQBijIkF5ZYD8lIl8IXzAYjqeHt0EntI6A=; b=rv005+zGWAUFzGoVS7g7J5sQzssJWO2oPiKOzvOkJtEidZzS8Rq/j364uRoEg/XMzf jr4fpAhU+ifCi4GQrjL0awCUcwE5Q4NGPMPLnRLm+qmbOqBltDsg7KGmf76sp++JRk33 k6LpBLjE3XxmWfm/VWesk8gOQ7ARAnF8ioYEH3CoIhHs1345WpV1n6mgP/HtqOyWWJX8 MXaOr/EkFaJcDcxCpTUfHuPtSsYANo02VVvyGrmewGCbnVMz/BmiM+AWF2EKwzEmOb7F s3laDrxjMDzD9w4lndaTyi0WrQQSqPZNsTL2y7BrGZZJuBcz6Bb7d0RQE5Qp7Yk+I9Nn P7dw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si16487359pgt.259.2019.04.27.21.32.50; Sat, 27 Apr 2019 21:33:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbfD1Ecn (ORCPT + 99 others); Sun, 28 Apr 2019 00:32:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51768 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725924AbfD1Ecm (ORCPT ); Sun, 28 Apr 2019 00:32:42 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3S4T95w090229 for ; Sun, 28 Apr 2019 00:32:41 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s54649fnf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 28 Apr 2019 00:32:41 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 28 Apr 2019 05:32:41 +0100 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 28 Apr 2019 05:32:35 +0100 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3S4VK8H32244078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Apr 2019 04:31:20 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03B7A112062; Sun, 28 Apr 2019 04:31:20 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36054112061; Sun, 28 Apr 2019 04:31:16 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.75.21]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Sun, 28 Apr 2019 04:31:15 +0000 (GMT) From: Chandan Rajendra To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org Cc: Chandan Rajendra , tytso@mit.edu, adilger.kernel@dilger.ca, ebiggers@kernel.org, jaegeuk@kernel.org, yuchao0@huawei.com, hch@infradead.org Subject: [PATCH V2 11/13] ext4: Compute logical block and the page range to be encrypted Date: Sun, 28 Apr 2019 10:01:19 +0530 X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190428043121.30925-1-chandan@linux.ibm.com> References: <20190428043121.30925-1-chandan@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19042804-2213-0000-0000-0000038361B5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011008; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01195431; UDB=6.00626836; IPR=6.00976273; MB=3.00026628; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-28 04:32:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042804-2214-0000-0000-00005E3539B8 Message-Id: <20190428043121.30925-12-chandan@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-28_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904280030 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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_bytes = round_up(len, i_blocksize(inode)); + page_blk = page->index << (PAGE_SHIFT - inode->i_blkbits); 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