cluster: STABLE3 - Simplify bitmap/block list structures
Bob Peterson
rpeterso at fedoraproject.org
Tue Jan 26 21:18:52 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c779e31178fa82f5b7d2e7f80e871dadfac0bb1b
Commit: c779e31178fa82f5b7d2e7f80e871dadfac0bb1b
Parent: c7f8a0e194283bdd54d180cceda3377561ab0787
Author: Bob Peterson <bob at ganesha.peterson>
AuthorDate: Wed Nov 25 14:34:08 2009 -0600
Committer: Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Jan 26 14:39:26 2010 -0600
Simplify bitmap/block list structures
This patch eliminates structures within structures to simplify the
code and improve performance.
rhbz#455300
---
gfs2/edit/savemeta.c | 8 ++++----
gfs2/fsck/fsck.h | 2 +-
gfs2/fsck/initialize.c | 4 ++--
gfs2/fsck/main.c | 2 +-
gfs2/libgfs2/block_list.c | 34 ++++++++++++++++------------------
gfs2/libgfs2/libgfs2.h | 27 ++++++++-------------------
6 files changed, 32 insertions(+), 45 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 3a11332..1bdadbe 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -34,7 +34,7 @@ struct saved_metablock {
struct saved_metablock *savedata;
uint64_t last_fs_block, last_reported_block, blks_saved, total_out, pct;
-struct gfs2_block_list *blocklist = NULL;
+struct gfs2_bmap *blocklist = NULL;
uint64_t journal_blocks[MAX_JOURNALS_SAVED];
uint64_t gfs1_journal_size = 0; /* in blocks */
int journals_found = 0;
@@ -620,8 +620,8 @@ void savemeta(char *out_fn, int saveoption)
fflush(stdout);
}
if (!slow) {
- blocklist = gfs2_block_list_create(&sbd, last_fs_block + 1,
- &memreq);
+ blocklist = gfs2_bmap_create(&sbd, last_fs_block + 1,
+ &memreq);
if (!blocklist)
slow = TRUE;
}
@@ -717,7 +717,7 @@ void savemeta(char *out_fn, int saveoption)
}
/* Clean up */
if (blocklist)
- gfs2_block_list_destroy(&sbd, blocklist);
+ gfs2_bmap_destroy(&sbd, blocklist);
/* There may be a gap between end of file system and end of device */
/* so we tell the user that we've processed everything. */
block = last_fs_block;
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 1b479e9..0431e4b 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -85,7 +85,7 @@ extern struct gfs2_options opts;
extern struct gfs2_inode *lf_dip; /* Lost and found directory inode */
extern osi_list_t dir_hash[FSCK_HASH_SIZE];
extern osi_list_t inode_hash[FSCK_HASH_SIZE];
-extern struct gfs2_block_list *bl;
+extern struct gfs2_bmap *bl;
extern uint64_t last_fs_block, last_reported_block;
extern int skip_this_pass, fsck_abort;
extern int errors_found, errors_corrected;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 11558b0..2241df2 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -98,7 +98,7 @@ static void empty_super_block(struct gfs2_sbd *sdp)
}
if (bl)
- gfs2_block_list_destroy(sdp, bl);
+ gfs2_bmap_destroy(sdp, bl);
}
@@ -255,7 +255,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
goto fail;
}
- bl = gfs2_block_list_create(sdp, last_fs_block+1, &addl_mem_needed);
+ bl = gfs2_bmap_create(sdp, last_fs_block+1, &addl_mem_needed);
if (!bl) {
log_crit( _("This system doesn't have enough memory + swap space to fsck this file system.\n"));
log_crit( _("Additional memory needed is approximately: %lluMB\n"),
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 0e9ccfe..aa14f98 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -20,7 +20,7 @@ struct gfs2_options opts = {0};
struct gfs2_inode *lf_dip; /* Lost and found directory inode */
osi_list_t dir_hash[FSCK_HASH_SIZE];
osi_list_t inode_hash[FSCK_HASH_SIZE];
-struct gfs2_block_list *bl = NULL;
+struct gfs2_bmap *bl = NULL;
uint64_t last_fs_block, last_reported_block = -1;
int skip_this_pass = FALSE, fsck_abort = FALSE;
int errors_found = 0, errors_corrected = 0;
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index 39de646..65df23f 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -148,19 +148,18 @@ static void gfs2_bitmap_destroy(struct gfs2_bmap *bmap)
bmap->chunks_per_byte = 0;
}
-struct gfs2_block_list *gfs2_block_list_create(struct gfs2_sbd *sdp,
- uint64_t size,
- uint64_t *addl_mem_needed)
+struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,
+ uint64_t *addl_mem_needed)
{
- struct gfs2_block_list *il;
+ struct gfs2_bmap *il;
*addl_mem_needed = 0L;
il = malloc(sizeof(*il));
if (!il || !memset(il, 0, sizeof(*il)))
return NULL;
- if(gfs2_bitmap_create(&il->list.gbmap, size, 4)) {
- *addl_mem_needed = il->list.gbmap.mapsize;
+ if(gfs2_bitmap_create(il, size, 4)) {
+ *addl_mem_needed = il->mapsize;
free(il);
il = NULL;
}
@@ -275,7 +274,7 @@ static void gfs2_dup_clear(struct dup_blocks *blocklist, uint64_t block)
}
}
-int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block mark)
{
int err = 0;
@@ -285,13 +284,12 @@ int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
else if(mark == gfs2_eattr_block)
gfs2_special_set(&sdp->eattr_blocks, block);
else
- err = gfs2_bitmap_set(&il->list.gbmap, block,
- mark_to_gbmap[mark]);
+ err = gfs2_bitmap_set(il, block, mark_to_gbmap[mark]);
return err;
}
/* gfs2_block_unmark clears ONE mark for the given block */
-int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block mark)
{
int err = 0;
@@ -305,25 +303,25 @@ int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
break;
default:
/* FIXME: check types */
- err = gfs2_bitmap_clear(&il->list.gbmap, block);
+ err = gfs2_bitmap_clear(il, block);
break;
}
return err;
}
/* gfs2_block_clear clears all the marks for the given block */
-int gfs2_block_clear(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+int gfs2_block_clear(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block)
{
int err = 0;
gfs2_dup_clear(&sdp->dup_blocks, block);
gfs2_special_clear(&sdp->eattr_blocks, block);
- err = gfs2_bitmap_clear(&il->list.gbmap, block);
+ err = gfs2_bitmap_clear(il, block);
return err;
}
-int gfs2_block_set(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+int gfs2_block_set(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block mark)
{
int err;
@@ -334,7 +332,7 @@ int gfs2_block_set(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
return err;
}
-int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, struct gfs2_block_query *val)
{
int err = 0;
@@ -345,15 +343,15 @@ int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
val->dup_block = 1;
if (blockfind(&sdp->eattr_blocks, block))
val->eattr_block = 1;
- if((err = gfs2_bitmap_get(&il->list.gbmap, block, &val->block_type)))
+ if((err = gfs2_bitmap_get(il, block, &val->block_type)))
return err;
return 0;
}
-void *gfs2_block_list_destroy(struct gfs2_sbd *sdp, struct gfs2_block_list *il)
+void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il)
{
if(il) {
- gfs2_bitmap_destroy(&il->list.gbmap);
+ gfs2_bitmap_destroy(il);
free(il);
il = NULL;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b1fe8ea..38100d3 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -340,35 +340,24 @@ struct gfs2_block_query {
uint8_t eattr_block;
};
-union gfs2_block_lists {
- struct gfs2_bmap gbmap;
-};
-
-/* bitmap implementation */
-struct gfs2_block_list {
- union gfs2_block_lists list;
-};
-
-extern struct gfs2_block_list *gfs2_block_list_create(struct gfs2_sbd *sdp,
- uint64_t size,
- uint64_t *addl_mem_needed);
+extern struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,
+ uint64_t *addl_mem_needed);
extern struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num);
extern void gfs2_special_set(struct special_blocks *blocklist, uint64_t block);
extern void gfs2_special_free(struct special_blocks *blist);
-extern int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+extern int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block mark);
-extern int gfs2_block_set(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+extern int gfs2_block_set(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block mark);
/* gfs2_block_unmark clears ONE mark for the given block */
-extern int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+extern int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, enum gfs2_mark_block m);
/* gfs2_block_clear clears all the marks for the given block */
-extern int gfs2_block_clear(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+extern int gfs2_block_clear(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block);
-extern int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
+extern int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
uint64_t block, struct gfs2_block_query *val);
-extern void *gfs2_block_list_destroy(struct gfs2_sbd *sdp,
- struct gfs2_block_list *il);
+extern void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il);
/* buf.c */
extern void init_buf_list(struct gfs2_sbd *sdp, struct buf_list *bl, uint32_t limit);
More information about the cluster-commits
mailing list