Skip to content

Commit

Permalink
Done GC without BM
Browse files Browse the repository at this point in the history
  • Loading branch information
tlemsl committed Jul 21, 2022
1 parent 376d6c1 commit 6338e4f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DEBUGFLAGS=\
-Wno-pointer-arith\
-g\
-export-dynamic\
# -fsanitize=address\
-fsanitize=address\

export COMMONFLAGS+=\
-Wno-write-strings\
Expand Down
9 changes: 5 additions & 4 deletions algorithm/normal/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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){
Expand Down
25 changes: 16 additions & 9 deletions algorithm/normal/pFTL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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){
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -129,7 +135,7 @@ void* GC(void* qwer){



}
//}

}
/*
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions include/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions interface/vectored_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 6338e4f

Please sign in to comment.