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_generate_dun

Logical offsets into an inode are usually expressed as bytes in the VFS.
Switch fscrypt_generate_dun to that convention and remove the
ci_data_units_per_block_bits member in struct fscrypt_inode_info that
was only used to cache the DUN shift based on the logical block size
granularity.

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

authored by

Christoph Hellwig and committed by
Eric Biggers
60b4fcb4 a18b1ab8

+4 -11
-3
fs/crypto/fscrypt_private.h
··· 278 278 */ 279 279 u8 ci_data_unit_bits; 280 280 281 - /* Cached value: log2 of number of data units per FS block */ 282 - u8 ci_data_units_per_block_bits; 283 - 284 281 /* Hashed inode number. Only set for IV_INO_LBLK_32 */ 285 282 u32 ci_hashed_ino; 286 283
+4 -6
fs/crypto/inline_crypt.c
··· 268 268 EXPORT_SYMBOL_GPL(__fscrypt_inode_uses_inline_crypto); 269 269 270 270 static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci, 271 - u64 lblk_num, 272 - u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) 271 + loff_t pos, u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) 273 272 { 274 - u64 index = lblk_num << ci->ci_data_units_per_block_bits; 275 273 union fscrypt_iv iv; 276 274 int i; 277 275 278 - fscrypt_generate_iv(&iv, index, ci); 276 + fscrypt_generate_iv(&iv, pos >> ci->ci_data_unit_bits, ci); 279 277 280 278 BUILD_BUG_ON(FSCRYPT_MAX_IV_SIZE > BLK_CRYPTO_MAX_IV_SIZE); 281 279 memset(dun, 0, BLK_CRYPTO_MAX_IV_SIZE); ··· 307 309 return; 308 310 ci = fscrypt_get_inode_info_raw(inode); 309 311 310 - fscrypt_generate_dun(ci, first_lblk, dun); 312 + fscrypt_generate_dun(ci, first_lblk << inode->i_blkbits, dun); 311 313 bio_crypt_set_ctx(bio, ci->ci_enc_key.blk_key, dun, gfp_mask); 312 314 } 313 315 EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx); ··· 354 356 if (bc->bc_key != ci->ci_enc_key.blk_key) 355 357 return false; 356 358 357 - fscrypt_generate_dun(ci, next_lblk, next_dun); 359 + fscrypt_generate_dun(ci, next_lblk << inode->i_blkbits, next_dun); 358 360 return bio_crypt_dun_is_contiguous(bc, bio->bi_iter.bi_size, next_dun); 359 361 } 360 362 EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio);
-2
fs/crypto/keysetup.c
··· 609 609 610 610 crypt_info->ci_data_unit_bits = 611 611 fscrypt_policy_du_bits(&crypt_info->ci_policy, inode); 612 - crypt_info->ci_data_units_per_block_bits = 613 - inode->i_blkbits - crypt_info->ci_data_unit_bits; 614 612 615 613 res = setup_file_encryption_key(crypt_info, need_dirhash_key, &mk); 616 614 if (res)