|
@@ -1050,16 +1050,14 @@ cleanup:
|
|
*/
|
|
*/
|
|
static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
|
static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
|
unsigned int flags,
|
|
unsigned int flags,
|
|
- struct ext4_ext_path *path,
|
|
|
|
struct ext4_extent *newext)
|
|
struct ext4_extent *newext)
|
|
{
|
|
{
|
|
- struct ext4_ext_path *curp = path;
|
|
|
|
struct ext4_extent_header *neh;
|
|
struct ext4_extent_header *neh;
|
|
struct buffer_head *bh;
|
|
struct buffer_head *bh;
|
|
ext4_fsblk_t newblock;
|
|
ext4_fsblk_t newblock;
|
|
int err = 0;
|
|
int err = 0;
|
|
|
|
|
|
- newblock = ext4_ext_new_meta_block(handle, inode, path,
|
|
|
|
|
|
+ newblock = ext4_ext_new_meta_block(handle, inode, NULL,
|
|
newext, &err, flags);
|
|
newext, &err, flags);
|
|
if (newblock == 0)
|
|
if (newblock == 0)
|
|
return err;
|
|
return err;
|
|
@@ -1079,7 +1077,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
|
}
|
|
}
|
|
|
|
|
|
/* move top-level index/leaf into new block */
|
|
/* move top-level index/leaf into new block */
|
|
- memmove(bh->b_data, curp->p_hdr, sizeof(EXT4_I(inode)->i_data));
|
|
|
|
|
|
+ memmove(bh->b_data, EXT4_I(inode)->i_data,
|
|
|
|
+ sizeof(EXT4_I(inode)->i_data));
|
|
|
|
|
|
/* set size of new block */
|
|
/* set size of new block */
|
|
neh = ext_block_hdr(bh);
|
|
neh = ext_block_hdr(bh);
|
|
@@ -1097,32 +1096,23 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- /* create index in new top-level index: num,max,pointer */
|
|
|
|
- err = ext4_ext_get_access(handle, inode, curp);
|
|
|
|
- if (err)
|
|
|
|
- goto out;
|
|
|
|
-
|
|
|
|
- curp->p_hdr->eh_magic = EXT4_EXT_MAGIC;
|
|
|
|
- curp->p_hdr->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode, 0));
|
|
|
|
- curp->p_hdr->eh_entries = cpu_to_le16(1);
|
|
|
|
- curp->p_idx = EXT_FIRST_INDEX(curp->p_hdr);
|
|
|
|
-
|
|
|
|
- if (path[0].p_hdr->eh_depth)
|
|
|
|
- curp->p_idx->ei_block =
|
|
|
|
- EXT_FIRST_INDEX(path[0].p_hdr)->ei_block;
|
|
|
|
- else
|
|
|
|
- curp->p_idx->ei_block =
|
|
|
|
- EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block;
|
|
|
|
- ext4_idx_store_pblock(curp->p_idx, newblock);
|
|
|
|
-
|
|
|
|
|
|
+ /* Update top-level index: num,max,pointer */
|
|
neh = ext_inode_hdr(inode);
|
|
neh = ext_inode_hdr(inode);
|
|
|
|
+ neh->eh_entries = cpu_to_le16(1);
|
|
|
|
+ ext4_idx_store_pblock(EXT_FIRST_INDEX(neh), newblock);
|
|
|
|
+ if (neh->eh_depth == 0) {
|
|
|
|
+ /* Root extent block becomes index block */
|
|
|
|
+ neh->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode, 0));
|
|
|
|
+ EXT_FIRST_INDEX(neh)->ei_block =
|
|
|
|
+ EXT_FIRST_EXTENT(neh)->ee_block;
|
|
|
|
+ }
|
|
ext_debug("new root: num %d(%d), lblock %d, ptr %llu\n",
|
|
ext_debug("new root: num %d(%d), lblock %d, ptr %llu\n",
|
|
le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max),
|
|
le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max),
|
|
le32_to_cpu(EXT_FIRST_INDEX(neh)->ei_block),
|
|
le32_to_cpu(EXT_FIRST_INDEX(neh)->ei_block),
|
|
ext4_idx_pblock(EXT_FIRST_INDEX(neh)));
|
|
ext4_idx_pblock(EXT_FIRST_INDEX(neh)));
|
|
|
|
|
|
- neh->eh_depth = cpu_to_le16(path->p_depth + 1);
|
|
|
|
- err = ext4_ext_dirty(handle, inode, curp);
|
|
|
|
|
|
+ neh->eh_depth = cpu_to_le16(neh->eh_depth + 1);
|
|
|
|
+ ext4_mark_inode_dirty(handle, inode);
|
|
out:
|
|
out:
|
|
brelse(bh);
|
|
brelse(bh);
|
|
|
|
|
|
@@ -1170,8 +1160,7 @@ repeat:
|
|
err = PTR_ERR(path);
|
|
err = PTR_ERR(path);
|
|
} else {
|
|
} else {
|
|
/* tree is full, time to grow in depth */
|
|
/* tree is full, time to grow in depth */
|
|
- err = ext4_ext_grow_indepth(handle, inode, flags,
|
|
|
|
- path, newext);
|
|
|
|
|
|
+ err = ext4_ext_grow_indepth(handle, inode, flags, newext);
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|