aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2015-09-02 16:49:49 -0400
committerNeilBrown <neilb@suse.com>2015-10-31 22:48:26 -0400
commit828cbe989e4f5c8666cb3d99918b03666ccde0a0 (patch)
treed0a2523905dbada0b75104e22e6b8d93fec77a78
parent509ffec7089d10521ac91d4537b789d76103b4c0 (diff)
raid5-cache: optimize FLUSH IO with log enabled
With log enabled, bio is written to raid disks after the bio is settled down in log disk. The recovery guarantees we can recovery the bio data from log disk, so we we skip FLUSH IO. Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
-rw-r--r--drivers/md/raid5-cache.c18
-rw-r--r--drivers/md/raid5.c11
-rw-r--r--drivers/md/raid5.h1
3 files changed, 28 insertions, 2 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 6479f15a5434..ea1480392eba 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -507,6 +507,24 @@ void r5l_write_stripe_run(struct r5l_log *log)
507 mutex_unlock(&log->io_mutex); 507 mutex_unlock(&log->io_mutex);
508} 508}
509 509
510int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio)
511{
512 if (!log)
513 return -ENODEV;
514 /*
515 * we flush log disk cache first, then write stripe data to raid disks.
516 * So if bio is finished, the log disk cache is flushed already. The
517 * recovery guarantees we can recovery the bio from log disk, so we
518 * don't need to flush again
519 */
520 if (bio->bi_iter.bi_size == 0) {
521 bio_endio(bio);
522 return 0;
523 }
524 bio->bi_rw &= ~REQ_FLUSH;
525 return -EAGAIN;
526}
527
510/* This will run after log space is reclaimed */ 528/* This will run after log space is reclaimed */
511static void r5l_run_no_space_stripes(struct r5l_log *log) 529static void r5l_run_no_space_stripes(struct r5l_log *log)
512{ 530{
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 46042c7c25a5..a622ccb3477a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5146,8 +5146,15 @@ static void make_request(struct mddev *mddev, struct bio * bi)
5146 bool do_prepare; 5146 bool do_prepare;
5147 5147
5148 if (unlikely(bi->bi_rw & REQ_FLUSH)) { 5148 if (unlikely(bi->bi_rw & REQ_FLUSH)) {
5149 md_flush_request(mddev, bi); 5149 int ret = r5l_handle_flush_request(conf->log, bi);
5150 return; 5150
5151 if (ret == 0)
5152 return;
5153 if (ret == -ENODEV) {
5154 md_flush_request(mddev, bi);
5155 return;
5156 }
5157 /* ret == -EAGAIN, fallback */
5151 } 5158 }
5152 5159
5153 md_write_start(mddev, bi); 5160 md_write_start(mddev, bi);
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 1f16d437bfda..32c8ce81248b 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -629,4 +629,5 @@ extern int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh);
629extern void r5l_write_stripe_run(struct r5l_log *log); 629extern void r5l_write_stripe_run(struct r5l_log *log);
630extern void r5l_flush_stripe_to_raid(struct r5l_log *log); 630extern void r5l_flush_stripe_to_raid(struct r5l_log *log);
631extern void r5l_stripe_write_finished(struct stripe_head *sh); 631extern void r5l_stripe_write_finished(struct stripe_head *sh);
632extern int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
632#endif 633#endif