Commit c0a4ef38 authored by Akinobu Mita's avatar Akinobu Mita Committed by Theodore Ts'o

ext4: use ext4_get_group_desc()

Use ext4_get_group_desc() in ext4_get_inode_block() instead of open
coding the functionality.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: adilger@clusterfs.com
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mingming Cao <cmm@us.ibm.com>
parent d00a6d7b
...@@ -2511,12 +2511,10 @@ void ext4_truncate(struct inode *inode) ...@@ -2511,12 +2511,10 @@ void ext4_truncate(struct inode *inode)
static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb, static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb,
unsigned long ino, struct ext4_iloc *iloc) unsigned long ino, struct ext4_iloc *iloc)
{ {
unsigned long desc, group_desc;
ext4_group_t block_group; ext4_group_t block_group;
unsigned long offset; unsigned long offset;
ext4_fsblk_t block; ext4_fsblk_t block;
struct buffer_head *bh; struct ext4_group_desc *gdp;
struct ext4_group_desc * gdp;
if (!ext4_valid_inum(sb, ino)) { if (!ext4_valid_inum(sb, ino)) {
/* /*
...@@ -2528,22 +2526,10 @@ static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb, ...@@ -2528,22 +2526,10 @@ static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb,
} }
block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
if (block_group >= EXT4_SB(sb)->s_groups_count) { gdp = ext4_get_group_desc(sb, block_group, NULL);
ext4_error(sb,"ext4_get_inode_block","group >= groups count"); if (!gdp)
return 0; return 0;
}
smp_rmb();
group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
desc = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
bh = EXT4_SB(sb)->s_group_desc[group_desc];
if (!bh) {
ext4_error (sb, "ext4_get_inode_block",
"Descriptor not loaded");
return 0;
}
gdp = (struct ext4_group_desc *)((__u8 *)bh->b_data +
desc * EXT4_DESC_SIZE(sb));
/* /*
* Figure out the offset within the block group inode table * Figure out the offset within the block group inode table
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment