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 6EE2B2D372D; Wed, 17 Dec 2025 06:07:50 +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=1765951673; cv=none; b=cCROkRm+PGibmwd/W0dm82FJONzov3qBBqm8YZmXQqwq7wB6jLQACv+dMlau6IXJ8ytIS9g7swBt3c+LarvmnNmQUIg62SNpwdMw/WK/kTXS1jjeJatZ+kuD1MOhCK6QNpVosjQG+GudMqAD7PkJUupklbC0ZHTc0BHOKzxoPkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765951673; c=relaxed/simple; bh=1gzmHIoEkFm4z6kmBVCGjRL1igGStJt/isu8E06b6QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qiI9KwunGpntLyfNwMr+IYerDyA5Z/V3vqRG0VE7Xb9h0WTPAspyCk6zz5mep2dkrwutRcd6i0d+w19am/ajLjlr61+bk/9to5GthSIwkX6P9u21B8l81qQ9XriZz3h5a89A2d1r9V04PQvOJoooMLdCCdhMqHMinQUwCGYR0v8= 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=4Mxa7fIP; 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="4Mxa7fIP" 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=N7zWXEuamRYFXAsXaiU69QdqNZY6RmV6pFikJMUdeew=; b=4Mxa7fIPgyYXg+ncUYrTcb5jOF 7tfMIg89MJtNHbNRNuhgZjnl8v3LZde3N6Hg5XMFo5VyD1g+8p3SH12q2rueXStXTHIEvOs5WFEOz 8YFPNPQDDxdJLdXyblw1tx2/9rkBptr8KUJCRmAs9fPdI4KF1QcPJclg1ZfKLIGdtowvzzYV+itZY Gu4ZJxstJybzGmyS3x7Zc0ga8pRSn3EcoQZwE5/1VALZGCRSup2HfRFfS11jr6C+t/Xk7FnI5Cq3o 6Y7Gl1yKxpT5NLoHCwlA/6Iw5Qswtxy6xDpvm80s6xO4aimwSl6Jyln4+kOSqnK+FS2wecZrFI02w FiovMzsw==; Received: from 2a02-8389-2341-5b80-d601-7564-c2e0-491c.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:d601:7564:c2e0:491c] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vVkhR-00000006DCW-2bNJ; Wed, 17 Dec 2025 06:07:49 +0000 From: Christoph Hellwig To: Jens Axboe , Eric Biggers Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org Subject: [PATCH 1/9] fscrypt: pass a real sector_t to fscrypt_zeroout_range_inline_crypt Date: Wed, 17 Dec 2025 07:06:44 +0100 Message-ID: <20251217060740.923397-2-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251217060740.923397-1-hch@lst.de> References: <20251217060740.923397-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@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 While the pblk argument to fscrypt_zeroout_range_inline_crypt is declared as a sector_t it actually is interpreted as a logical block size unit, which is highly unusual. Switch to passing the 512 byte units that sector_t is defined for. Signed-off-by: Christoph Hellwig Reviewed-by: Eric Biggers --- fs/crypto/bio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 5f5599020e94..68b0424d879a 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -48,7 +48,7 @@ bool fscrypt_decrypt_bio(struct bio *bio) EXPORT_SYMBOL(fscrypt_decrypt_bio); static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode, - pgoff_t lblk, sector_t pblk, + pgoff_t lblk, sector_t sector, unsigned int len) { const unsigned int blockbits = inode->i_blkbits; @@ -67,8 +67,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode, if (num_pages == 0) { fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOFS); - bio->bi_iter.bi_sector = - pblk << (blockbits - SECTOR_SHIFT); + bio->bi_iter.bi_sector = sector; } ret = bio_add_page(bio, ZERO_PAGE(0), bytes_this_page, 0); if (WARN_ON_ONCE(ret != bytes_this_page)) { @@ -78,7 +77,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode, num_pages++; len -= blocks_this_page; lblk += blocks_this_page; - pblk += blocks_this_page; + sector += (bytes_this_page >> SECTOR_SHIFT); if (num_pages == BIO_MAX_VECS || !len || !fscrypt_mergeable_bio(bio, inode, lblk)) { err = submit_bio_wait(bio); @@ -132,7 +131,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, return 0; if (fscrypt_inode_uses_inline_crypto(inode)) - return fscrypt_zeroout_range_inline_crypt(inode, lblk, pblk, + return fscrypt_zeroout_range_inline_crypt(inode, lblk, sector, len); BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS); -- 2.47.3