[Tux3] [PATHC 4/4] test flush for bitmap
OGAWA Hirofumi
hirofumi at mail.parknet.co.jp
Mon Mar 9 18:32:00 PDT 2009
diff -puN user/kernel/balloc.c~bitmap-atomic-commit user/kernel/balloc.c
--- tux3/user/kernel/balloc.c~bitmap-atomic-commit 2009-03-10 09:58:23.000000000 +0900
+++ tux3-hirofumi/user/kernel/balloc.c 2009-03-10 09:58:23.000000000 +0900
@@ -232,7 +232,9 @@ static block_t balloc_from_range(struct
buffer = blockdirty(buffer, sb->flush);
// FIXME: error check of buffer
set_bits(bufdata(buffer), found & mapmask, run);
+#ifdef ATOMIC
mark_buffer_dirty(buffer);
+#endif
brelse(buffer);
sb->nextalloc = found + run;
sb->freeblocks -= run;
@@ -282,7 +284,9 @@ int bfree(struct sb *sb, block_t start,
buffer = blockdirty(buffer, sb->flush);
// FIXME: error check of buffer
clear_bits(bufdata(buffer), start, blocks);
+#ifdef ATOMIC
mark_buffer_dirty(buffer);
+#endif
brelse(buffer);
sb->freeblocks += blocks;
//set_sb_dirty(sb);
diff -puN user/kernel/commit.c~bitmap-atomic-commit user/kernel/commit.c
--- tux3/user/kernel/commit.c~bitmap-atomic-commit 2009-03-10 09:58:23.000000000 +0900
+++ tux3-hirofumi/user/kernel/commit.c 2009-03-10 09:58:23.000000000 +0900
@@ -66,14 +66,22 @@ int load_itable(struct sb *sb)
static int need_delta(struct sb *sb)
{
+#if 0
static unsigned crudehack;
return !(++crudehack % 10);
+#else
+ return 1;
+#endif
}
static int need_flush(struct sb *sb)
{
+#if 0
static unsigned crudehack;
return !(++crudehack % 3);
+#else
+ return 1;
+#endif
}
static void clean_buffer(struct buffer_head *buffer)
diff -puN user/super.c~bitmap-atomic-commit user/super.c
--- tux3/user/super.c~bitmap-atomic-commit 2009-03-10 09:58:23.000000000 +0900
+++ tux3-hirofumi/user/super.c 2009-03-10 09:58:23.000000000 +0900
@@ -23,15 +23,22 @@ int sync_super(struct sb *sb)
printf("sync atom table\n");
if ((err = tuxsync(sb->atable)))
return err;
+#if 1
+ change_begin(sb);
+ change_end(sb);
+#else
printf("sync bitmap\n");
if ((err = tuxsync(sb->bitmap)))
return err;
+#endif
printf("sync volmap\n");
if ((err = flush_buffers(sb->volmap->map)))
return err;
+#if 0
printf("sync super\n");
if ((err = save_sb(sb)))
return err;
+#endif
return 0;
}
@@ -98,6 +105,11 @@ int make_tux3(struct sb *sb)
sb->atomgen = 1; // atom 0 not allowed, means end of atom freelist
if (make_inode(sb->atable, TUX_ATABLE_INO))
goto eek;
+ trace("volmap: map %p", sb->volmap->map);
+ trace("bitmap: map %p", sb->bitmap->map);
+ trace("vtable: map %p", sb->vtable->map);
+ trace("atable: map %p", sb->atable->map);
+ trace("rootdir: map %p", sb->rootdir->map);
if ((err = sync_super(sb)))
goto eek;
diff -puN user/tux3.c~bitmap-atomic-commit user/tux3.c
--- tux3/user/tux3.c~bitmap-atomic-commit 2009-03-10 09:58:23.000000000 +0900
+++ tux3-hirofumi/user/tux3.c 2009-03-10 09:58:23.000000000 +0900
@@ -49,6 +49,7 @@ static int mkfs(int fd, const char *voln
.freeblocks = volsize >> dev->bits);
sb->super = (struct disksuper){ .magic = SB_MAGIC, .volblocks = to_be_u64(sb->blockbits) };
+ sb->logmap = rapid_open_inode(sb, dev_errio, 0);
sb->volmap = tux_new_volmap(sb);
if (!sb->volmap)
return -ENOMEM;
@@ -57,6 +58,8 @@ static int mkfs(int fd, const char *voln
int err = make_tux3(sb);
if (!err)
show_tree_range(itable_btree(sb), 0, -1);
+ /* sb->bitmap is always dirty */
+ invalidate_buffers(sb->bitmap->map);
return err;
}
@@ -115,6 +118,7 @@ int main(int argc, char *argv[])
dev->bits = sb->blockbits;
init_buffers(dev, 1 << 20, 1);
+ sb->logmap = rapid_open_inode(sb, dev_errio, 0);
sb->volmap = tux_new_volmap(sb);
if (!sb->volmap)
goto eek;
@@ -288,6 +292,8 @@ int main(int argc, char *argv[])
goto eek;
}
+ /* sb->bitmap is always dirty */
+ invalidate_buffers(sb->bitmap->map);
//printf("---- show state ----\n");
//show_buffers(sb->rootdir->map);
//show_buffers(sb->volmap->map);
_
--
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
More information about the Tux3
mailing list