]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2fs: Optimize extending an extent-mapped file using ext2fs_block_iterate2()
authorTheodore Ts'o <tytso@mit.edu>
Thu, 11 Mar 2010 17:47:41 +0000 (12:47 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Mar 2010 20:58:54 +0000 (15:58 -0500)
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>
lib/ext2fs/block.c

index 490116d545f6d0fcbaa3df5f48d27b0eed0cfa3e..c8d6b17d4bda09ed14cd5eacc643b28b2c088653 100644 (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;
                        }