From 3814ee040908edfe102033e2912eff054c4b17a3 Mon Sep 17 00:00:00 2001 From: WangZiao Date: Sun, 12 Nov 2023 14:38:37 -0800 Subject: [PATCH] test on top of GuangZhe's fix on layer1 --- include/fs.h | 7 ++++--- test/layer1_test1.cpp | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/fs.h b/include/fs.h index 128e738..c162e30 100644 --- a/include/fs.h +++ b/include/fs.h @@ -9,8 +9,8 @@ one inode equipped with one 512 bytes block *****************************************************/ #define SECTOR_SIZE 512 #define IO_BLOCK_SIZE 4096 -#define MAX_INODE 524288 -#define MAX_BLOCKNUM MAX_INODE*2 //62914560 +#define MAX_INODE 2048 +#define MAX_BLOCKNUM 51200 //62914560 class SuperBlock{ @@ -169,8 +169,8 @@ public: } } if (!notFull){ - printf("HEADER REMOVAL DETECTED %llu %llu\n", freeListHead, freeBlockNum); u_int64_t next_header = read_byte_at(0, buffer); + printf("HEADER MOVE (Cause: Alloc) %llu -> %llu (%llu)\n", freeListHead, next_header, freeBlockNum); SuperBlock::writeFreeListHead(disk, next_header); } return freeBlockNum; @@ -291,6 +291,7 @@ public: if(!nowInList){ u_int64_t freeListHead = SuperBlock::getFreeListHead(disk); write_byte_at(freeListHead, 0, buffer); + printf("HEADER MOVE (Cause: Dealloc) %llu -> %llu\n", freeListHead, freeBlockHead); SuperBlock::writeFreeListHead(disk, freeBlockHead); } disk.rawdisk_write(freeBlockHead, buffer, sizeof(buffer)); diff --git a/test/layer1_test1.cpp b/test/layer1_test1.cpp index 27fa971..2943ecd 100644 --- a/test/layer1_test1.cpp +++ b/test/layer1_test1.cpp @@ -81,8 +81,10 @@ int main(int argc, char *argv[]) { // Test Big File (Use direct, single indirect, double indirect) printf("=== Big File Test ===\n"); + u_int64_t lastAllc = 0; for(int j=0;j<5000;j++){ u_int64_t allcBlockNum = inode_inside[0].datablock_allocate(*H); + lastAllc = allcBlockNum; u_int64_t fh = SuperBlock::getFreeListHead(*H); if (allcBlockNum % 2048 != 0 || allcBlockNum < 2048*512 || allcBlockNum >= 25*2048*512 || fh >= 51200*512) { printf("%d, Alloc Block Number: %llu\n", j, allcBlockNum); @@ -90,6 +92,7 @@ int main(int argc, char *argv[]) { assert(false); } } + printf("last allocate for big file: %llu\n", lastAllc); printf("Finished Allocating\n"); printf("freeListHead: %d \n", SuperBlock::getFreeListHead(*H)); for(int j=0;j<5000;j++){