Skip to content

Commit fdbb6cd

Browse files
jc2870akpm00
authored andcommitted
ocfs2: correct l_next_free_rec in online check
Correct the value of l_next_free_rec to l_count during the online check, as done in the check_el() function in ocfs2_tools. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Julian Sun <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 34bb50c commit fdbb6cd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fs/ocfs2/inode.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
200200
return inode;
201201
}
202202

203+
static int ocfs2_dinode_has_extents(struct ocfs2_dinode *di)
204+
{
205+
/* inodes flagged with other stuff in id2 */
206+
if (di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
207+
OCFS2_CHAIN_FL | OCFS2_DEALLOC_FL))
208+
return 0;
209+
/* i_flags doesn't indicate when id2 is a fast symlink */
210+
if (S_ISLNK(di->i_mode) && di->i_size && di->i_clusters == 0)
211+
return 0;
212+
if (di->i_dyn_features & OCFS2_INLINE_DATA_FL)
213+
return 0;
214+
215+
return 1;
216+
}
203217

204218
/*
205219
* here's how inodes get read from disk:
@@ -1547,6 +1561,16 @@ static int ocfs2_filecheck_repair_inode_block(struct super_block *sb,
15471561
le32_to_cpu(di->i_fs_generation));
15481562
}
15491563

1564+
if (ocfs2_dinode_has_extents(di) &&
1565+
le16_to_cpu(di->id2.i_list.l_next_free_rec) > le16_to_cpu(di->id2.i_list.l_count)) {
1566+
di->id2.i_list.l_next_free_rec = di->id2.i_list.l_count;
1567+
changed = 1;
1568+
mlog(ML_ERROR,
1569+
"Filecheck: reset dinode #%llu: l_next_free_rec to %u\n",
1570+
(unsigned long long)bh->b_blocknr,
1571+
le16_to_cpu(di->id2.i_list.l_next_free_rec));
1572+
}
1573+
15501574
if (changed || ocfs2_validate_meta_ecc(sb, bh->b_data, &di->i_check)) {
15511575
ocfs2_compute_meta_ecc(sb, bh->b_data, &di->i_check);
15521576
mark_buffer_dirty(bh);

0 commit comments

Comments
 (0)