Whamcloud - gitweb
e2fsck: copy badblocks when copying fs
authorWang Shilong <wshilong@ddn.com>
Wed, 9 Sep 2020 07:07:10 +0000 (15:07 +0800)
committerLi Dongyang <dongyangli@ddn.com>
Fri, 28 Apr 2023 00:35:54 +0000 (10:35 +1000)
This patch copies badblocks when the copying fs.

E2fsprogs-commit: 8095b716e15bb15a47925ae02cb1c06e91fdb651

Change-Id: Ibf5718ad5851a9ccd853a2a1f928bce447aa5de9
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c

index ebb5bb1..182c8cd 100644 (file)
@@ -2193,6 +2193,12 @@ static errcode_t e2fsck_pass1_copy_fs(ext2_filsys dest, ext2_filsys src)
                        return retval;
        }
 
+       if (src->badblocks) {
+               retval = ext2fs_badblocks_copy(src->badblocks, &dest->badblocks);
+               if (retval)
+                       return retval;
+       }
+
        /* icache will be rebuilt if needed, so do not copy from @src */
        src->icache = NULL;
        return 0;
@@ -2225,6 +2231,13 @@ static int e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
                src->icache = NULL;
        }
 
+       if (src->badblocks) {
+               retval = ext2fs_badblocks_copy(src->badblocks, &dest->badblocks);
+
+               ext2fs_badblocks_list_free(src->badblocks);
+               src->badblocks = NULL;
+       }
+
        return retval;
 }