Skip to content

Commit 9a790ba

Browse files
Tristan Yejlbec
authored andcommitted
ocfs2: skip existing hole when removing the last extent_rec in punching-hole codes.
In the case of removing a partial extent record which covers a hole, current punching-hole logic will try to remove more than the length of whole extent record, which leads to the failure of following assert(fs/ocfs2/alloc.c): 5507 BUG_ON(cpos < le32_to_cpu(rec->e_cpos) || trunc_range > rec_range); This patch tries to skip existing hole at the last attempt of removing a partial extent record, what's more, it also adds some necessary comments for better understanding of punching-hole codes. Signed-off-by: Tristan Ye <tristan.ye@oracle.com> Signed-off-by: Joel Becker <jlbec@evilplan.org>
1 parent 5d44670 commit 9a790ba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/ocfs2/file.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode,
16071607
range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec);
16081608

16091609
if (le32_to_cpu(rec->e_cpos) >= trunc_start) {
1610+
/*
1611+
* remove an entire extent record.
1612+
*/
16101613
*trunc_cpos = le32_to_cpu(rec->e_cpos);
16111614
/*
16121615
* Skip holes if any.
@@ -1617,7 +1620,16 @@ static void ocfs2_calc_trunc_pos(struct inode *inode,
16171620
*blkno = le64_to_cpu(rec->e_blkno);
16181621
*trunc_end = le32_to_cpu(rec->e_cpos);
16191622
} else if (range > trunc_start) {
1623+
/*
1624+
* remove a partial extent record, which means we're
1625+
* removing the last extent record.
1626+
*/
16201627
*trunc_cpos = trunc_start;
1628+
/*
1629+
* skip hole if any.
1630+
*/
1631+
if (range < *trunc_end)
1632+
*trunc_end = range;
16211633
*trunc_len = *trunc_end - trunc_start;
16221634
coff = trunc_start - le32_to_cpu(rec->e_cpos);
16231635
*blkno = le64_to_cpu(rec->e_blkno) +

0 commit comments

Comments
 (0)