OSDN Git Service

libext2fs: fix block iterator for extents when truncating inodes
authorTheodore Ts'o <tytso@mit.edu>
Tue, 12 Jun 2012 04:27:39 +0000 (00:27 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 12 Jun 2012 05:34:10 +0000 (01:34 -0400)
commitbeb388a473bc12fa874743a7b9f97ec3094bb9d1
tree77496a099f3d820d785fc2e7205cb9c36f3ed558
parente9e96584b316f14d117801c61da5192743136b6f
libext2fs: fix block iterator for extents when truncating inodes

When e2fsck uses the block iterator to release the blocks in an
extent-mapped inode, when the last block in an extent is removed, the
current extent has been removed and the extent cursor is now pointing
at the next inode.  But the block iterator code doesn't know that.  So
when it tries to go the next extent, it will end up skipping an
extent, and so the inode will be incompletely truncated.

The fix is to go to the next extent before calling the callback
function for the current extent.  This way, regardless of whether the
current extent gets removed, the extent cursor is still pointing at
the right place.

Reported-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/block.c