vfs: follow-on fixes for i_ino widening
Subsystems (6)
v3 cover vfs: follow-on fixes for i_ino widening
Just some patches to fix follow-on issues reported after the inode->i_ino widening series. Christian, could you toss these onto the vfs-7.1.kino branch?
---
Changes in v3:
- nilfs2: find index with bitwise & operation instead of div_u64_rem()
- add compile-time assertion that NILFS_BMAP_GROUP_DIV is power of two
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- rename variable in nilfs2 patch from "rem" to "index"
- reword comment and commit log for better accuracy in EVM patch
---
Jeff Layton (2):
EVM: add comment describing why ino field is still unsigned long
nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
fs/nilfs2/bmap.c | 15 +++++++++++---- security/integrity/evm/evm_crypto.c | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
---
base-commit: 9840bb66e7e5dffd72b03201318f154a10b06b4a
change-id: 20260310-iino-u64-424fa570d850
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
PATCH v3 1/2 EVM: add comment describing why ino field is still unsigned long
Mimi pointed out that we didn't widen the inode number field in struct h_misc alongside the inode->i_ino widening. While we could make an equivalent change there, that would require EVM resigning on all 32-bit hosts.
Instead, leave the field as an unsigned long. This should have no effect on 64-bit hosts, and allow things to continue working on 32-bit hosts in the cases where the i_ino fits in 32-bits.
Add a comment explaining why it's being left as unsigned long.
--- security/integrity/evm/evm_crypto.c | 6 ++++++ 1 file changed, 6 insertions(+)
security/integrity/evm/evm_crypto.c +6 -0
@@ -144,6 +144,12 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, char type, char *digest) { struct h_misc { +/* +* Although inode->i_ino is now u64, this field remains +* unsigned long to allow existing HMAC and signatures from +* 32-bit hosts to continue working when i_ino hasn't changed +* and fits in a u32. +*/ unsigned long ino;__u32 generation;uid_t uid;
Signature · 1 line
2.53.0
PATCH v3 2/2 nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
In reply to Jeff LaytonWith the change to make inode->i_ino a u64, the build started failing on 32-bit ARM with:
ERROR: modpost: "__aeabi_uldivmod" [fs/nilfs2/nilfs2.ko] undefined!
Fix this by using udiv_u64() for the division.
For finding the index into the group, switch to using a bitwise & operation since that's more efficient. With this change however, NILFS_BMAP_GROUP_DIV must be a power of two, so add a compile-time assertion for that.
--- fs/nilfs2/bmap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/nilfs2/bmap.c +11 -4
@@ -450,18 +450,25 @@ __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key)return NILFS_BMAP_INVALID_PTR ; } -#define NILFS_BMAP_GROUP_DIV 8 +#define NILFS_BMAP_GROUP_DIV 8/* must be power of 2 */ +__u64 nilfs_bmap_find_target_in_group (const struct nilfs_bmap *bmap) {struct inode *dat =nilfs_bmap_get_dat (bmap);unsigned long entries_per_group =nilfs_palloc_entries_per_group (dat); -unsigned long group = bmap->b_inode->i_ino / entries_per_group; +unsigned long group; +u32 index; + +BUILD_BUG_ON_NOT_POWER_OF_2 (NILFS_BMAP_GROUP_DIV ); + + group =div_u64 (bmap->b_inode->i_ino, entries_per_group); + index = bmap->b_inode->i_ino & (NILFS_BMAP_GROUP_DIV -1 );return group * entries_per_group + - (bmap->b_inode->i_ino %NILFS_BMAP_GROUP_DIV ) * - (entries_per_group /NILFS_BMAP_GROUP_DIV ); + index * (entries_per_group /NILFS_BMAP_GROUP_DIV ); } +static struct lock_class_key nilfs_bmap_dat_lock_key;static struct lock_class_key nilfs_bmap_mdt_lock_key;
Signature · 1 line
2.53.0
Quoted 3 lines · Jeff Layton
Just some patches to fix follow-on issues reported after the
inode->i_inowidening series. Christian, could you toss these onto the vfs-7.1.kino branch?
Applied to the vfs-7.1.kino branch of the vfs/vfs.git tree. Patches in the vfs-7.1.kino branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.1.kino
[1/2] EVM: add comment describing why ino field is still unsigned long
https://git.kernel.org/vfs/vfs/c/bef5b11087ce [2/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group() https://git.kernel.org/vfs/vfs/c/81359c146fba