From 6338e4f8a6924063c3d666007474206fb309f568 Mon Sep 17 00:00:00 2001 From: tlemsl Date: Thu, 21 Jul 2022 14:13:44 +0900 Subject: [PATCH] Done GC without BM --- Makefile | 2 +- algorithm/normal/normal.c | 9 +++++---- algorithm/normal/pFTL.c | 25 ++++++++++++++++--------- include/container.h | 18 ++++++++++++++++++ interface/vectored_main.c | 4 ++-- 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index f78ce7f..1299fc7 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ DEBUGFLAGS=\ -Wno-pointer-arith\ -g\ -export-dynamic\ -# -fsanitize=address\ + -fsanitize=address\ export COMMONFLAGS+=\ -Wno-write-strings\ diff --git a/algorithm/normal/normal.c b/algorithm/normal/normal.c index 60428fa..4ad74cb 100644 --- a/algorithm/normal/normal.c +++ b/algorithm/normal/normal.c @@ -54,6 +54,7 @@ uint32_t normal_get(request *const req){ my_req->type=DATAR; switch (req->type){ case GCDR: + my_req->type=GCDR; __normal.li->read(req->key,PAGESIZE,req->value, my_req); break; @@ -68,16 +69,16 @@ uint32_t normal_get(request *const req){ return 1; } uint32_t normal_set(request *const req){ - //GC(NULL); - pthread_mutex_lock(&GC_lock); + GC(NULL); + //pthread_mutex_lock(&GC_lock); write(req); //wait_for_gc(); //__normal.li->write(req->key ,PAGESIZE,req->value,req->isAsync,my_req); //__normal.li->write(get_key(req->key, DATAW, 0),PAGESIZE,req->value,my_req); - pthread_mutex_unlock(&GC_lock); - wait_for_gc(); + //pthread_mutex_unlock(&GC_lock); + //wait_for_gc(); return 0; } uint32_t normal_remove(request *const req){ diff --git a/algorithm/normal/pFTL.c b/algorithm/normal/pFTL.c index d60fc97..a4adc33 100644 --- a/algorithm/normal/pFTL.c +++ b/algorithm/normal/pFTL.c @@ -18,7 +18,7 @@ static bool _GC_flag; pthread_mutex_t GC_lock; // Validation Parameters static uint32_t _user_write_reqest, _lower_write_request_cnt; - +static struct mastersegment* GC_reserve_segment; void pFTL_init(){ @@ -41,8 +41,14 @@ void pFTL_init(){ pthread_t GC_thread; pthread_mutex_init(&GC_lock, NULL); - pthread_create(&GC_thread, NULL, GC, NULL); - printf("%u %u %u\n", _usable_section, _L2P_table, _P2L_table); + GC_reserve_segment = __normal.bm->get_segment(__normal.bm, BLOCK_ACTIVE); + printf("%u!!!!!!\n\n\n", GC_reserve_segment->seg_idx); + printf("%u!!!!!!\n\n\n", __normal.bm->get_page_addr(GC_reserve_segment)); + printf("%u!!!!!!\n\n\n", __normal.bm->get_page_addr(GC_reserve_segment)); + printf("%u!!!!!!\n\n\n", __normal.bm->get_page_addr(GC_reserve_segment)); + _log = _PPS; + //pthread_create(&GC_thread, NULL, GC, NULL); + } KEYT get_key(KEYT lpa){ @@ -51,9 +57,9 @@ KEYT get_key(KEYT lpa){ void* GC(void* qwer){ //printf("initialize GC thread\n"); - while(true){ + //while(true){ - if(_usable_section==3){ + if(_usable_section==1){ while (!done_GC()){ _GC_flag = true; @@ -101,12 +107,12 @@ void* GC(void* qwer){ write_request->key = lpa; //memcpy((void*)write_request->value, (void*)(read_request->value+(LPAGESIZE*pidx)), 1); - pthread_mutex_lock(&GC_lock); + //pthread_mutex_lock(&GC_lock); write(write_request); wait_for_request(write_request); _validation_table[ppa] = false; write_param->done = false; - pthread_mutex_unlock(&GC_lock); + //pthread_mutex_unlock(&GC_lock); } read_param->done=false; } @@ -129,7 +135,7 @@ void* GC(void* qwer){ - } + //} } /* @@ -228,7 +234,7 @@ void write(request* const req){ //printf("%d %d\n", (void*)pftl_buffer.data_set, (void*)pftl_buffer.data_set + LPAGESIZE*pftl_buffer.buffer_count); pftl_buffer.lpas[pftl_buffer.buffer_count] = lpa; - //memcpy((void*)pftl_buffer.data_set + LPAGESIZE*pftl_buffer.buffer_count, (void*)req->value, LPAGESIZE); + //memcpy(&pftl_buffer.data_set[LPAGESIZE*pftl_buffer.buffer_count], (void*)req->value->value, LPAGESIZE); pftl_buffer.ppa=_log; pftl_buffer.buffer_count++; //printf("Write Logical : %u Physical : %u\n", req->key, ppa>>2); @@ -244,6 +250,7 @@ void write(request* const req){ my_req->parents=req; my_req->end_req=normal_end_req; my_req->type=DATAW; + if(req->type == GCDW) my_req->type = GCDW; my_req->param=(void*)params; _validation_table[ppa] = true; __normal.li->write(pftl_buffer.ppa,PAGESIZE, pftl_buffer.data_set,my_req); diff --git a/include/container.h b/include/container.h index fe4dcaf..f390275 100644 --- a/include/container.h +++ b/include/container.h @@ -263,23 +263,41 @@ enum{ struct blockmanager{ uint32_t type; + //Require block get __segment* (*get_segment) (struct blockmanager*, uint32_t type); + //get remaining block not pop (queue) __segment* (*pick_segment) (struct blockmanager *, uint32_t seg_idx, uint32_t type); //used for load + // remove int32_t (*get_page_addr) (__segment*); + int32_t (*pick_page_addr) (__segment*); + // Check segment bool (*check_full) (__segment*); + // true -> GC bool (*is_gc_needed) (struct blockmanager*); + // GC block get __gsegment* (*get_gc_target) (struct blockmanager*); + + //Remove block void (*trim_segment) (struct blockmanager*, __gsegment*); + // Check Valid(4K) int (*bit_set) (struct blockmanager*, uint32_t piece_ppa); + // invalid int (*bit_unset) (struct blockmanager*, uint32_t piece_ppa); + // Check page valid(4K data) bool (*bit_query) (struct blockmanager *, uint32_t piece_ppa); + // Reverse Query bool (*is_invalid_piece) (struct blockmanager *, uint32_t piece_ppa); + // Set LBA data : lbas void (*set_oob) (struct blockmanager *, char* data, int len, uint32_t ppa); + char *(*get_oob)(struct blockmanager *, uint32_t ppa); + void (*change_reserve_to_active)(struct blockmanager *, __segment *reserve); + + void (*insert_gc_target)(struct blockmanager *, uint32_t seg_idx); uint32_t (*total_free_page_num)(struct blockmanager *, __segment *active); uint32_t (*seg_invalidate_piece_num)(struct blockmanager *, uint32_t seg_idx); diff --git a/interface/vectored_main.c b/interface/vectored_main.c index 286c243..29dbbee 100644 --- a/interface/vectored_main.c +++ b/interface/vectored_main.c @@ -52,7 +52,7 @@ int main(int argc,char* argv[]){ bench_init(); bench_vectored_configure(); bench_add(VECTOREDSSET,0,RANGE,RANGE/2); - bench_add(VECTOREDSSET,0,RANGE,RANGE); + bench_add(VECTOREDRSET,0,RANGE,RANGE); // bench_add(VECTOREDSGET,0,RANGE,RANGE); // bench_add(VECTOREDRSET,0,RANGE,RANGE); @@ -61,7 +61,7 @@ int main(int argc,char* argv[]){ // bench_add(VECTOREDUNIQRSET,0,RANGE,RANGE); // bench_add(VECTOREDRGET,0, RANGE, RANGE); // bench_add(VECTOREDRW,0, RANGE,(RANGE)*2); - bench_add(VECTOREDRGET,0,RANGE,RANGE); + // bench_add(VECTOREDRGET,0,RANGE,RANGE); // bench_add(VECTOREDLOCALIZEDGET,0,RANGE,RANGE); // bench_add(VECTOREDRGET,0,RANGE,RANGE); // bench_add(VECTOREDRSET,0,RANGE,RANGE*2);