[Ocfs2-tools-commits] jlbec commits r931 - trunk/libocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Jun 6 06:23:07 CDT 2005
Author: jlbec
Date: 2005-06-06 06:23:05 -0500 (Mon, 06 Jun 2005)
New Revision: 931
Modified:
trunk/libocfs2/chainalloc.c
Log:
o Teach ocfs2_chain_alloc() to actually return its gd_blkno. Fixes
bug 468.
Modified: trunk/libocfs2/chainalloc.c
===================================================================
--- trunk/libocfs2/chainalloc.c 2005-06-03 20:43:24 UTC (rev 930)
+++ trunk/libocfs2/chainalloc.c 2005-06-06 11:23:05 UTC (rev 931)
@@ -362,6 +362,31 @@
return ocfs2_bitmap_clear_range(cinode->ci_chains, len, start_bit);
}
+struct find_gd_state {
+ ocfs2_filesys *fs;
+ uint64_t bitno;
+ uint64_t gd_blkno;
+ int found;
+};
+
+static errcode_t chainalloc_find_gd(struct ocfs2_bitmap_region *br,
+ void *private_data)
+{
+ struct chainalloc_region_private *cr = br->br_private;
+ struct find_gd_state *state = private_data;
+
+ if ((state->bitno >= br->br_start_bit) &&
+ (state->bitno < (br->br_start_bit + br->br_total_bits))) {
+ state->found = 1;
+ state->gd_blkno = cr->cr_ag->bg_blkno;
+ if (state->gd_blkno == OCFS2_RAW_SB(state->fs->fs_super)->s_first_cluster_group)
+ state->gd_blkno = 0;
+ return OCFS2_ET_ITERATION_COMPLETE;
+ }
+
+ return 0;
+}
+
errcode_t ocfs2_chain_alloc(ocfs2_filesys *fs,
ocfs2_cached_inode *cinode,
uint64_t *gd_blkno,
@@ -369,6 +394,7 @@
{
errcode_t ret;
int oldval;
+ struct find_gd_state state;
if (!cinode->ci_chains)
return OCFS2_ET_INVALID_ARGUMENT;
@@ -383,7 +409,19 @@
if (oldval)
return OCFS2_ET_INTERNAL_FAILURE;
- return 0;
+ state = (struct find_gd_state) {
+ .fs = fs,
+ .bitno = *bitno,
+ };
+ ret = ocfs2_bitmap_foreach_region(cinode->ci_chains,
+ chainalloc_find_gd, &state);
+ if (!ret) {
+ if (state.found)
+ *gd_blkno = state.gd_blkno;
+ else
+ ret = OCFS2_ET_INTERNAL_FAILURE;
+ }
+ return ret;
}
errcode_t ocfs2_chain_free(ocfs2_filesys *fs,
More information about the Ocfs2-tools-commits
mailing list