[Ocfs2-tools-devel] [PATCH 21/22] extras: Change some programs in extras to use discontig bg.
Tao Ma
tao.ma at oracle.com
Wed Mar 31 21:41:25 PDT 2010
This patch changes:
1. test program in libocfs2/chain.c if DEBUG_EXE is defined.
2. test program in extras/find_allocation_fragments.c
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
extras/find_allocation_fragments.c | 14 +++++++++++---
libocfs2/chain.c | 14 ++++++++++++--
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/extras/find_allocation_fragments.c b/extras/find_allocation_fragments.c
index aa76529..84ff269 100644
--- a/extras/find_allocation_fragments.c
+++ b/extras/find_allocation_fragments.c
@@ -110,7 +110,7 @@ static int print_group(struct ocfs2_group_desc *gd)
return 0;
}
-static int iterate_chain(ocfs2_filesys *fs, uint64_t start)
+static int iterate_chain(ocfs2_filesys *fs, uint64_t start, int suballocator)
{
errcode_t ret;
uint64_t gd_blkno;
@@ -123,7 +123,7 @@ static int iterate_chain(ocfs2_filesys *fs, uint64_t start)
gd_blkno = start;
do {
- ret = ocfs2_read_group_desc(fs, gd_blkno, buf, 0);
+ ret = ocfs2_read_group_desc(fs, gd_blkno, buf, suballocator);
if (ret)
goto out_free;
@@ -149,6 +149,13 @@ static int iterate_allocator(ocfs2_filesys *fs, uint64_t blkno)
char *buf = NULL;
struct ocfs2_dinode *di;
struct ocfs2_chain_list *cl;
+ uint64_t gb_blkno;
+
+ ret = ocfs2_lookup_system_inode(fs, GLOBAL_BITMAP_SYSTEM_INODE,
+ 0, &gb_blkno);
+ if (ret)
+ return ret;
+
ret = ocfs2_malloc_block(fs->fs_io, &buf);
if (ret)
@@ -169,7 +176,8 @@ static int iterate_allocator(ocfs2_filesys *fs, uint64_t blkno)
cl = &di->id2.i_chain;
for(i = 0; i < cl->cl_next_free_rec; i++) {
- ret = iterate_chain(fs, cl->cl_recs[i].c_blkno);
+ ret = iterate_chain(fs, cl->cl_recs[i].c_blkno,
+ blkno != gb_blkno);
if (ret)
goto out_free;
}
diff --git a/libocfs2/chain.c b/libocfs2/chain.c
index 4af12ee..350c1e5 100644
--- a/libocfs2/chain.c
+++ b/libocfs2/chain.c
@@ -303,6 +303,7 @@ struct walk_it {
int last_chain;
int count_free;
int count_total;
+ int suballocator;
};
static int walk_chain_func(ocfs2_filesys *fs,
@@ -322,7 +323,7 @@ static int walk_chain_func(ocfs2_filesys *fs,
wi->count_free = wi->count_total = 0;
}
- ret = ocfs2_read_group_desc(fs, gd_blkno, wi->gd_buf, 0);
+ ret = ocfs2_read_group_desc(fs, gd_blkno, wi->gd_buf, wi->suballocator);
if (ret)
return OCFS2_CHAIN_ERROR;
@@ -344,7 +345,7 @@ extern char *optarg;
int main(int argc, char *argv[])
{
errcode_t ret;
- uint64_t blkno;
+ uint64_t blkno, gb_blkno;
int c;
char *filename, *buf;
ocfs2_filesys *fs;
@@ -395,6 +396,14 @@ int main(int argc, char *argv[])
goto out;
}
+ ret = ocfs2_lookup_system_inode(fs, GLOBAL_BITMAP_SYSTEM_INODE,
+ 0, &gb_blkno);
+ if (ret) {
+ com_err(argv[0], ret,
+ "while finding global bitmap block");
+ goto out_close;
+ }
+
ret = ocfs2_malloc_block(fs->fs_io, &buf);
if (ret) {
com_err(argv[0], ret,
@@ -424,6 +433,7 @@ int main(int argc, char *argv[])
wi.di = di;
wi.last_chain = -1;
+ wi.suballocator = gb_blkno != blkno;
ret = ocfs2_chain_iterate(fs, blkno,
walk_chain_func,
&wi);
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list