--- convertfs/devremap.c 2002-03-01 16:16:45.000000000 +0100 +++ convertfs/devremap.c 2005-09-30 15:57:24.000000000 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include "convertfs.h" @@ -80,6 +81,15 @@ static struct superblock super; static struct info info; + +/* ULTRA UGLY HACK */ +struct indexpage *hack_ip; +struct chunk *hack_chunk = NULL; +baddr_t *hack_physp; +baddr_t hack_virt; +int hack_i; + + static void die (const char *format, ...) { @@ -346,17 +356,63 @@ baddr_t virt; int i; +/* printf("find_cross_block\n"); */ + + if(hack_chunk != NULL) + { + if ((*hack_physp == bm->to) && (*hack_physp != hack_virt)) + { + + ip = hack_ip; + chunk = hack_chunk; + physp = hack_physp; + virt = hack_virt; + i = hack_i; + + goto VERY_UGLY_HACK; + } + } + i = bm->i + 1; chunk = bm->chunk; for (ip = bm->ip; ip; ip = ip->next, chunk = ip->chunk) for (; chunk; chunk = next_chunk(ip, chunk), i = 0) { + +/* printf("chunk: %p bm->to: %lx\n", chunk, (long int)bm->to); */ + virt = chunk->offset + i; physp = &chunk->block[i]; - for (; i < chunk->nblocks; i++, virt++, physp++) + for (; i < chunk->nblocks; i++, virt++, physp++) { + VERY_UGLY_HACK: + if ((*physp == bm->to) && (*physp != virt)) { + + hack_ip = ip; + hack_chunk = chunk; + hack_physp = physp; + hack_virt = virt; + hack_i = i; + + hack_i++; + hack_virt++; + hack_physp++; + + if(hack_i >= chunk->nblocks) + { + hack_chunk = next_chunk(hack_ip, hack_chunk); + hack_i = 0; + + if(hack_chunk) + { + hack_virt = hack_chunk->offset + hack_i; + hack_physp = &hack_chunk->block[hack_i]; + } + } + handle_cross_block(ip, bm, physp, virt); return 1; } + } } return 0; } @@ -606,6 +662,8 @@ int main (int argc, char *argv[]) { + time_t t; + selfname = argv[0]; if (argc != 2) { fprintf(stderr, "Usage: %s DEVICE\n", selfname); @@ -621,9 +679,13 @@ replay_log(); load_index(); while (info.ip) { + t = time(NULL); + prepare_log(); write_log(); commit_log(); + + printf("...that took %d seconds.\n", (int)(time(NULL)-t)); } printf("And now the block0...\n"); bmove(super.block0, 0);