Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fscrypt: pass a byte length to fscrypt_zeroout_range

Range lengths are usually expressed as bytes in the VFS, switch
fscrypt_zeroout_range to this convention.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20260302141922.370070-13-hch@lst.de
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

authored by

Christoph Hellwig and committed by
Eric Biggers
fb87ab4a cd7db2e7

+12 -10
+6 -5
fs/crypto/bio.c
··· 115 115 * @inode: the file's inode 116 116 * @pos: the first file position (in bytes) to zero out 117 117 * @pblk: the first filesystem physical block to zero out 118 - * @len: number of blocks to zero out 118 + * @len: bytes to zero out 119 119 * 120 120 * Zero out filesystem blocks in an encrypted regular file on-disk, i.e. write 121 121 * ciphertext blocks which decrypt to the all-zeroes block. The blocks must be 122 122 * both logically and physically contiguous. It's also assumed that the 123 - * filesystem only uses a single block device, ->s_bdev. 123 + * filesystem only uses a single block device, ->s_bdev. @len must be a 124 + * multiple of the file system logical block size. 124 125 * 125 126 * Note that since each block uses a different IV, this involves writing a 126 127 * different ciphertext to each block; we can't simply reuse the same one. ··· 129 128 * Return: 0 on success; -errno on failure. 130 129 */ 131 130 int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 132 - sector_t pblk, unsigned int len) 131 + sector_t pblk, u64 len) 133 132 { 134 133 const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode); 135 134 const unsigned int du_bits = ci->ci_data_unit_bits; ··· 137 136 const unsigned int du_per_page_bits = PAGE_SHIFT - du_bits; 138 137 const unsigned int du_per_page = 1U << du_per_page_bits; 139 138 u64 du_index = pos >> du_bits; 140 - u64 du_remaining = (u64)len << (inode->i_blkbits - du_bits); 139 + u64 du_remaining = len >> du_bits; 141 140 sector_t sector = pblk << (inode->i_blkbits - SECTOR_SHIFT); 142 141 struct page *pages[16]; /* write up to 16 pages at a time */ 143 142 unsigned int nr_pages; ··· 151 150 152 151 if (fscrypt_inode_uses_inline_crypto(inode)) 153 152 return fscrypt_zeroout_range_inline_crypt(inode, pos, sector, 154 - (u64)len << inode->i_blkbits); 153 + len); 155 154 156 155 BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS); 157 156 nr_pages = min_t(u64, ARRAY_SIZE(pages),
+2 -1
fs/ext4/inode.c
··· 406 406 407 407 if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) 408 408 return fscrypt_zeroout_range(inode, 409 - (loff_t)lblk << inode->i_blkbits, pblk, len); 409 + (loff_t)lblk << inode->i_blkbits, pblk, 410 + (u64)len << inode->i_blkbits); 410 411 411 412 ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS); 412 413 if (ret > 0)
+1 -1
fs/f2fs/file.c
··· 4164 4164 if (IS_ENCRYPTED(inode)) 4165 4165 ret = fscrypt_zeroout_range(inode, 4166 4166 (loff_t)off << inode->i_blkbits, block, 4167 - len); 4167 + (u64)len << inode->i_blkbits); 4168 4168 else 4169 4169 ret = blkdev_issue_zeroout(bdev, sector, nr_sects, 4170 4170 GFP_NOFS, 0);
+3 -3
include/linux/fscrypt.h
··· 450 450 451 451 /* bio.c */ 452 452 bool fscrypt_decrypt_bio(struct bio *bio); 453 - int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 454 - sector_t pblk, unsigned int len); 453 + int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, sector_t pblk, 454 + u64 len); 455 455 456 456 /* hooks.c */ 457 457 int fscrypt_file_open(struct inode *inode, struct file *filp); ··· 756 756 } 757 757 758 758 static inline int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 759 - sector_t pblk, unsigned int len) 759 + sector_t pblk, u64 len) 760 760 { 761 761 return -EOPNOTSUPP; 762 762 }