The ext2_extent_info.max_depth is zero-based (e.g., it is zero when
the entire extent tree fits in the inode). Hence, if it is equal to
MAX_EXTENT_DEPTH_COUNT we should always rebuild the extent tree to
shorten it.
Also, for 1k block file systems, it's possible for the worst-case
extent tree in its most compact form to have a maximum depth of 6, not
5. So set MAX_EXTENT_DEPTH_COUNT to 8 just to be sure we have plenty
of headroom. (The kernel supports an extent depth up to 2**16, but
e2fsck only keeps statistics up to MAX_EXTENT_DEPTH_COUNT, and if it's
deeper than that, we know that it will be profitable to rebuild the
extent tree in any case.)
Addresses-Coverity-Bug: 1507761
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
*/
typedef struct e2fsck_struct *e2fsck_t;
-#define MAX_EXTENT_DEPTH_COUNT 5
+#define MAX_EXTENT_DEPTH_COUNT 8
/*
* This strucutre is used to manage the list of extents in a file. Placing
sizeof(struct ext3_extent);
/* If the extent tree is too deep, then rebuild it. */
- if (info->max_depth > MAX_EXTENT_DEPTH_COUNT) {
+ if (info->max_depth > MAX_EXTENT_DEPTH_COUNT-1) {
pctx->blk = info->max_depth;
op = PR_1E_CAN_COLLAPSE_EXTENT_TREE;
goto rebuild;