[Ocfs2-tools-devel] [PATCH 1/1] fsck.ocfs2: Reinitialize bitmap when we reset fs_blocks.
Tao Ma
tao.ma at oracle.com
Sun Jul 27 18:21:03 PDT 2008
In fsck.ocfs2, when we find fs_blocks in super block isn't the
same as the number stored in global_bitmap, we choose to trust
global_bitmap. In this case, we have to reinitialize the bitmap
also since they are all fs_blocks based. This bug blocks the test
case of fsck-test.sh in ocfs2-test.
Another minor bug is also fixed in this patch. the "ret" in
o2fsck_check_blocks may be used "uninitalized", so initialize
it to "0".
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
fsck.ocfs2/fsck.c | 54 ++++++++++++++++++++++++++++++++++----------
fsck.ocfs2/include/fsck.h | 4 +++
fsck.ocfs2/pass0.c | 8 ++++++
fsck.ocfs2/pass1.c | 2 +-
4 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 4d6070b..9dccfbe 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -146,21 +146,24 @@ static uint64_t read_number(const char *num)
extern int opterr, optind;
extern char *optarg;
-static errcode_t o2fsck_state_init(ocfs2_filesys *fs, o2fsck_state *ost)
+void o2fsck_state_bitmap_free(o2fsck_state *ost)
{
- errcode_t ret;
+ ocfs2_bitmap_free(ost->ost_bad_inodes);
+ ost->ost_bad_inodes = NULL;
- ret = o2fsck_icount_new(fs, &ost->ost_icount_in_inodes);
- if (ret) {
- com_err(whoami, ret, "while allocating inode icount");
- return ret;
- }
+ ocfs2_bitmap_free(ost->ost_dir_inodes);
+ ost->ost_dir_inodes = NULL;
- ret = o2fsck_icount_new(fs, &ost->ost_icount_refs);
- if (ret) {
- com_err(whoami, ret, "while allocating reference icount");
- return ret;
- }
+ ocfs2_bitmap_free(ost->ost_reg_inodes);
+ ost->ost_reg_inodes = NULL;
+
+ ocfs2_bitmap_free(ost->ost_allocated_clusters);
+ ost->ost_allocated_clusters = NULL;
+}
+
+errcode_t o2fsck_state_bitmap_new(ocfs2_filesys *fs, o2fsck_state *ost)
+{
+ errcode_t ret;
ret = ocfs2_block_bitmap_new(fs, "inodes with bad fields",
&ost->ost_bad_inodes);
@@ -194,6 +197,31 @@ static errcode_t o2fsck_state_init(ocfs2_filesys *fs, o2fsck_state *ost)
return 0;
}
+static errcode_t o2fsck_state_init(ocfs2_filesys *fs, o2fsck_state *ost)
+{
+ errcode_t ret;
+
+ ret = o2fsck_icount_new(fs, &ost->ost_icount_in_inodes);
+ if (ret) {
+ com_err(whoami, ret, "while allocating inode icount");
+ return ret;
+ }
+
+ ret = o2fsck_icount_new(fs, &ost->ost_icount_refs);
+ if (ret) {
+ com_err(whoami, ret, "while allocating reference icount");
+ return ret;
+ }
+
+ ret = o2fsck_state_bitmap_new(fs, ost);
+ if (ret) {
+ com_err(whoami, ret, "while allocating bitmaps. ");
+ return ret;
+ }
+
+ return 0;
+}
+
static errcode_t check_superblock(o2fsck_state *ost)
{
struct ocfs2_dinode *di = ost->ost_fs->fs_super;
@@ -356,7 +384,7 @@ static void print_uuid(o2fsck_state *ost)
printf("\n");
}
-static void mark_magical_clusters(o2fsck_state *ost)
+void mark_magical_clusters(o2fsck_state *ost)
{
uint32_t cluster;
diff --git a/fsck.ocfs2/include/fsck.h b/fsck.ocfs2/include/fsck.h
index f3a8105..e99ec03 100644
--- a/fsck.ocfs2/include/fsck.h
+++ b/fsck.ocfs2/include/fsck.h
@@ -73,6 +73,10 @@ typedef struct _o2fsck_state {
ost_fix_fs_gen:1;
} o2fsck_state;
+void o2fsck_state_bitmap_free(o2fsck_state *ost);
+errcode_t o2fsck_state_bitmap_new(ocfs2_filesys *fs, o2fsck_state *ost);
+void mark_magical_clusters(o2fsck_state *ost);
+
/* The idea is to let someone off-site run fsck and have it give us
* enough information to diagnose problems with */
extern int verbose;
diff --git a/fsck.ocfs2/pass0.c b/fsck.ocfs2/pass0.c
index 68dd930..a00fa82 100644
--- a/fsck.ocfs2/pass0.c
+++ b/fsck.ocfs2/pass0.c
@@ -1100,6 +1100,14 @@ errcode_t o2fsck_pass0(o2fsck_state *ost)
fs->fs_clusters = di->i_clusters;
fs->fs_blocks = ocfs2_clusters_to_blocks(fs,
fs->fs_clusters);
+ o2fsck_state_bitmap_free(ost);
+ ret = o2fsck_state_bitmap_new(fs, ost);
+ if (ret) {
+ com_err(whoami, ret, "while allocating "
+ "bitmaps. ");
+ goto out;
+ }
+ mark_magical_clusters(ost);
}
}
diff --git a/fsck.ocfs2/pass1.c b/fsck.ocfs2/pass1.c
index 175ac38..dddc1f9 100644
--- a/fsck.ocfs2/pass1.c
+++ b/fsck.ocfs2/pass1.c
@@ -762,7 +762,7 @@ static errcode_t o2fsck_check_blocks(ocfs2_filesys *fs, o2fsck_state *ost,
uint64_t blkno, struct ocfs2_dinode *di)
{
uint64_t expected = 0, unexpected = 0;
- errcode_t ret;
+ errcode_t ret = 0;
struct verifying_blocks vb = {
.vb_ost = ost,
.vb_di = di,
--
1.5.4.GIT
More information about the Ocfs2-tools-devel
mailing list