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 A2BCE224FA; Wed, 18 Feb 2026 06:16:18 +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=1771395379; cv=none; b=uJ/YcTl/Ko0CbakDLxLYHG+YW70urjr6EirJr6CL2rQc9OtX3srASJav3eDroZCDKuTvsd2qnjoP99+pxTS3PbzEpYT30W+FRfXmh2sr1WgyhQH8mGJr2BRUfnnRoT4+3IBkPtro7K37imKejLMQqXeCpEuUkXtdr8TVitBjgiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771395379; c=relaxed/simple; bh=TpMe5V2WMJ3UTEeHrFNYeh9FoFtCE36rBWY80BaEBZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OV5YZ0Z3pjt1ZabrOMMA4iC9jZoJFPerksEqhb0gcf+1oEKX8hlCj9JMA/M0T5e3CZE1dN3+gJgmjQKsQEXrFr55keZILeVfpdcX7tEV1uEXZIHdtliiC7N9QDfz2oExO9ItZwLNeN5RXENxer3C5O60gtFGDmJ06DF9vi7lTps= 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=M6ispzKd; 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="M6ispzKd" 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=0/vPyrZBFN5+lhr4fp6mgM2zMJF3Tz241yvSNPXAYqY=; b=M6ispzKd1X9+foZkFPC0oVRlKs nscrFla2hR1NyQL95kf7SeZ6r9uPhafSvC8d3jc8oYVQCNfuE36sVSiY7qj2UPuSdbcdWFALQenSW P+XTiCfXi8mrkWnIIR2G8boVb3lL1dNb/bIhBLB/JOCJ1Cly4SNBNz4SMBsGWLj3dC3GLMYUJ5xt8 YcRpyaFO/l+XN4PD9ldyqPxYfcE+DhCCdEuOLQlzQiF7KQVVCAfNlOdTrs3uAU6zqm2rzAyQZBPCf i6Fxmicc4LUop6VUYbfxw+DDU+nFll5UBEBg7uA+73rlDOIpWySd9CQ1NdaJ2K41oaCHBhKb+YMSH ovzg22Lw==; Received: from [2001:4bb8:2dc:9863:1842:9381:9c0f:de32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vsarB-00000009LiM-2rZy; Wed, 18 Feb 2026 06:16:18 +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 8/9] fscrypt: pass a byte length to fscrypt_zeroout_range Date: Wed, 18 Feb 2026 07:14:46 +0100 Message-ID: <20260218061531.3318130-9-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260218061531.3318130-1-hch@lst.de> References: <20260218061531.3318130-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 Range lengths are usually expressed as bytes in the VFS, switch fscrypt_zeroout_range to this convention. Signed-off-by: Christoph Hellwig --- fs/crypto/bio.c | 6 +++--- fs/ext4/inode.c | 3 ++- fs/f2fs/file.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index e41e605cf7e6..cea931620c04 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -115,7 +115,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode, * @inode: the file's inode * @pos: the first file logical offset (in bytes) to zero out * @pblk: the first filesystem physical block to zero out - * @len: number of blocks to zero out + * @len: bytes to zero out * * Zero out filesystem blocks in an encrypted regular file on-disk, i.e. write * ciphertext blocks which decrypt to the all-zeroes block. The blocks must be @@ -136,7 +136,7 @@ int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, const unsigned int du_per_page_bits = PAGE_SHIFT - du_bits; const unsigned int du_per_page = 1U << du_per_page_bits; u64 du_index = pos >> du_bits; - u64 du_remaining = (u64)len << (inode->i_blkbits - du_bits); + u64 du_remaining = len >> du_bits; loff_t pos = (loff_t)lblk << inode->i_blkbits; sector_t sector = pblk << (inode->i_blkbits - SECTOR_SHIFT); struct page *pages[16]; /* write up to 16 pages at a time */ @@ -151,7 +151,7 @@ int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, if (fscrypt_inode_uses_inline_crypto(inode)) return fscrypt_zeroout_range_inline_crypt(inode, pos, sector, - len << inode->i_blkbits); + len); BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS); nr_pages = min_t(u64, ARRAY_SIZE(pages), diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 945613c95ffa..675ef741cb30 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -406,7 +406,8 @@ int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk, if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) return fscrypt_zeroout_range(inode, - (loff_t)lblk << inode->i_blkbits, pblk, len); + (loff_t)lblk << inode->i_blkbits, pblk, + len << inode->i_blkbits); ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS); if (ret > 0) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 239c2666ceb5..5b7013f7f6a1 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4164,7 +4164,7 @@ static int f2fs_secure_erase(struct block_device *bdev, struct inode *inode, if (IS_ENCRYPTED(inode)) ret = fscrypt_zeroout_range(inode, (loff_t)off << inode->i_blkbits, block, - len); + len << inode->i_blkbits); else ret = blkdev_issue_zeroout(bdev, sector, nr_sects, GFP_NOFS, 0); -- 2.47.3