aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-10-05 03:31:14 -0400
committerNeilBrown <neilb@suse.com>2015-10-31 22:48:28 -0400
commitc1b9919849866b96dc435f025beaa307dc76ca27 (patch)
tree7e96f4aedd6aeaf9cec5ff0014768f98ebd8d137
parent51039cd066553689bb82a588b25a6eba7d453837 (diff)
raid5-cache: new helper: r5_reserve_log_entry
Factor out code to reserve log space. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
-rw-r--r--drivers/md/raid5-cache.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 88758285261c..ea20d740a67c 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -271,6 +271,23 @@ static struct bio *r5l_bio_alloc(struct r5l_log *log, struct r5l_io_unit *io)
271 return bio; 271 return bio;
272} 272}
273 273
274static void r5_reserve_log_entry(struct r5l_log *log, struct r5l_io_unit *io)
275{
276 log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);
277
278 /*
279 * If we filled up the log device start from the beginning again,
280 * which will require a new bio.
281 *
282 * Note: for this to work properly the log size needs to me a multiple
283 * of BLOCK_SECTORS.
284 */
285 if (log->log_start == 0)
286 io->current_bio = NULL;
287
288 io->log_end = log->log_start;
289}
290
274static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log) 291static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
275{ 292{
276 struct r5l_io_unit *io; 293 struct r5l_io_unit *io;
@@ -299,11 +316,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
299 bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0); 316 bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0);
300 317
301 log->seq++; 318 log->seq++;
302 log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS); 319 r5_reserve_log_entry(log, io);
303 io->log_end = log->log_start;
304 /* current bio hit disk end */
305 if (log->log_start == 0)
306 io->current_bio = NULL;
307 320
308 spin_lock_irq(&log->io_list_lock); 321 spin_lock_irq(&log->io_list_lock);
309 list_add_tail(&io->log_sibling, &log->running_ios); 322 list_add_tail(&io->log_sibling, &log->running_ios);
@@ -357,13 +370,8 @@ alloc_bio:
357 io->current_bio = NULL; 370 io->current_bio = NULL;
358 goto alloc_bio; 371 goto alloc_bio;
359 } 372 }
360 log->log_start = r5l_ring_add(log, log->log_start,
361 BLOCK_SECTORS);
362 /* current bio hit disk end */
363 if (log->log_start == 0)
364 io->current_bio = NULL;
365 373
366 io->log_end = log->log_start; 374 r5_reserve_log_entry(log, io);
367} 375}
368 376
369static void r5l_log_stripe(struct r5l_log *log, struct stripe_head *sh, 377static void r5l_log_stripe(struct r5l_log *log, struct stripe_head *sh,