Skip to content

Commit

Permalink
libext2fs: set interior tree block goal more intelligently
Browse files Browse the repository at this point in the history
When we're splitting an extent node, try to allocate the new interior
tree block just prior to the first extent in the block we're trying to
split.  The previous logic only set a goal block if we had to split
both the current node and its parent, which is somewhat infrequent.
When that would happen, the goal would start at zero, leading to poor
locality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
djwong authored and tytso committed Dec 14, 2014
1 parent 7b486ec commit 6509eeb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
20 changes: 19 additions & 1 deletion lib/ext2fs/extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,25 @@ static errcode_t extent_node_split(ext2_extent_handle_t handle,
orig_height = info.max_depth - info.curr_level;
orig_lblk = extent.e_lblk;

/* Try to put the index block before the first extent */
path = handle->path + handle->level;
eh = (struct ext3_extent_header *) path->buf;
if (handle->level == handle->max_depth) {
struct ext3_extent *ex;

ex = EXT_FIRST_EXTENT(eh);
goal_blk = ext2fs_le32_to_cpu(ex->ee_start) +
((__u64) ext2fs_le16_to_cpu(ex->ee_start_hi) << 32);
} else {
struct ext3_extent_idx *ix;

ix = EXT_FIRST_INDEX(eh);
goal_blk = ext2fs_le32_to_cpu(ix->ei_leaf) +
((__u64) ext2fs_le16_to_cpu(ix->ei_leaf_hi) << 32);
}
goal_blk -= EXT2FS_CLUSTER_RATIO(handle->fs);
goal_blk &= ~EXT2FS_CLUSTER_MASK(handle->fs);

/* Is there room in the parent for a new entry? */
if (handle->level &&
(handle->path[handle->level - 1].entries >=
Expand All @@ -947,7 +966,6 @@ static errcode_t extent_node_split(ext2_extent_handle_t handle,
retval = ext2fs_extent_get(handle, EXT2_EXTENT_UP, &extent);
if (retval)
goto done;
goal_blk = extent.e_pblk;

retval = extent_node_split(handle, expand_allowed);
if (retval)
Expand Down
2 changes: 1 addition & 1 deletion tests/f_extents2/expect.1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -(25--34) -(155--199)
Block bitmap differences: -(25--33) -(154--199)
Fix? yes

Free blocks count wrong for group #0 (65535, counted=55).
Expand Down
10 changes: 5 additions & 5 deletions tests/m_bigjournal/expect.1
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Group 0: (Blocks 0-32767)
Reserved GDT blocks at 2-672
Block bitmap at 673 (+673), Inode bitmap at 757 (+757)
Inode table at 841-841 (+841)
31836 free blocks, 5 free inodes, 2 directories, 5 unused inodes
Free blocks: 932-32767
31837 free blocks, 5 free inodes, 2 directories, 5 unused inodes
Free blocks: 931-32767
Free inodes: 12-16
Group 1: (Blocks 32768-65535) [INODE_UNINIT, BLOCK_UNINIT]
Backup superblock at 32768, Group descriptors at 32769-32769
Expand Down Expand Up @@ -297,11 +297,11 @@ Group 38: (Blocks 1245184-1277951) [INODE_UNINIT, BLOCK_UNINIT]
32768 free blocks, 16 free inodes, 0 directories, 16 unused inodes
Free blocks: 1245184-1277951
Free inodes: 609-624
Group 39: (Blocks 1277952-1310719) [INODE_UNINIT, BLOCK_UNINIT]
Group 39: (Blocks 1277952-1310719) [INODE_UNINIT]
Block bitmap at 712 (bg #0 + 712), Inode bitmap at 796 (bg #0 + 796)
Inode table at 880-880 (bg #0 + 880)
32768 free blocks, 16 free inodes, 0 directories, 16 unused inodes
Free blocks: 1277952-1310719
32767 free blocks, 16 free inodes, 0 directories, 16 unused inodes
Free blocks: 1277952-1310718
Free inodes: 625-640
Group 40: (Blocks 1310720-1343487) [INODE_UNINIT]
Block bitmap at 713 (bg #0 + 713), Inode bitmap at 797 (bg #0 + 797)
Expand Down

0 comments on commit 6509eeb

Please sign in to comment.