@@ -772,6 +772,7 @@ extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
extern struct inode *ext2_iget (struct super_block *, unsigned long);
extern int ext2_write_inode (struct inode *, struct writeback_control *);
extern void ext2_evict_inode(struct inode *);
+extern int ext2_block_to_path(struct super_block *sb, long i_block, int offsets[4], int *boundary);
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
extern int ext2_setattr (struct dentry *, struct iattr *);
extern void ext2_set_inode_flags(struct inode *inode);
@@ -132,7 +132,6 @@ static inline int verify_chain(Indirect *from, Indirect *to)
/**
* ext2_block_to_path - parse the block number into array of offsets
- * @inode: inode in question (we are only interested in its superblock)
* @i_block: block number to be parsed
* @offsets: array to store the offsets in
* @boundary: set this non-zero if the referred-to block is likely to be
@@ -160,11 +159,11 @@ static inline int verify_chain(Indirect *from, Indirect *to)
* get there at all.
*/
-static int ext2_block_to_path(struct inode *inode,
+int ext2_block_to_path(struct super_block *sb,
long i_block, int offsets[4], int *boundary)
{
- int ptrs = EXT2_ADDR_PER_BLOCK(inode->i_sb);
- int ptrs_bits = EXT2_ADDR_PER_BLOCK_BITS(inode->i_sb);
+ int ptrs = EXT2_ADDR_PER_BLOCK(sb);
+ int ptrs_bits = EXT2_ADDR_PER_BLOCK_BITS(sb);
const long direct_blocks = EXT2_NDIR_BLOCKS,
indirect_blocks = ptrs,
double_blocks = (1 << (ptrs_bits * 2));
@@ -172,7 +171,7 @@ static int ext2_block_to_path(struct inode *inode,
int final = 0;
if (i_block < 0) {
- ext2_msg(inode->i_sb, KERN_WARNING,
+ ext2_msg(sb, KERN_WARNING,
"warning: %s: block < 0", __func__);
} else if (i_block < direct_blocks) {
offsets[n++] = i_block;
@@ -193,7 +192,7 @@ static int ext2_block_to_path(struct inode *inode,
offsets[n++] = i_block & (ptrs - 1);
final = ptrs;
} else {
- ext2_msg(inode->i_sb, KERN_WARNING,
+ ext2_msg(sb, KERN_WARNING,
"warning: %s: block is too big", __func__);
}
if (boundary)
@@ -637,7 +636,8 @@ static int ext2_get_blocks(struct inode *inode,
BUG_ON(maxblocks == 0);
- depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
+ depth = ext2_block_to_path(inode->i_sb, iblock,
+ offsets, &blocks_to_boundary);
if (depth == 0)
return -EIO;
@@ -1194,7 +1194,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
WARN_ON(!rwsem_is_locked(&ei->dax_sem));
#endif
- n = ext2_block_to_path(inode, iblock, offsets, NULL);
+ n = ext2_block_to_path(inode->i_sb, iblock, offsets, NULL);
if (n == 0)
return;
This function will be used to get exact size in ext2_max_size future. Signed-off-by: yangerkun <yangerkun@huawei.com> --- fs/ext2/ext2.h | 1 + fs/ext2/inode.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-)