Index: head/sys/fs/ext2fs/ext2_extents.c =================================================================== --- head/sys/fs/ext2fs/ext2_extents.c +++ head/sys/fs/ext2fs/ext2_extents.c @@ -1159,14 +1159,13 @@ struct m_ext2fs *fs; e4fs_daddr_t newblk; - fs = ip->i_e2fs; - /* * We will allocate only single block for now. */ if (*count > 1) return (0); + fs = ip->i_e2fs; EXT2_LOCK(ip->i_ump); *perror = ext2_alloc(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newblk); if (*perror) @@ -1193,13 +1192,12 @@ unsigned long allocated = 0; int error = 0, depth; - fs = ip->i_e2fs; - *pallocated = 0; - path = NULL; if(bpp) *bpp = NULL; + *pallocated = 0; /* Check cache. */ + path = NULL; if ((bpref = ext4_ext_in_cache(ip, iblk, &newex))) { if (bpref == EXT4_EXT_CACHE_IN) { /* Block is already allocated. */ @@ -1271,6 +1269,7 @@ if (bpp) { + fs = ip->i_e2fs; error = bread(ip->i_devvp, fsbtodb(fs, newblk), fs->e2fs_bsize, cred, &bp); if (error) { @@ -1304,7 +1303,7 @@ ext4_ext_header(struct inode *ip) { - return (struct ext4_extent_header *)ip->i_db; + return ((struct ext4_extent_header *)ip->i_db); } static int @@ -1345,19 +1344,15 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_path *path, uint64_t start) { - struct m_ext2fs *fs; - int depth; struct ext4_extent_header *eh; + struct ext4_extent *ex; unsigned int a, b, block, num; unsigned long ex_blk; unsigned short ex_len; - struct ext4_extent *ex; + int depth; int error, correct_index; - fs = ip->i_e2fs; depth = ext4_ext_inode_depth(ip); - correct_index = 0; - if (!path[depth].ep_header) { if (path[depth].ep_data == NULL) return (EINVAL); @@ -1367,7 +1362,8 @@ eh = path[depth].ep_header; if (!eh) { - ext2_fserr(fs, ip->i_uid, "bad header => extent corrupted"); + ext2_fserr(ip->i_e2fs, ip->i_uid, + "bad header => extent corrupted"); return (EIO); } @@ -1375,6 +1371,8 @@ ex_blk = ex->e_blk; ex_len = ext4_ext_get_actual_len(ex); + error = 0; + correct_index = 0; while (ex >= EXT_FIRST_EXTENT(eh) && ex_blk + ex_len > start) { path[depth].ep_ext = ex; a = ex_blk > start ? ex_blk : start; @@ -1442,7 +1440,6 @@ int error; fs = ip->i_e2fs; - error = bread(ip->i_devvp, fsbtodb(fs, pblk), fs->e2fs_bsize, NOCRED, &bp); if (error) { @@ -1506,10 +1503,10 @@ if (!path) return (ENOMEM); - i = 0; path[0].ep_header = ehp; path[0].ep_depth = depth; - while (i >= 0 && error == 0) { + i = 0; + while (error == 0 && i >= 0) { if (i == depth) { /* This is leaf. */ error = ext4_ext_rm_leaf(ip, path, length); @@ -1568,7 +1565,6 @@ ext4_ext_header(ip)->eh_depth = 0; ext4_ext_header(ip)->eh_max = ext4_ext_space_root(ip); ext4_ext_dirty(ip, path); - } ext4_ext_drop_refs(path);