[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1586342714-12536-10-git-send-email-wangshilong1991@gmail.com>
Date: Wed, 8 Apr 2020 19:44:37 +0900
From: Wang Shilong <wangshilong1991@...il.com>
To: linux-ext4@...r.kernel.org
Cc: lixi@....com, adilger@...ger.ca, sihara@....com,
Wang Shilong <wshilong@....com>
Subject: [RFC PATCH 09/46] e2fsck: copy badblocks when copying fs
From: Li Xi <lixi@....com>
This patch copies badblocks when the copying fs.
Signed-off-by: Li Xi <lixi@....com>
Signed-off-by: Wang Shilong <wshilong@....com>
---
e2fsck/pass1.c | 55 ++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 47 insertions(+), 8 deletions(-)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index f3337bde..de56562c 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2163,10 +2163,23 @@ static errcode_t e2fsck_pass1_copy_fs(ext2_filsys dest, ext2_filsys src)
src->dblist = NULL;
}
+ if (src->badblocks) {
+ retval = ext2fs_badblocks_copy(src->badblocks, &dest->badblocks);
+ if (retval)
+ goto out_dblist;
+
+ ext2fs_badblocks_list_free(src->badblocks);
+ src->badblocks = NULL;
+ }
return 0;
+
+out_dblist:
+ ext2fs_free_dblist(dest->dblist);
+ dest->dblist = NULL;
+ return retval;
}
-static int e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
+static int _e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
{
errcode_t retval = 0;
@@ -2178,6 +2191,32 @@ static int e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
PASS1_COPY_FS_BITMAP(dest, src, inode_map);
PASS1_COPY_FS_BITMAP(dest, src, block_map);
+ if (src->dblist) {
+ retval = ext2fs_copy_dblist(src->dblist, &dest->dblist);
+ if (retval)
+ return retval;
+ /* The ext2fs_copy_dblist() uses the src->fs as the fs */
+ dest->dblist->fs = dest;
+ }
+
+ if (src->badblocks) {
+ retval = ext2fs_badblocks_copy(src->badblocks, &dest->badblocks);
+ if (retval)
+ goto out_dblist;
+ }
+ return 0;
+out_dblist:
+ ext2fs_free_dblist(dest->dblist);
+ dest->dblist = NULL;
+ return retval;
+}
+
+static int e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
+{
+ errcode_t retval;
+
+ retval = _e2fsck_pass1_merge_fs(dest, src);
+
/* icache will be rebuilt if needed, so do not copy from @src */
if (src->icache) {
ext2fs_free_inode_cache(src->icache);
@@ -2185,16 +2224,16 @@ static int e2fsck_pass1_merge_fs(ext2_filsys dest, ext2_filsys src)
}
dest->icache = NULL;
- if (dest->dblist) {
- retval = ext2fs_copy_dblist(src->dblist, &dest->dblist);
- if (retval == 0) {
- /* The ext2fs_copy_dblist() uses the src->fs as the fs */
- dest->dblist->fs = dest;
- }
-
+ if (src->dblist) {
ext2fs_free_dblist(src->dblist);
src->dblist = NULL;
}
+
+ if (src->badblocks) {
+ ext2fs_badblocks_list_free(src->badblocks);
+ src->badblocks = NULL;
+ }
+
return retval;
}
--
2.25.2
Powered by blists - more mailing lists