[Ocfs2-tools-devel] [PATCH 14/22] tunefs.ocfs2: Make some group read/write handle suballocator.
Tao Ma
tao.ma at oracle.com
Wed Mar 31 21:41:18 PDT 2010
In libocfs2ne, we check global bitmap, so it isn't a suballoc.
In set_slot_count, we will move group among suballocators.
In enable_metaecc, we record the gb_blkno so that we can
figure out whether the group belongs to a suballocator by
checking inode->i_blkno with gb_blkno.
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
tunefs.ocfs2/feature_metaecc.c | 16 +++++++++++++---
tunefs.ocfs2/libocfs2ne.c | 6 +++---
tunefs.ocfs2/op_set_slot_count.c | 4 ++--
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/tunefs.ocfs2/feature_metaecc.c b/tunefs.ocfs2/feature_metaecc.c
index 360d581..a7621c0 100644
--- a/tunefs.ocfs2/feature_metaecc.c
+++ b/tunefs.ocfs2/feature_metaecc.c
@@ -31,7 +31,7 @@
#include "libocfs2ne.h"
-
+static uint64_t gb_blkno;
/* A dirblock we have to add a trailer to */
struct tunefs_trailer_dirblock {
@@ -791,7 +791,8 @@ out:
static errcode_t gd_write_func(ocfs2_filesys *fs,
struct block_to_ecc *block)
{
- return ocfs2_write_group_desc(fs, block->e_blkno, block->e_buf, 0);
+ return ocfs2_write_group_desc(fs, block->e_blkno, block->e_buf,
+ block->e_di->i_blkno != gb_blkno);
}
static errcode_t block_insert_gd(ocfs2_filesys *fs,
@@ -926,7 +927,8 @@ static int chain_iterate(ocfs2_filesys *fs, uint64_t gd_blkno,
verbosef(VL_DEBUG, "Reading group descriptor at %"PRIu64"\n",
gd_blkno);
- ret = ocfs2_read_group_desc(fs, gd_blkno, (char *)gd, 0);
+ ret = ocfs2_read_group_desc(fs, gd_blkno, (char *)gd,
+ iter->ic_di->i_blkno != gb_blkno);
if (ret)
goto out;
@@ -1309,6 +1311,14 @@ static int enable_metaecc(ocfs2_filesys *fs, int flags)
goto out;
}
+ ret = ocfs2_lookup_system_inode(fs, GLOBAL_BITMAP_SYSTEM_INODE,
+ 0, &gb_blkno);
+ if (ret) {
+ ret = TUNEFS_ET_INTERNAL_FAILURE;
+ tcom_err(ret, "while finding the global bitmap block");
+ goto out;
+ }
+
if (!tools_interact("Enable the metadata ECC feature on device "
"\"%s\"? ",
fs->fs_devname))
diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index ea30d65..23d0c2f 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -899,7 +899,7 @@ static int tunefs_count_free_bits(struct ocfs2_group_desc *gd)
static errcode_t tunefs_validate_chain_group(ocfs2_filesys *fs,
struct ocfs2_dinode *di,
- int chain)
+ int chain, int suballocator)
{
errcode_t ret = 0;
uint64_t blkno;
@@ -928,7 +928,7 @@ static errcode_t tunefs_validate_chain_group(ocfs2_filesys *fs,
blkno = cr->c_blkno;
while (blkno) {
- ret = ocfs2_read_group_desc(fs, blkno, buf, 0);
+ ret = ocfs2_read_group_desc(fs, blkno, buf, suballocator);
if (ret) {
verbosef(VL_LIB,
"%s while reading chain group descriptor "
@@ -1073,7 +1073,7 @@ static errcode_t tunefs_global_bitmap_check(ocfs2_filesys *fs)
cl = &(di->id2.i_chain);
for (i = 0; i < cl->cl_next_free_rec; ++i) {
- ret = tunefs_validate_chain_group(fs, di, i);
+ ret = tunefs_validate_chain_group(fs, di, i, 0);
if (ret)
goto bail;
}
diff --git a/tunefs.ocfs2/op_set_slot_count.c b/tunefs.ocfs2/op_set_slot_count.c
index 3cac17d..5e63795 100644
--- a/tunefs.ocfs2/op_set_slot_count.c
+++ b/tunefs.ocfs2/op_set_slot_count.c
@@ -269,7 +269,7 @@ static errcode_t move_group(ocfs2_filesys *fs,
*/
gd->bg_next_group = cr->c_blkno;
- ret = ocfs2_write_group_desc(fs, group->blkno, group->gd_buf, 0);
+ ret = ocfs2_write_group_desc(fs, group->blkno, group->gd_buf, 1);
if (ret)
goto bail;
@@ -336,7 +336,7 @@ static errcode_t move_chain_rec(ocfs2_filesys *fs, struct relink_ctxt *ctxt)
if (ret)
goto bail;
- ret = ocfs2_read_group_desc(fs, gd_blkno, group->gd_buf, 0);
+ ret = ocfs2_read_group_desc(fs, gd_blkno, group->gd_buf, 1);
if (ret)
goto bail;
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list