提交 828cbe98 编写于 作者: S Shaohua Li 提交者: NeilBrown

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: NShaohua Li <shli@fb.com>
Signed-off-by: NNeilBrown <neilb@suse.com>
上级 509ffec7
...@@ -507,6 +507,24 @@ void r5l_write_stripe_run(struct r5l_log *log) ...@@ -507,6 +507,24 @@ void r5l_write_stripe_run(struct r5l_log *log)
mutex_unlock(&log->io_mutex); mutex_unlock(&log->io_mutex);
} }
int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio)
{
if (!log)
return -ENODEV;
/*
* we flush log disk cache first, then write stripe data to raid disks.
* So if bio is finished, the log disk cache is flushed already. The
* recovery guarantees we can recovery the bio from log disk, so we
* don't need to flush again
*/
if (bio->bi_iter.bi_size == 0) {
bio_endio(bio);
return 0;
}
bio->bi_rw &= ~REQ_FLUSH;
return -EAGAIN;
}
/* This will run after log space is reclaimed */ /* This will run after log space is reclaimed */
static void r5l_run_no_space_stripes(struct r5l_log *log) static void r5l_run_no_space_stripes(struct r5l_log *log)
{ {
......
...@@ -5146,9 +5146,16 @@ static void make_request(struct mddev *mddev, struct bio * bi) ...@@ -5146,9 +5146,16 @@ static void make_request(struct mddev *mddev, struct bio * bi)
bool do_prepare; bool do_prepare;
if (unlikely(bi->bi_rw & REQ_FLUSH)) { if (unlikely(bi->bi_rw & REQ_FLUSH)) {
int ret = r5l_handle_flush_request(conf->log, bi);
if (ret == 0)
return;
if (ret == -ENODEV) {
md_flush_request(mddev, bi); md_flush_request(mddev, bi);
return; return;
} }
/* ret == -EAGAIN, fallback */
}
md_write_start(mddev, bi); md_write_start(mddev, bi);
......
...@@ -629,4 +629,5 @@ extern int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh); ...@@ -629,4 +629,5 @@ extern int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh);
extern void r5l_write_stripe_run(struct r5l_log *log); extern void r5l_write_stripe_run(struct r5l_log *log);
extern void r5l_flush_stripe_to_raid(struct r5l_log *log); extern void r5l_flush_stripe_to_raid(struct r5l_log *log);
extern void r5l_stripe_write_finished(struct stripe_head *sh); extern void r5l_stripe_write_finished(struct stripe_head *sh);
extern int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册