If we're going to read the "nr - 1" entry in an indirect block for use as a "goal" input to the block allocator, we need to byteswap the entry. While we're at it, if we're allocating blocks for the zeroth entry in the indirect block, we might as well use the indirect block as the starting point to try to reduce fragmentation. (d_fallocate_blkmap will test this...) Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- lib/ext2fs/bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index c1d0e6f..f819e9c 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -67,7 +67,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, #endif if (!b && (flags & BMAP_ALLOC)) { - b = nr ? ((blk_t *) block_buf)[nr-1] : 0; + b = nr ? ext2fs_le32_to_cpu(((blk_t *)block_buf)[nr - 1]) : ind; retval = ext2fs_alloc_block(fs, b, block_buf + fs->blocksize, &b); if (retval) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html