Skip to content

Commit 0baaea6

Browse files
Lukas Czernertytso
authored andcommitted
ext4: use EXT_MAX_BLOCKS in ext4_es_can_be_merged()
In ext4_es_can_be_merged() when checking whether we can merge two extents we should use EXT_MAX_BLOCKS instead of defining it manually. Also if it is really the case we should notify userspace because clearly there is a bug in extent status tree implementation since this should never happen. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
1 parent 5d60125 commit 0baaea6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎fs/ext4/extents_status.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,14 @@ static int ext4_es_can_be_merged(struct extent_status *es1,
344344
if (ext4_es_status(es1) != ext4_es_status(es2))
345345
return 0;
346346

347-
if (((__u64) es1->es_len) + es2->es_len > 0xFFFFFFFFULL)
347+
if (((__u64) es1->es_len) + es2->es_len > EXT_MAX_BLOCKS) {
348+
pr_warn("ES assertion failed when merging extents. "
349+
"The sum of lengths of es1 (%d) and es2 (%d) "
350+
"is bigger than allowed file size (%d)\n",
351+
es1->es_len, es2->es_len, EXT_MAX_BLOCKS);
352+
WARN_ON(1);
348353
return 0;
354+
}
349355

350356
if (((__u64) es1->es_lblk) + es1->es_len != es2->es_lblk)
351357
return 0;

0 commit comments

Comments
 (0)