engines/rbd: issue initial flush to enable writeback/around mode
authorJason Dillaman <dillaman@redhat.com>
Wed, 2 Dec 2020 19:03:42 +0000 (14:03 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 2 Dec 2020 19:06:11 +0000 (14:06 -0500)
By default librbd will use a writethrough cache until it receives
the first flush. Send a no-op flush after opening the image to
ensure writearound (default) or writeback cache modes can be
properly enabled (unlesss direct=1).

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
engines/rbd.c

index 336837e9d812bb0119308a62620a4cb2b1382003..c6203d4c2a68173da20073f3f75863b6ec63ed38 100644 (file)
@@ -240,6 +240,17 @@ static int _fio_rbd_connect(struct thread_data *td)
                goto failed_open;
        }
 
+       if (!td->o.odirect) {
+               /*
+                * ensure cache enables writeback/around mode unless explicitly
+                * configured for writethrough mode
+                */
+               r = rbd_flush(rbd->image);
+               if (r < 0) {
+                       log_info("rbd: failed to issue initial flush\n");
+               }
+       }
+
        if (!_fio_rbd_setup_poll(rbd))
                goto failed_poll;