Skip to content

Commit 78c37eb

Browse files
Tao MaJoel Becker
authored andcommitted
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: Tao Ma <tao.ma@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com>
1 parent ee860b6 commit 78c37eb

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎fs/ocfs2/suballoc.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
152152

153153
#define do_error(fmt, ...) \
154154
do{ \
155-
if (clean_error) \
155+
if (resize) \
156156
mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \
157157
else \
158158
ocfs2_error(sb, fmt, ##__VA_ARGS__); \
159159
} while (0)
160160

161161
static int ocfs2_validate_gd_self(struct super_block *sb,
162162
struct buffer_head *bh,
163-
int clean_error)
163+
int resize)
164164
{
165165
struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
166166

@@ -211,7 +211,7 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
211211
static int ocfs2_validate_gd_parent(struct super_block *sb,
212212
struct ocfs2_dinode *di,
213213
struct buffer_head *bh,
214-
int clean_error)
214+
int resize)
215215
{
216216
unsigned int max_bits;
217217
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,
233233
return -EINVAL;
234234
}
235235

236-
if (le16_to_cpu(gd->bg_chain) >=
237-
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
236+
/* In resize, we may meet the case bg_chain == cl_next_free_rec. */
237+
if ((le16_to_cpu(gd->bg_chain) >
238+
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) ||
239+
((le16_to_cpu(gd->bg_chain) ==
240+
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) && !resize)) {
238241
do_error("Group descriptor #%llu has bad chain %u",
239242
(unsigned long long)bh->b_blocknr,
240243
le16_to_cpu(gd->bg_chain));

0 commit comments

Comments
 (0)