summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-03-17 15:38:54 +0100
committerChristian Brauner <brauner@kernel.org>2026-03-17 15:38:54 +0100
commit2e43ca1a4f949e4beb763f8196695da02b17bd77 (patch)
tree37e7c99ed1cf5519ed37b192bd55aaedf2b1f591 /fs
parent9840bb66e7e5dffd72b03201318f154a10b06b4a (diff)
parent81359c146fba8d6a59db7e938c316776f63b9ee5 (diff)
downloadlwn-2e43ca1a4f949e4beb763f8196695da02b17bd77.tar.gz
lwn-2e43ca1a4f949e4beb763f8196695da02b17bd77.zip
Merge patch series "vfs: follow-on fixes for i_ino widening"
Jeff Layton <jlayton@kernel.org> says: Just some patches to fix follow-on issues reported after the inode->i_ino widening series. * patches from https://patch.msgid.link/20260316-iino-u64-v3-0-d1076b8f7a20@kernel.org: nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group() EVM: add comment describing why ino field is still unsigned long Link: https://patch.msgid.link/20260316-iino-u64-v3-0-d1076b8f7a20@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/bmap.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 824f2bd91c16..5f0f1f283af0 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -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;