cocalele / PureFlash

A ServerSAN storage system designed for flash device
GNU General Public License v3.0
101 stars 29 forks source link

post COW task to disk io thread #26

Closed qiyuanzhi closed 7 months ago

qiyuanzhi commented 1 year ago
void PfFlashStore::do_cow_entry(lmt_key* key, lmt_entry *srcEntry, lmt_entry *dstEntry)
{//this function called in thread pool, not the store's event thread
    CowTask r;
    r.src_offset = srcEntry->offset;
    r.dst_offset = dstEntry->offset;
    r.size = COW_OBJ_SIZE;
    sem_init(&r.sem, 0, 0);

    r.buf = app_context.cow_buf_pool.alloc(COW_OBJ_SIZE);
    event_queue->post_event(EVT_COW_READ, 0, &r);
    sem_wait(&r.sem);
    if(unlikely(r.complete_status != PfMessageStatus::MSG_STATUS_SUCCESS))  {
        S5LOG_ERROR("COW read failed, status:%d", r.complete_status);
        goto cowfail;
    }

    event_queue->post_event(EVT_COW_WRITE, 0, &r);
    sem_wait(&r.sem);
    if(unlikely(r.complete_status != PfMessageStatus::MSG_STATUS_SUCCESS))  {
        S5LOG_ERROR("COW write failed, status:%d", r.complete_status);
        goto cowfail;
    }

I wonder is it necessary to post cow task to disk thread ? The two blocks(src & dest) were reserved currently, and no other IO will occur until we release them. So, i think cow on current thread is feasible.

qiyuanzhi commented 1 year ago

it seems that only COW_OBJ_SIZE (128K)is copyed to dest block. Is it a coding error ?

cocalele commented 1 year ago

it seems that only COW_OBJ_SIZE (128K)is copyed to dest block. Is it a coding error ?

Yes, you are right. That's a bug. there need a loop to copy the whole entity object in IO size COW_OBJ_SIZE. Not copying the whole entiry object in single IO is to avoid so large an read/write have impact on normal IO.

cocalele commented 10 months ago

This issue is fixed in commit: a82b6f7

The COW read/write IO was issued by a number of std::async tasks, not send to SSD thread.