Skip to content

Commit

Permalink
raid5-cache: new helper: r5_reserve_log_entry
Browse files Browse the repository at this point in the history
Factor out code to reserve log space.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Shaohua Li <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
  • Loading branch information
Christoph Hellwig authored and NeilBrown committed Nov 1, 2015
1 parent 51039cd commit c1b9919
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions drivers/md/raid5-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ static struct bio *r5l_bio_alloc(struct r5l_log *log, struct r5l_io_unit *io)
return bio;
}

static void r5_reserve_log_entry(struct r5l_log *log, struct r5l_io_unit *io)
{
log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);

/*
* If we filled up the log device start from the beginning again,
* which will require a new bio.
*
* Note: for this to work properly the log size needs to me a multiple
* of BLOCK_SECTORS.
*/
if (log->log_start == 0)
io->current_bio = NULL;

io->log_end = log->log_start;
}

static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
{
struct r5l_io_unit *io;
Expand Down Expand Up @@ -299,11 +316,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0);

log->seq++;
log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);
io->log_end = log->log_start;
/* current bio hit disk end */
if (log->log_start == 0)
io->current_bio = NULL;
r5_reserve_log_entry(log, io);

spin_lock_irq(&log->io_list_lock);
list_add_tail(&io->log_sibling, &log->running_ios);
Expand Down Expand Up @@ -357,13 +370,8 @@ static void r5l_append_payload_page(struct r5l_log *log, struct page *page)
io->current_bio = NULL;
goto alloc_bio;
}
log->log_start = r5l_ring_add(log, log->log_start,
BLOCK_SECTORS);
/* current bio hit disk end */
if (log->log_start == 0)
io->current_bio = NULL;

io->log_end = log->log_start;
r5_reserve_log_entry(log, io);
}

static void r5l_log_stripe(struct r5l_log *log, struct stripe_head *sh,
Expand Down

0 comments on commit c1b9919

Please sign in to comment.