]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
raid5-cache: optimize FLUSH IO with log enabled
authorShaohua Li <shli@fb.com>
Wed, 2 Sep 2015 20:49:49 +0000 (13:49 -0700)
committerNeilBrown <neilb@suse.com>
Sun, 1 Nov 2015 02:48:26 +0000 (13:48 +1100)
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>
drivers/md/raid5-cache.c
drivers/md/raid5.c
drivers/md/raid5.h

index 6479f15a543415f153858c5fc8bb4debfd55d524..ea1480392ebac3c0cbad7119a5955823b58a5b46 100644 (file)
@@ -507,6 +507,24 @@ void r5l_write_stripe_run(struct r5l_log *log)
        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 */
 static void r5l_run_no_space_stripes(struct r5l_log *log)
 {
index 46042c7c25a5d69c471d832724aa12398ee2241a..a622ccb3477a09f306bf716f98881e61c7ae92b3 100644 (file)
@@ -5146,8 +5146,15 @@ static void make_request(struct mddev *mddev, struct bio * bi)
        bool do_prepare;
 
        if (unlikely(bi->bi_rw & REQ_FLUSH)) {
-               md_flush_request(mddev, bi);
-               return;
+               int ret = r5l_handle_flush_request(conf->log, bi);
+
+               if (ret == 0)
+                       return;
+               if (ret == -ENODEV) {
+                       md_flush_request(mddev, bi);
+                       return;
+               }
+               /* ret == -EAGAIN, fallback */
        }
 
        md_write_start(mddev, bi);
index 1f16d437bfda2b227682ea28ec3fdfc4522f721a..32c8ce81248b53581e8601552f47f441ebe14933 100644 (file)
@@ -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_flush_stripe_to_raid(struct r5l_log *log);
 extern void r5l_stripe_write_finished(struct stripe_head *sh);
+extern int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
 #endif