# \[PATCH\] \_\_ext4\_get\_inode\_loc: use s\_inodes\_per\_block directly

- From: Coly Li \<hidden\>
- Date: 2011-01-24 18:54:24 
- List: linux-ext4
- Page: https://ratatoskr.run/linux-ext4/2011/01/13409162
- Thread: https://ratatoskr.run/linux-ext4/2011/01/13409162/t.md

```text
From: Coly Li <redacted>

In __ext4_get_inode_loc(), inodes_per_block is calculated by
(EXT4_BLOCK_SIZE(sb) / EXT4_INODE_SIZE(sb)). This is unncessary, the
value can be found directly from s_inodes_per_block.

Signed-off-by: Coly Li <redacted>
---
 fs/ext4/inode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 9f7f9e4..837c5a6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4668,7 +4668,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
 	/*
 	 * Figure out the offset within the block group inode table
 	 */
-	inodes_per_block = (EXT4_BLOCK_SIZE(sb) / EXT4_INODE_SIZE(sb));
+	inodes_per_block = EXT4_SB(sb)->s_inodes_per_block;
 	inode_offset = ((inode->i_ino - 1) %
 			EXT4_INODES_PER_GROUP(sb));
 	block = ext4_inode_table(sb, gdp) + (inode_offset / inodes_per_block);
-- 
1.7.3.2

```
