Commit 78c37eb0 authored by Tao Ma's avatar Tao Ma Committed by Joel Becker

ocfs2: Change bg_chain check for ocfs2_validate_gd_parent.

In ocfs2_validate_gd_parent, we check bg_chain against the
cl_next_free_rec of the dinode. Actually in resize, we have
the chance of bg_chain == cl_next_free_rec. So add some
additional condition check for it.

I also rename paramter "clean_error" to "resize", since the
old one is not clearly enough to indicate that we should only
meet with this case in resize.

btw, the correpsonding bug is
http://oss.oracle.com/bugzilla/show_bug.cgi?id=1230.
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent ee860b6a
...@@ -152,7 +152,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl) ...@@ -152,7 +152,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
#define do_error(fmt, ...) \ #define do_error(fmt, ...) \
do{ \ do{ \
if (clean_error) \ if (resize) \
mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \ mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \
else \ else \
ocfs2_error(sb, fmt, ##__VA_ARGS__); \ ocfs2_error(sb, fmt, ##__VA_ARGS__); \
...@@ -160,7 +160,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl) ...@@ -160,7 +160,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
static int ocfs2_validate_gd_self(struct super_block *sb, static int ocfs2_validate_gd_self(struct super_block *sb,
struct buffer_head *bh, struct buffer_head *bh,
int clean_error) int resize)
{ {
struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
...@@ -211,7 +211,7 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -211,7 +211,7 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
static int ocfs2_validate_gd_parent(struct super_block *sb, static int ocfs2_validate_gd_parent(struct super_block *sb,
struct ocfs2_dinode *di, struct ocfs2_dinode *di,
struct buffer_head *bh, struct buffer_head *bh,
int clean_error) int resize)
{ {
unsigned int max_bits; unsigned int max_bits;
struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
...@@ -233,8 +233,11 @@ static int ocfs2_validate_gd_parent(struct super_block *sb, ...@@ -233,8 +233,11 @@ static int ocfs2_validate_gd_parent(struct super_block *sb,
return -EINVAL; return -EINVAL;
} }
if (le16_to_cpu(gd->bg_chain) >= /* In resize, we may meet the case bg_chain == cl_next_free_rec. */
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) { if ((le16_to_cpu(gd->bg_chain) >
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) ||
((le16_to_cpu(gd->bg_chain) ==
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) && !resize)) {
do_error("Group descriptor #%llu has bad chain %u", do_error("Group descriptor #%llu has bad chain %u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_chain)); le16_to_cpu(gd->bg_chain));
......
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