Skip to content

Commit 566a2ab

Browse files
author
Andreas Gruenbacher
committed
gfs2: Another gfs2_walk_metadata fix
Make sure we don't walk past the end of the metadata in gfs2_walk_metadata: the inode holds fewer pointers than indirect blocks. Slightly clean up gfs2_iomap_get. Fixes: a27a0c9 ("gfs2: gfs2_walk_metadata fix") Cc: [email protected] # v5.3+ Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent d22f69a commit 566a2ab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fs/gfs2/bmap.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,12 @@ static int gfs2_walk_metadata(struct inode *inode, struct metapath *mp,
528528

529529
/* Advance in metadata tree. */
530530
(mp->mp_list[hgt])++;
531-
if (mp->mp_list[hgt] >= sdp->sd_inptrs) {
532-
if (!hgt)
531+
if (hgt) {
532+
if (mp->mp_list[hgt] >= sdp->sd_inptrs)
533+
goto lower_metapath;
534+
} else {
535+
if (mp->mp_list[hgt] >= sdp->sd_diptrs)
533536
break;
534-
goto lower_metapath;
535537
}
536538

537539
fill_up_metapath:
@@ -876,10 +878,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
876878
ret = -ENOENT;
877879
goto unlock;
878880
} else {
879-
/* report a hole */
880881
iomap->offset = pos;
881882
iomap->length = length;
882-
goto do_alloc;
883+
goto hole_found;
883884
}
884885
}
885886
iomap->length = size;
@@ -933,8 +934,6 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
933934
return ret;
934935

935936
do_alloc:
936-
iomap->addr = IOMAP_NULL_ADDR;
937-
iomap->type = IOMAP_HOLE;
938937
if (flags & IOMAP_REPORT) {
939938
if (pos >= size)
940939
ret = -ENOENT;
@@ -956,6 +955,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
956955
if (pos < size && height == ip->i_height)
957956
ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
958957
}
958+
hole_found:
959+
iomap->addr = IOMAP_NULL_ADDR;
960+
iomap->type = IOMAP_HOLE;
959961
goto out;
960962
}
961963

0 commit comments

Comments
 (0)