From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E64D3FFACC; Mon, 2 Mar 2026 14:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772461172; cv=none; b=Lbg55vnu9pSDimkT3Wm00FL0/3LoAiYGh2j6S+STgAvYZJnwRVqzVqvkT8V4vuJ6GiamAk/K6PYIFlbD6T7J533YGSyz3gpY9qlfi9W0x1FCeqOe5ZnwDh00EcJIPJCJlaC0NOOUrjCSvESIu0HVwKcZw3XI8MC/cFeEf+beAB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772461172; c=relaxed/simple; bh=xrZ56GwN0DxtCOcCCQXmr+B+xIIiunz1BcHYsiIyL+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DQo/3/fbFBBXzGj7VhZ0vcL7khRFJTlKRG+BbDs1yZfP3Nig5LZF9LN7oJpzlQQzMweS/kqt+Y9lD7FjLbwANJLSArRd7WAvz8mwKwA6oyw5Ols7B9Y4TynTmNOfC0jyZuj5nBihLS8fom+QV65WTC9fVX0FCjtA7JEsauIVDs8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=FMlOqcPq; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FMlOqcPq" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=prullTp9LHQrqh8Xt6O1yFS0g5pZcBygbWXiKMvvhew=; b=FMlOqcPqVjecSD8em2VRwNK20W n/teCXxTJdwJtTvATkIzt2dsoGG2TdG+x72oBViP/oQ7qw829p+YaTBj67io4mICxgllIZFO9tLx4 9DmW83YkAN+FQOGIy71pUUe2K4hF11U/PpvfeQdJMn0/gsOcvxWKHQb0hMtXiEpfLz6FZHf4YMBPX NhxfNAS/zGR8O6E7P8dSwhEkIr/wx3DmGICjP/OTVtRPl6c4D6mYmwGRmapu3uD7aEDgch3Zrb1rJ Clht9D6ZQrWrAOpykmwUFEyZOiVJbOC62PzocZHTFp+CDnxqnA03D69jvm09Xfpf8m3z/qCzedudy D5n6VcRA==; Received: from [2604:3d08:797f:2840::9d5f] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vx47O-0000000DDSc-2lI3; Mon, 02 Mar 2026 14:19:30 +0000 From: Christoph Hellwig To: Eric Biggers Cc: "Theodore Y. Ts'o" , Jaegeuk Kim , Andreas Dilger , Chao Yu , Christian Brauner , "Darrick J. Wong" , linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Subject: [PATCH 06/14] fscrypt: pass a byte offset to fscrypt_generate_dun Date: Mon, 2 Mar 2026 06:18:11 -0800 Message-ID: <20260302141922.370070-7-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260302141922.370070-1-hch@lst.de> References: <20260302141922.370070-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Logical offsets into an inode are usually expressed as bytes in the VFS. Switch fscrypt_generate_dun to that convention and remove the ci_data_units_per_block_bits member in struct fscrypt_inode_info that was only used to cache the DUN shift based on the logical block size granularity. Signed-off-by: Christoph Hellwig --- fs/crypto/fscrypt_private.h | 3 --- fs/crypto/inline_crypt.c | 10 ++++------ fs/crypto/keysetup.c | 2 -- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 4e8e82a9ccf9..8d3c278a7591 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -278,9 +278,6 @@ struct fscrypt_inode_info { */ u8 ci_data_unit_bits; - /* Cached value: log2 of number of data units per FS block */ - u8 ci_data_units_per_block_bits; - /* Hashed inode number. Only set for IV_INO_LBLK_32 */ u32 ci_hashed_ino; diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index 702d13d138aa..5279565e9846 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -268,14 +268,12 @@ bool __fscrypt_inode_uses_inline_crypto(const struct inode *inode) EXPORT_SYMBOL_GPL(__fscrypt_inode_uses_inline_crypto); static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci, - u64 lblk_num, - u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) + loff_t pos, u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) { - u64 index = lblk_num << ci->ci_data_units_per_block_bits; union fscrypt_iv iv; int i; - fscrypt_generate_iv(&iv, index, ci); + fscrypt_generate_iv(&iv, pos >> ci->ci_data_unit_bits, ci); BUILD_BUG_ON(FSCRYPT_MAX_IV_SIZE > BLK_CRYPTO_MAX_IV_SIZE); memset(dun, 0, BLK_CRYPTO_MAX_IV_SIZE); @@ -309,7 +307,7 @@ void fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, return; ci = fscrypt_get_inode_info_raw(inode); - fscrypt_generate_dun(ci, first_lblk, dun); + fscrypt_generate_dun(ci, first_lblk << inode->i_blkbits, dun); bio_crypt_set_ctx(bio, ci->ci_enc_key.blk_key, dun, gfp_mask); } EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx); @@ -356,7 +354,7 @@ bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, if (bc->bc_key != ci->ci_enc_key.blk_key) return false; - fscrypt_generate_dun(ci, next_lblk, next_dun); + fscrypt_generate_dun(ci, next_lblk << inode->i_blkbits, next_dun); return bio_crypt_dun_is_contiguous(bc, bio->bi_iter.bi_size, next_dun); } EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio); diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 40fa05688d3a..d83257e9945e 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -609,8 +609,6 @@ fscrypt_setup_encryption_info(struct inode *inode, crypt_info->ci_data_unit_bits = fscrypt_policy_du_bits(&crypt_info->ci_policy, inode); - crypt_info->ci_data_units_per_block_bits = - inode->i_blkbits - crypt_info->ci_data_unit_bits; res = setup_file_encryption_key(crypt_info, need_dirhash_key, &mk); if (res) -- 2.47.3 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 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19CB6EA4E0D for ; Mon, 2 Mar 2026 14:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6hXny1585FwmpVqKj0UmQ582Anr2/yxhxZWFKKutcQc=; b=dpqjT9SplKUzgwuyeYZbB14Qyq LLRpX+PGyf2B5XhRj9+Ucn1eIn5Z2KhMHF1U+plUYZFDyLT9urlRsgRMVohh1Fx0cROjj4HCohy70 3EvdoeUNmbPeoA9ZjjtBM30arLes/NCX+pzPMsopefdzXU3JKQxGB1QVzDXO/Jrc7OUs=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vx47V-0005ux-VX; Mon, 02 Mar 2026 14:19:38 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vx47U-0005uh-Bv for linux-f2fs-devel@lists.sourceforge.net; Mon, 02 Mar 2026 14:19:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=prullTp9LHQrqh8Xt6O1yFS0g5pZcBygbWXiKMvvhew=; b=KTjActa1mM+z0mv5fcizV6dA2a Qh1IqI93XchKUURBZ1Ng2rzsriUxPUWxJr1Y3yYTLqAS2dt4JlEJMUzN7JW0zFTSZTdg/iyf2EIrX 7NqpIun6ePQe98/veNbr5xX96evuUmM19ZFa74b+k3028ibiTf1jRVVeCg10u9/Wbljc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=prullTp9LHQrqh8Xt6O1yFS0g5pZcBygbWXiKMvvhew=; b=T1/k+sL/6FB4QdT4jbVDqXh7mg QMIlpvq7pPMuV1Ly7hwa2o2YRCLFJBwSI/TcpwldfJHqf9opMU+qmjTsgro8LU2VbLV2b1viZj0QZ 7lc5g5aIEwH5r4wjajlrs4X4ip90UGvtVJhD3Kf/TePUI2Y47Dz6vEGdHRp5skauylIk=; Received: from bombadil.infradead.org ([198.137.202.133]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vx47U-0001TR-N1 for linux-f2fs-devel@lists.sourceforge.net; Mon, 02 Mar 2026 14:19:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=prullTp9LHQrqh8Xt6O1yFS0g5pZcBygbWXiKMvvhew=; b=FMlOqcPqVjecSD8em2VRwNK20W n/teCXxTJdwJtTvATkIzt2dsoGG2TdG+x72oBViP/oQ7qw829p+YaTBj67io4mICxgllIZFO9tLx4 9DmW83YkAN+FQOGIy71pUUe2K4hF11U/PpvfeQdJMn0/gsOcvxWKHQb0hMtXiEpfLz6FZHf4YMBPX NhxfNAS/zGR8O6E7P8dSwhEkIr/wx3DmGICjP/OTVtRPl6c4D6mYmwGRmapu3uD7aEDgch3Zrb1rJ Clht9D6ZQrWrAOpykmwUFEyZOiVJbOC62PzocZHTFp+CDnxqnA03D69jvm09Xfpf8m3z/qCzedudy D5n6VcRA==; Received: from [2604:3d08:797f:2840::9d5f] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vx47O-0000000DDSc-2lI3; Mon, 02 Mar 2026 14:19:30 +0000 From: Christoph Hellwig To: Eric Biggers Date: Mon, 2 Mar 2026 06:18:11 -0800 Message-ID: <20260302141922.370070-7-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260302141922.370070-1-hch@lst.de> References: <20260302141922.370070-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Headers-End: 1vx47U-0001TR-N1 Subject: [f2fs-dev] [PATCH 06/14] fscrypt: pass a byte offset to fscrypt_generate_dun X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Brauner , "Theodore Y. Ts'o" , "Darrick J. Wong" , linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, Andreas Dilger , linux-fsdevel@vger.kernel.org, Jaegeuk Kim , linux-ext4@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Logical offsets into an inode are usually expressed as bytes in the VFS. Switch fscrypt_generate_dun to that convention and remove the ci_data_units_per_block_bits member in struct fscrypt_inode_info that was only used to cache the DUN shift based on the logical block size granularity. Signed-off-by: Christoph Hellwig --- fs/crypto/fscrypt_private.h | 3 --- fs/crypto/inline_crypt.c | 10 ++++------ fs/crypto/keysetup.c | 2 -- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 4e8e82a9ccf9..8d3c278a7591 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -278,9 +278,6 @@ struct fscrypt_inode_info { */ u8 ci_data_unit_bits; - /* Cached value: log2 of number of data units per FS block */ - u8 ci_data_units_per_block_bits; - /* Hashed inode number. Only set for IV_INO_LBLK_32 */ u32 ci_hashed_ino; diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index 702d13d138aa..5279565e9846 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -268,14 +268,12 @@ bool __fscrypt_inode_uses_inline_crypto(const struct inode *inode) EXPORT_SYMBOL_GPL(__fscrypt_inode_uses_inline_crypto); static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci, - u64 lblk_num, - u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) + loff_t pos, u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) { - u64 index = lblk_num << ci->ci_data_units_per_block_bits; union fscrypt_iv iv; int i; - fscrypt_generate_iv(&iv, index, ci); + fscrypt_generate_iv(&iv, pos >> ci->ci_data_unit_bits, ci); BUILD_BUG_ON(FSCRYPT_MAX_IV_SIZE > BLK_CRYPTO_MAX_IV_SIZE); memset(dun, 0, BLK_CRYPTO_MAX_IV_SIZE); @@ -309,7 +307,7 @@ void fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, return; ci = fscrypt_get_inode_info_raw(inode); - fscrypt_generate_dun(ci, first_lblk, dun); + fscrypt_generate_dun(ci, first_lblk << inode->i_blkbits, dun); bio_crypt_set_ctx(bio, ci->ci_enc_key.blk_key, dun, gfp_mask); } EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx); @@ -356,7 +354,7 @@ bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, if (bc->bc_key != ci->ci_enc_key.blk_key) return false; - fscrypt_generate_dun(ci, next_lblk, next_dun); + fscrypt_generate_dun(ci, next_lblk << inode->i_blkbits, next_dun); return bio_crypt_dun_is_contiguous(bc, bio->bi_iter.bi_size, next_dun); } EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio); diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 40fa05688d3a..d83257e9945e 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -609,8 +609,6 @@ fscrypt_setup_encryption_info(struct inode *inode, crypt_info->ci_data_unit_bits = fscrypt_policy_du_bits(&crypt_info->ci_policy, inode); - crypt_info->ci_data_units_per_block_bits = - inode->i_blkbits - crypt_info->ci_data_unit_bits; res = setup_file_encryption_key(crypt_info, need_dirhash_key, &mk); if (res) -- 2.47.3 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel