mirror of
https://github.com/adulau/aha.git
synced 2025-01-01 05:36:24 +00:00
[GFS2] Fix bug in directory expansion code
We didn't properly check that leaf splitting was allowed. We do now. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
parent
d0dc80dbaf
commit
e90deff533
1 changed files with 14 additions and 9 deletions
|
@ -940,10 +940,15 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
|
||||||
/* Get the old leaf block */
|
/* Get the old leaf block */
|
||||||
error = get_leaf(dip, leaf_no, &obh);
|
error = get_leaf(dip, leaf_no, &obh);
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
return error;
|
||||||
|
|
||||||
|
oleaf = (struct gfs2_leaf *)obh->b_data;
|
||||||
|
if (dip->i_di.di_depth == be16_to_cpu(oleaf->lf_depth)) {
|
||||||
|
brelse(obh);
|
||||||
|
return 1; /* can't split */
|
||||||
|
}
|
||||||
|
|
||||||
gfs2_trans_add_bh(dip->i_gl, obh, 1);
|
gfs2_trans_add_bh(dip->i_gl, obh, 1);
|
||||||
oleaf = (struct gfs2_leaf *)obh->b_data;
|
|
||||||
|
|
||||||
nleaf = new_leaf(inode, &nbh, be16_to_cpu(oleaf->lf_depth) + 1);
|
nleaf = new_leaf(inode, &nbh, be16_to_cpu(oleaf->lf_depth) + 1);
|
||||||
if (!nleaf) {
|
if (!nleaf) {
|
||||||
|
@ -956,6 +961,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
|
||||||
len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth));
|
len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth));
|
||||||
half_len = len >> 1;
|
half_len = len >> 1;
|
||||||
if (!half_len) {
|
if (!half_len) {
|
||||||
|
printk(KERN_WARNING "di_depth %u lf_depth %u index %u\n", dip->i_di.di_depth, be16_to_cpu(oleaf->lf_depth), index);
|
||||||
gfs2_consist_inode(dip);
|
gfs2_consist_inode(dip);
|
||||||
error = -EIO;
|
error = -EIO;
|
||||||
goto fail_brelse;
|
goto fail_brelse;
|
||||||
|
@ -1043,8 +1049,6 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
|
||||||
|
|
||||||
fail_brelse:
|
fail_brelse:
|
||||||
brelse(obh);
|
brelse(obh);
|
||||||
|
|
||||||
fail:
|
|
||||||
brelse(nbh);
|
brelse(nbh);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -1570,15 +1574,16 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
|
||||||
error = dir_split_leaf(inode, name);
|
error = dir_split_leaf(inode, name);
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
continue;
|
continue;
|
||||||
if (error != -ENOSPC)
|
if (error < 0)
|
||||||
break;
|
break;
|
||||||
if (ip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) {
|
if (ip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) {
|
||||||
error = dir_double_exhash(ip);
|
error = dir_double_exhash(ip);
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
error = dir_split_leaf(inode, name);
|
error = dir_split_leaf(inode, name);
|
||||||
if (error)
|
if (error < 0)
|
||||||
break;
|
break;
|
||||||
|
if (error == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
error = dir_new_leaf(inode, name);
|
error = dir_new_leaf(inode, name);
|
||||||
|
|
Loading…
Reference in a new issue