Пример #1
0
static double ssd_clean_block_fully(int plane_num, int elem_num, ssd_t *s)
{
    int blk;
    double cost = 0;
    double mcost = 0;
    ssd_element_metadata *metadata = &s->elements[elem_num].metadata;
    plane_metadata *pm = &metadata->plane_meta[plane_num];

    ASSERT((pm->clean_in_progress == 0) && (pm->clean_in_block = -1));

    blk = ssd_pick_block_to_clean(plane_num, elem_num, &mcost, metadata, s);
    ASSERT(metadata->block_usage[blk].plane_num == plane_num);

    cost = _ssd_clean_block_fully(blk, plane_num, elem_num, metadata, s);
    return (cost+mcost);
}
Пример #2
0
double ssd_clean_block_partially(int plane_num, int elem_num, ssd_t *s)
{
    ssd_element_metadata *metadata = &(s->elements[elem_num].metadata);
    plane_metadata *pm = &metadata->plane_meta[plane_num];
    double cost = 0;
    double mcost = 0;

    // see if we've already started the cleaning
    if (!pm->clean_in_progress) {
        // pick a block to be cleaned
        pm->clean_in_block = ssd_pick_block_to_clean(plane_num, elem_num, &mcost, metadata, s);
        pm->clean_in_progress = 1;
    }

    // yes, the cleaning on this plane is already initiated
    ASSERT(pm->clean_in_block != -1);
    cost = _ssd_clean_block_partially(plane_num, elem_num, s);

    return (cost+mcost);
}
Пример #3
0
double ssd_clean_element(ssd_t *s, int elem_num)
{
	ssd_element_metadata *metadata;
    double cost = 0;
	int lbn;
	int reserved = s->params.reserve_blocks * s->params.blocks_per_element * 0.01;
	int low_thresold = reserved * 0.9;

	metadata = &(s->elements[elem_num].metadata);
	/*if (!ssd_start_cleaning(-1, elem_num, s)) {
		if(metadata->num_log >= reserved){
			cost = ssd_merge(s, elem_num, lbn);
		}
        return cost;
    }*/
	while (metadata->num_log > low_thresold) {
		lbn = ssd_pick_block_to_clean(-1, elem_num, metadata, s);

		cost += ssd_merge(s, elem_num, lbn);
        //return cost;
    }

    return cost;
}