dm-writeboost
dm-writeboost copied to clipboard
discard the segment to acquire
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.
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
but please be sure that no bad impact on the performance. This should be easily measurable by randwrite test
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