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 offset to fscrypt_zeroout_range

Logical offsets into an inode are usually expressed as bytes in the VFS.
Switch fscrypt_zeroout_range to that convention.

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

authored by

Christoph Hellwig and committed by
Eric Biggers
cd7db2e7 90950ee5

+10 -8
+3 -4
fs/crypto/bio.c
··· 113 113 /** 114 114 * fscrypt_zeroout_range() - zero out a range of blocks in an encrypted file 115 115 * @inode: the file's inode 116 - * @lblk: the first file logical block to zero out 116 + * @pos: the first file position (in bytes) to zero out 117 117 * @pblk: the first filesystem physical block to zero out 118 118 * @len: number of blocks to zero out 119 119 * ··· 127 127 * 128 128 * Return: 0 on success; -errno on failure. 129 129 */ 130 - int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, 130 + int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 131 131 sector_t pblk, unsigned int len) 132 132 { 133 133 const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode); ··· 135 135 const unsigned int du_size = 1U << du_bits; 136 136 const unsigned int du_per_page_bits = PAGE_SHIFT - du_bits; 137 137 const unsigned int du_per_page = 1U << du_per_page_bits; 138 - u64 du_index = (u64)lblk << (inode->i_blkbits - du_bits); 138 + u64 du_index = pos >> du_bits; 139 139 u64 du_remaining = (u64)len << (inode->i_blkbits - du_bits); 140 - loff_t pos = (loff_t)lblk << inode->i_blkbits; 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;
+2 -1
fs/ext4/inode.c
··· 405 405 KUNIT_STATIC_STUB_REDIRECT(ext4_issue_zeroout, inode, lblk, pblk, len); 406 406 407 407 if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) 408 - return fscrypt_zeroout_range(inode, lblk, pblk, len); 408 + return fscrypt_zeroout_range(inode, 409 + (loff_t)lblk << inode->i_blkbits, pblk, len); 409 410 410 411 ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS); 411 412 if (ret > 0)
+3 -1
fs/f2fs/file.c
··· 4162 4162 4163 4163 if (!ret && (flags & F2FS_TRIM_FILE_ZEROOUT)) { 4164 4164 if (IS_ENCRYPTED(inode)) 4165 - ret = fscrypt_zeroout_range(inode, off, block, len); 4165 + ret = fscrypt_zeroout_range(inode, 4166 + (loff_t)off << inode->i_blkbits, block, 4167 + len); 4166 4168 else 4167 4169 ret = blkdev_issue_zeroout(bdev, sector, nr_sects, 4168 4170 GFP_NOFS, 0);
+2 -2
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, pgoff_t lblk, 453 + int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 454 454 sector_t pblk, unsigned int len); 455 455 456 456 /* hooks.c */ ··· 755 755 return true; 756 756 } 757 757 758 - static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, 758 + static inline int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, 759 759 sector_t pblk, unsigned int len) 760 760 { 761 761 return -EOPNOTSUPP;