On Thu, Dec 25, 2008 at 08:18:48PM +1300, Paul Collins wrote: > Theodore Tso <tytso@xxxxxxx> writes: > > Yeah, resize2fs needs to be fixed to handle extents correctly. At the > > moment it can screw them up pretty badly. > > In the meantime, perhaps something like the patch below is appropriate? Actually, I think the following patch should fix things up nicely. I need to create a test case so I can be sure this fixes the problem, but I think this should address the root cause of theproblem you reported. - Ted diff --git a/resize/resize2fs.c b/resize/resize2fs.c index abe05f5..65398a6 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -1188,6 +1188,16 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, return ret; } +static int process_block_ind(ext2_filsys fs, blk_t *block_nr, + e2_blkcnt_t blockcnt, blk_t ref_block, + int ref_offset, void *priv_data) +{ + if (blockcnt >= 0) + return 0; + return process_block(fs, block_nr, blockcnt, ref_block, ref_offset, + priv_data); +} + /* * Progress callback */ @@ -1302,6 +1312,18 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) if (ext2fs_inode_has_valid_blocks(inode) && (rfs->bmap || pb.is_dir)) { pb.ino = ino; + if (inode->i_flags & EXT4_EXTENTS_FL) { + /* + * With extent-based files, we have + * to translate all of the interior + * node blocks first. + */ + retval = ext2fs_block_iterate2(rfs->old_fs, + ino, 0, block_buf, + process_block_ind, &pb); + if (retval) + goto errout; + } retval = ext2fs_block_iterate2(rfs->old_fs, ino, 0, block_buf, process_block, &pb); -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html