dm-writeboost icon indicating copy to clipboard operation
dm-writeboost copied to clipboard

discard the segment to acquire

Open akiradeveloper opened this issue 8 years ago • 3 comments

dm-writeboost uses SSD cache device like logging. It splits whole region into segments and when it reaches the last, it returns back to the first segment.

Telling the SSD device that all the cache blocks in the segment is now needless and can be reclaimed is useful because log could be partial. Partial log doesn't overwrite the segment in full extent so rest of the region that wasn't overwritten is still being recognized as non-reclaimable.

But my past experiment showed that discard is not costless so I just keep a memo.

akiradeveloper avatar Jun 19 '16 08:06 akiradeveloper

this is unlikely to occur but if we don't discard the segment everytime, the SSD controller can never realize some blocks in the segment are reclaimable because there isn't overwrite on the blocks. SSD controller can naturally realize some blocks are reclaimable when they are overwritten but otherwise no chance to realize it.

So these blocks are always kept in flash blocks inside the SSD and may cause massive copying.

It would be better to discard segments

akiradeveloper avatar Jul 15 '16 02:07 akiradeveloper

but please be sure that no bad impact on the performance. This should be easily measurable by randwrite test

akiradeveloper avatar Jul 15 '16 02:07 akiradeveloper

If we do this, we should insert blkdev_issue_discard into

void acquire_new_seg(struct wb_device *wb, u64 id)
{
    struct segment_header *new_seg = get_segment_header_by_id(wb, id);

    /*
     * We wait for all requests to the new segment is consumed.
     * Mutex taken guarantees that no new I/O to this segment is coming in.
     */
    wait_event(wb->inflight_ios_wq,
        !atomic_read(&new_seg->nr_inflight_ios));

    wait_for_writeback(wb, SUB_ID(id, wb->nr_segments));
    if (count_dirty_caches_remained(new_seg)) {
        DMERR("%u dirty caches remained. id:%llu",
              count_dirty_caches_remained(new_seg), id);
        BUG();
    }
    discard_caches_inseg(wb, new_seg);
    // HERE

akiradeveloper avatar Jul 22 '16 11:07 akiradeveloper