test on top of GuangZhe's fix on layer1

This commit is contained in:
WangZiao 2023-11-12 14:38:37 -08:00
parent dcf097a411
commit 3814ee0409
2 changed files with 7 additions and 3 deletions

View File

@ -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));

View File

@ -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++){