Skip to content

Commit 90950ee

Browse files
Christoph HellwigEric Biggers
authored andcommitted
fscrypt: pass a byte length to fscrypt_zeroout_range_inline_crypt
Range lengths are usually expressed as bytes in the VFS, switch fscrypt_zeroout_range_inline_crypt to this convention. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20260302141922.370070-11-hch@lst.de Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent 090c5c1 commit 90950ee

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

fs/crypto/bio.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ static void fscrypt_zeroout_range_end_io(struct bio *bio)
7171

7272
static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
7373
loff_t pos, sector_t sector,
74-
unsigned int len)
74+
u64 len)
7575
{
76-
const unsigned int blockbits = inode->i_blkbits;
77-
const unsigned int blocks_per_page = 1 << (PAGE_SHIFT - blockbits);
7876
struct fscrypt_zero_done done = {
7977
.pending = ATOMIC_INIT(1),
8078
.done = COMPLETION_INITIALIZER_ONSTACK(done.done),
@@ -92,12 +90,10 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
9290
fscrypt_set_bio_crypt_ctx(bio, inode, pos, GFP_NOFS);
9391

9492
for (n = 0; n < BIO_MAX_VECS; n++) {
95-
unsigned int blocks_this_page =
96-
min(len, blocks_per_page);
97-
unsigned int bytes_this_page = blocks_this_page << blockbits;
93+
unsigned int bytes_this_page = min(len, PAGE_SIZE);
9894

9995
__bio_add_page(bio, ZERO_PAGE(0), bytes_this_page, 0);
100-
len -= blocks_this_page;
96+
len -= bytes_this_page;
10197
pos += bytes_this_page;
10298
sector += (bytes_this_page >> SECTOR_SHIFT);
10399
if (!len || !fscrypt_mergeable_bio(bio, inode, pos))
@@ -155,7 +151,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
155151

156152
if (fscrypt_inode_uses_inline_crypto(inode))
157153
return fscrypt_zeroout_range_inline_crypt(inode, pos, sector,
158-
len);
154+
(u64)len << inode->i_blkbits);
159155

160156
BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS);
161157
nr_pages = min_t(u64, ARRAY_SIZE(pages),

0 commit comments

Comments
 (0)