ext2fs: Optimize extending an extent-mapped file using ext2fs_block_iterate2()

When ext2fs_block_iterate2() is called on an extent-mapped file with a
depth > 1, it will erroneously calling the callback function starting
all over again with an offset of logical block 0.  It shouldn't do
this, and it cases mke2fs to become very slow when creating files with
very large journals.

Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2010-03-11 12:47:41 -05:00
parent 4ffafee26c
commit 8e2399d57a
1 changed files with 3 additions and 1 deletions

View File

@ -379,6 +379,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
ctx.errcode = 0;
if (!(flags & BLOCK_FLAG_APPEND))
break;
next_block_set:
blk = 0;
r = (*ctx.func)(fs, &blk, blockcnt,
0, 0, priv_data);
@ -392,7 +393,8 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
(blk64_t) blk, 0);
if (ctx.errcode || (ret & BLOCK_ABORT))
break;
continue;
if (blk)
goto next_block_set;
}
break;
}