[Ocfs2-tools-commits] jlbec commits r355 - in trunk/libocfs2: .
include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Nov 1 21:50:22 CST 2004
Author: jlbec
Date: 2004-11-01 21:50:20 -0600 (Mon, 01 Nov 2004)
New Revision: 355
Modified:
trunk/libocfs2/Makefile
trunk/libocfs2/bitmap.c
trunk/libocfs2/cached_inode.c
trunk/libocfs2/chain.c
trunk/libocfs2/extents.c
trunk/libocfs2/include/bitmap.h
trunk/libocfs2/include/ocfs2.h
Log:
o Add chainalloc.c This is the file that manages chain allocators.
Modified: trunk/libocfs2/Makefile
===================================================================
--- trunk/libocfs2/Makefile 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/Makefile 2004-11-02 03:50:20 UTC (rev 355)
@@ -61,6 +61,7 @@
bitmap.c \
fileio.c \
chain.c \
+ chainalloc.c \
checkhb.c \
kernel-rbtree.c \
bitops.c
Modified: trunk/libocfs2/bitmap.c
===================================================================
--- trunk/libocfs2/bitmap.c 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/bitmap.c 2004-11-02 03:50:20 UTC (rev 355)
@@ -45,13 +45,14 @@
struct rb_node *node;
struct ocfs2_bitmap_region *br;
+ /*
+ * If the bitmap needs to do extra cleanup of region,
+ * it should have done it in destroy_notify. Same with the
+ * private pointers.
+ */
if (bitmap->b_ops->destroy_notify)
(*bitmap->b_ops->destroy_notify)(bitmap);
- /*
- * If the bitmap needs to do extra cleanup of region,
- * it should have done it in destroy_notify
- */
while ((node = rb_first(&bitmap->b_regions)) != NULL) {
br = rb_entry(node, struct ocfs2_bitmap_region, br_node);
@@ -138,6 +139,26 @@
return (*bitmap->b_ops->find_next_clear)(bitmap, start, found);
}
+errcode_t ocfs2_bitmap_read(ocfs2_bitmap *bitmap)
+{
+ if (!bitmap->b_ops->read_bitmap)
+ return OCFS2_ET_INVALID_ARGUMENT;
+
+ /* FIXME: Some sane error, or handle in ->read_bitmap() */
+ if (rb_first(&bitmap->b_regions))
+ return OCFS2_ET_INVALID_BIT;
+
+ return (*bitmap->b_ops->read_bitmap)(bitmap);
+}
+
+errcode_t ocfs2_bitmap_write(ocfs2_bitmap *bitmap)
+{
+ if (!bitmap->b_ops->write_bitmap)
+ return OCFS2_ET_INVALID_ARGUMENT;
+
+ return (*bitmap->b_ops->write_bitmap)(bitmap);
+}
+
uint64_t ocfs2_bitmap_get_set_bits(ocfs2_bitmap *bitmap)
{
return bitmap->b_set_bits;
@@ -452,9 +473,9 @@
return 0;
}
-static errcode_t ocfs2_bitmap_find_next_set_generic(ocfs2_bitmap *bitmap,
- uint64_t start,
- uint64_t *found)
+errcode_t ocfs2_bitmap_find_next_set_generic(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found)
{
struct ocfs2_bitmap_region *br;
struct rb_node *node = NULL;
@@ -486,13 +507,12 @@
return OCFS2_ET_BIT_NOT_FOUND;
}
-static errcode_t ocfs2_bitmap_find_next_clear_generic(ocfs2_bitmap *bitmap,
- uint64_t start,
- uint64_t *found)
+errcode_t ocfs2_bitmap_find_next_clear_generic(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found)
{
struct ocfs2_bitmap_region *br;
struct rb_node *node = NULL;
- uint64_t seen;
int offset, ret;
/* start from either the node whose's br contains the bit or
@@ -500,22 +520,10 @@
br = ocfs2_bitmap_lookup(bitmap, start, 1, NULL, NULL, &node);
if (br)
node = &br->br_node;
- else if (!node) {
- /* There was nothing past start */
- *found = start;
- return 0;
- }
- seen = start;
for (; node != NULL; node = rb_next(node)) {
br = rb_entry(node, struct ocfs2_bitmap_region, br_node);
- /* Did we find a hole? */
- if (seen < br->br_start_bit) {
- *found = seen;
- return 0;
- }
-
if (start > br->br_start_bit)
offset = start - br->br_start_bit;
else
@@ -528,12 +536,12 @@
*found = br->br_start_bit + ret;
return 0;
}
- seen = br->br_start_bit + br->br_total_bits;
}
return OCFS2_ET_BIT_NOT_FOUND;
}
+
/*
* Helper functions for a bitmap with holes in it.
* If a bit doesn't have memory allocated for it, we allocate.
@@ -585,19 +593,59 @@
return 0;
}
-static errcode_t ocfs2_bitmap_find_next_set_holes(ocfs2_bitmap *bitmap,
- uint64_t start,
- uint64_t *found)
+errcode_t ocfs2_bitmap_find_next_set_holes(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found)
{
return ocfs2_bitmap_find_next_set_generic(bitmap, start, found);
}
-static errcode_t ocfs2_bitmap_find_next_clear_holes(ocfs2_bitmap *bitmap,
- uint64_t start,
- uint64_t *found)
+errcode_t ocfs2_bitmap_find_next_clear_holes(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found)
{
- return ocfs2_bitmap_find_next_clear_generic(bitmap, start,
- found);
+ struct ocfs2_bitmap_region *br;
+ struct rb_node *node = NULL;
+ uint64_t seen;
+ int offset, ret;
+
+ /* start from either the node whose's br contains the bit or
+ * the next greatest node in the tree */
+ br = ocfs2_bitmap_lookup(bitmap, start, 1, NULL, NULL, &node);
+ if (br)
+ node = &br->br_node;
+ else if (!node) {
+ /* There was nothing past start */
+ *found = start;
+ return 0;
+ }
+
+ seen = start;
+ for (; node != NULL; node = rb_next(node)) {
+ br = rb_entry(node, struct ocfs2_bitmap_region, br_node);
+
+ /* Did we find a hole? */
+ if (seen < br->br_start_bit) {
+ *found = seen;
+ return 0;
+ }
+
+ if (start > br->br_start_bit)
+ offset = start - br->br_start_bit;
+ else
+ offset = 0;
+
+ ret = ocfs2_find_next_bit_clear(br->br_bitmap,
+ br->br_total_bits,
+ offset);
+ if (ret != br->br_total_bits) {
+ *found = br->br_start_bit + ret;
+ return 0;
+ }
+ seen = br->br_start_bit + br->br_total_bits;
+ }
+
+ return OCFS2_ET_BIT_NOT_FOUND;
}
static struct ocfs2_bitmap_operations global_cluster_ops = {
Modified: trunk/libocfs2/cached_inode.c
===================================================================
--- trunk/libocfs2/cached_inode.c 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/cached_inode.c 2004-11-02 03:50:20 UTC (rev 355)
@@ -77,6 +77,9 @@
if (cinode->ci_map)
ocfs2_drop_extent_map(fs, cinode);
+
+ if (cinode->ci_chains)
+ ocfs2_bitmap_free(cinode->ci_chains);
if (cinode->ci_inode)
ocfs2_free(&cinode->ci_inode);
Modified: trunk/libocfs2/chain.c
===================================================================
--- trunk/libocfs2/chain.c 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/chain.c 2004-11-02 03:50:20 UTC (rev 355)
@@ -136,7 +136,7 @@
ctxt->errcode = ocfs2_read_group_desc(ctxt->fs, blkno,
ctxt->gd_buf);
if (ctxt->errcode) {
- iret |= OCFS2_EXTENT_ERROR;
+ iret |= OCFS2_CHAIN_ERROR;
break;
}
gd = (ocfs2_group_desc *)ctxt->gd_buf;
Modified: trunk/libocfs2/extents.c
===================================================================
--- trunk/libocfs2/extents.c 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/extents.c 2004-11-02 03:50:20 UTC (rev 355)
@@ -265,8 +265,9 @@
goto out_buf;
ret = OCFS2_ET_INODE_CANNOT_BE_ITERATED;
- if (inode->i_flags &
- (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL))
+ if (inode->i_flags & (OCFS2_SUPER_BLOCK_FL |
+ OCFS2_LOCAL_ALLOC_FL |
+ OCFS2_CHAIN_FL))
goto out_buf;
el = &inode->id2.i_list;
Modified: trunk/libocfs2/include/bitmap.h
===================================================================
--- trunk/libocfs2/include/bitmap.h 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/include/bitmap.h 2004-11-02 03:50:20 UTC (rev 355)
@@ -43,22 +43,24 @@
};
struct ocfs2_bitmap_operations {
- errcode_t (*set_bit)(ocfs2_bitmap *bm, uint64_t bit,
+ errcode_t (*set_bit)(ocfs2_bitmap *bitmap, uint64_t bit,
int *oldval);
- errcode_t (*clear_bit)(ocfs2_bitmap *bm, uint64_t bit,
+ errcode_t (*clear_bit)(ocfs2_bitmap *bitmap, uint64_t bit,
int *oldval);
- errcode_t (*test_bit)(ocfs2_bitmap *bm, uint64_t bit,
+ errcode_t (*test_bit)(ocfs2_bitmap *bitmap, uint64_t bit,
int *val);
- errcode_t (*find_next_set)(ocfs2_bitmap *bm, uint64_t start,
+ errcode_t (*find_next_set)(ocfs2_bitmap *bitmap,
+ uint64_t start,
uint64_t *found);
- errcode_t (*find_next_clear)(ocfs2_bitmap *bm, uint64_t start,
+ errcode_t (*find_next_clear)(ocfs2_bitmap *bitmap,
+ uint64_t start,
uint64_t *found);
- errcode_t (*merge_region)(ocfs2_bitmap *bm,
- struct ocfs2_bitmap_region *prev,
- struct ocfs2_bitmap_region *next);
- errcode_t (*read_bitmap)(ocfs2_bitmap *bm);
- errcode_t (*write_bitmap)(ocfs2_bitmap *bm);
- void (*destroy_notify)(ocfs2_bitmap *bm);
+ int (*merge_region)(ocfs2_bitmap *bitmap,
+ struct ocfs2_bitmap_region *prev,
+ struct ocfs2_bitmap_region *next);
+ errcode_t (*read_bitmap)(ocfs2_bitmap *bitmap);
+ errcode_t (*write_bitmap)(ocfs2_bitmap *bitmap);
+ void (*destroy_notify)(ocfs2_bitmap *bitmap);
};
struct _ocfs2_bitmap {
@@ -67,11 +69,6 @@
uint64_t b_total_bits;
char *b_description;
struct ocfs2_bitmap_operations *b_ops;
- ocfs2_cached_inode *b_cinode; /* Cached inode this
- bitmap was loaded
- from if it is a
- physical bitmap
- inode */
struct rb_root b_regions;
void *b_private;
};
@@ -99,10 +96,22 @@
uint64_t bitno, int *oldval);
errcode_t ocfs2_bitmap_test_generic(ocfs2_bitmap *bitmap,
uint64_t bitno, int *val);
+errcode_t ocfs2_bitmap_find_next_set_generic(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found);
+errcode_t ocfs2_bitmap_find_next_clear_generic(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found);
errcode_t ocfs2_bitmap_set_holes(ocfs2_bitmap *bitmap,
uint64_t bitno, int *oldval);
errcode_t ocfs2_bitmap_clear_holes(ocfs2_bitmap *bitmap,
uint64_t bitno, int *oldval);
errcode_t ocfs2_bitmap_test_holes(ocfs2_bitmap *bitmap,
uint64_t bitno, int *val);
+errcode_t ocfs2_bitmap_find_next_set_holes(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found);
+errcode_t ocfs2_bitmap_find_next_clear_holes(ocfs2_bitmap *bitmap,
+ uint64_t start,
+ uint64_t *found);
#endif /* _BITMAP_H */
Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h 2004-11-02 02:53:31 UTC (rev 354)
+++ trunk/libocfs2/include/ocfs2.h 2004-11-02 03:50:20 UTC (rev 355)
@@ -187,6 +187,7 @@
uint64_t ci_blkno;
ocfs2_dinode *ci_inode;
ocfs2_extent_map *ci_map;
+ ocfs2_bitmap *ci_chains;
};
struct _ocfs2_nodes {
@@ -369,6 +370,8 @@
uint64_t start, uint64_t *found);
errcode_t ocfs2_bitmap_find_next_clear(ocfs2_bitmap *bitmap,
uint64_t start, uint64_t *found);
+errcode_t ocfs2_bitmap_read(ocfs2_bitmap *bitmap);
+errcode_t ocfs2_bitmap_write(ocfs2_bitmap *bitmap);
uint64_t ocfs2_bitmap_get_set_bits(ocfs2_bitmap *bitmap);
errcode_t ocfs2_get_device_size(const char *file, int blocksize,
@@ -405,6 +408,11 @@
void *priv_data),
void *priv_data);
+errcode_t ocfs2_load_chain_allocator(ocfs2_filesys *fs,
+ ocfs2_cached_inode *cinode);
+errcode_t ocfs2_write_chain_allocator(ocfs2_filesys *fs,
+ ocfs2_cached_inode *cinode);
+
/*
* ${foo}_to_${bar} is a floor function. blocks_to_clusters will
* returns the cluster that contains a block, not the number of clusters
More information about the Ocfs2-tools-commits
mailing list