OSDN Git Service

e2fsck: update global free blocks/inodes count when truncating orphan inodes
authorTheodore Ts'o <tytso@mit.edu>
Tue, 12 Jun 2012 02:18:25 +0000 (22:18 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 12 Jun 2012 02:18:25 +0000 (22:18 -0400)
commite9e96584b316f14d117801c61da5192743136b6f
treee1331ec1c8187424e34a90bfbe92d08f03d7c66f
parent6854ab1d4a1f9fb3599f027d2593d9c4d64b5e32
e2fsck: update global free blocks/inodes count when truncating orphan inodes

By the time we start processing the orphan inode list, we have already
calculated the total expected number of free blocks and inodes in
ctx->free_{blocks,inodes}.  This is used to set the free blocks/inodes
count in the superblock in the case where we don't need to do a full
e2fsck.

We need to update these expected free block counts as we process the
orphan inode list so that superblock values are set correctly.
Otherwise we could have the following happen:

% e2fsck /tmp/test.img
e2fsck 1.42.3 (14-May-2012)
Truncating orphaned inode 12 (uid=0, gid=0, mode=0100644, size=0)
Setting free blocks count to 46 (was 79)
/tmp/test.img: clean, 12/16 files, 54/100 blocks

% e2fsck /tmp/test.img
e2fsck 1.42.3 (14-May-2012)
Setting free blocks count to 79 (was 46)
/tmp/test.img: clean, 12/16 files, 21/100 blocks

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/super.c