summaryrefslogtreecommitdiff
path: root/e2fsck/pass3.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2013-12-15 23:54:07 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-12-15 23:54:09 -0500
commit0047255f602ae725a37f24c9b3214a1400459a20 (patch)
tree51396267eaabc3b1f91d1723f0a0cec3f758e1c2 /e2fsck/pass3.c
parent69beadcfb285cb5ee254d7f53c64a3f0dc42e229 (diff)
downloade2fsprogs-0047255f602ae725a37f24c9b3214a1400459a20.tar.gz
e2fsck: try implied cluster allocation when expanding a dir
When we're expanding a directory, check to see if we're doing an implied cluster allocation; if so, we don't need to allocate a new block, and we certainly don't need to update the summary counts. Reported-by: Zheng Liu <wenqing.lz@taobao.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/pass3.c')
-rw-r--r--e2fsck/pass3.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index d7a243e4..d87bd79f 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -713,12 +713,23 @@ static int expand_dir_proc(ext2_filsys fs,
last_blk = *blocknr;
return 0;
}
- retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map,
- &new_blk);
- if (retval) {
- es->err = retval;
- return BLOCK_ABORT;
+
+ if (blockcnt &&
+ (EXT2FS_B2C(fs, last_blk) == EXT2FS_B2C(fs, last_blk + 1)))
+ new_blk = last_blk + 1;
+ else {
+ last_blk &= ~EXT2FS_CLUSTER_MASK(fs);
+ retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map,
+ &new_blk);
+ if (retval) {
+ es->err = retval;
+ return BLOCK_ABORT;
+ }
+ es->newblocks++;
+ ext2fs_block_alloc_stats2(fs, new_blk, +1);
}
+ last_blk = new_blk;
+
if (blockcnt > 0) {
retval = ext2fs_new_dir_block(fs, 0, 0, &block);
if (retval) {
@@ -743,8 +754,6 @@ static int expand_dir_proc(ext2_filsys fs,
ext2fs_free_mem(&block);
*blocknr = new_blk;
ext2fs_mark_block_bitmap2(ctx->block_found_map, new_blk);
- ext2fs_block_alloc_stats2(fs, new_blk, +1);
- es->newblocks++;
if (es->num == 0)
return (BLOCK_CHANGED | BLOCK_ABORT);