akiradeveloper / dm-writeboost

Log-structured Caching for Linux
GNU General Public License v2.0
123 stars 19 forks source link

make the size of read cache cells tunable #122

Closed akiradeveloper closed 8 years ago

akiradeveloper commented 8 years ago
static int init_read_cache_cells(struct wb_device *wb)
{
    struct read_cache_cells *cells;
    INIT_WORK(&wb->read_cache_work, read_cache_proc);
    cells = alloc_read_cache_cells(wb, 2048); /* 8MB */

As of now, read cache cells is a fixed size that is 2048 * 4KB (8MB in total). read data are once cached in the cells and when the cells is full, flushed to the rambuffer as clean write requests (cf. inject_read_cache)

static void read_cache_cell_copy_data(struct wb_device *wb, struct bio *bio, int error)
{
    struct per_bio_data *pbd = per_bio_data(wb, bio);
    struct read_cache_cells *cells = wb->read_cache_cells;
    struct read_cache_cell *cell = cells->array + pbd->cell_idx;

    /* Data can be broken. So don't stage. */
    if (error)
        cell->cancelled = true;

    /*
     * We can omit copying if the cell is cancelled but
     * copying for a non-cancelled cell isn't problematic.
     */
    if (!cell->cancelled)
        copy_bio_payload(cell->data, bio);

    if (atomic_dec_and_test(&cells->ack_count)) // when all cells are used.
        queue_work(cells->wq, &wb->read_cache_work);

This value is carefully chosen for the production use. But setting this value to 1 makes testing read-caching easy because the behavior becomes more predictable.

Since we need more white-box tests for the read-caching, making the value tunable will pay off.

akiradeveloper commented 8 years ago

I add some tests that's still ignored because this fix is not given yet. This isn't a tunable for users but myself only.

akiradeveloper commented 8 years ago

fix-122 passed the test. will be merged.

[info] REPRO_122:
[info] - nr_read_cache_cells works
[info] Run completed in 12 seconds, 534 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.