summaryrefslogtreecommitdiff
path: root/resize
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2003-06-24 17:34:02 -0400
committerTheodore Ts'o <tytso@mit.edu>2003-06-24 17:34:02 -0400
commit7d7bdd578b307cad1dc248310eb279c6fb73b682 (patch)
treee02bc1aaa944bcebaa44b4a128fcf68c45ee5154 /resize
parent23658ffa3083572fc118481264260cbd4ca86697 (diff)
downloade2fsprogs-7d7bdd578b307cad1dc248310eb279c6fb73b682.tar.gz
Fix bug in resize2fs which caused it to fail on filesystems with a
non-empty bad block list. Resize2fs now discards any blocks on the badblock list which are no longer part of the filesystem as the result of a filesystem shrink. (Note: this means that shrinking and then enlarging a filesystem is no longer a reversible operation; information about bad blocks in the part of the filesystem which is to be chopped off will be lost.)
Diffstat (limited to 'resize')
-rw-r--r--resize/ChangeLog9
-rw-r--r--resize/resize2fs.c17
2 files changed, 26 insertions, 0 deletions
diff --git a/resize/ChangeLog b/resize/ChangeLog
index e7667c8c..b0598738 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,12 @@
+2003-06-24 <tytso@snap.thunk.org>
+
+ * resize2fs.c (block_mover): Don't move blocks associated with the
+ bad blocks inode. Instead, just remove them from the
+ badblocks list. (Note this means that shrinking and then
+ enlarging a filesystem is not a reversible operation;
+ information about bad blocks in the part of the filesystem
+ which is to be chopped off is discarded.)
+
2003-06-08 Theodore Ts'o <tytso@mit.edu>
* resize2fs.8.in: Make explicit that you need to run resize2fs
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index f9543ccb..6f60cfcd 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -837,6 +837,12 @@ static errcode_t block_mover(ext2_resize_t rfs)
errcode_t retval;
int size, c;
int to_move, moved;
+ ext2_badblocks_list badblock_list = 0;
+ int bb_modified = 0;
+
+ retval = ext2fs_read_bb_inode(old_fs, &badblock_list);
+ if (retval)
+ return retval;
new_blk = fs->super->s_first_data_block;
if (!rfs->itable_buf) {
@@ -862,6 +868,11 @@ static errcode_t block_mover(ext2_resize_t rfs)
continue;
if (!ext2fs_test_block_bitmap(rfs->move_blocks, blk))
continue;
+ if (ext2fs_badblocks_list_test(badblock_list, blk)) {
+ ext2fs_badblocks_list_del(badblock_list, blk);
+ bb_modified++;
+ continue;
+ }
new_blk = get_new_block(rfs);
if (!new_blk) {
@@ -931,6 +942,12 @@ static errcode_t block_mover(ext2_resize_t rfs)
}
errout:
+ if (badblock_list) {
+ if (!retval && bb_modified)
+ retval = ext2fs_update_bb_inode(old_fs,
+ badblock_list);
+ ext2fs_badblocks_list_free(badblock_list);
+ }
return retval;
}