[Devel] [PATCH RHEL7 COMMIT] ploop: resurrect delayed_fua for io_kaio

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 27 00:10:22 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.20
------>
commit 39a8c1f33992dad8fd5a72b34e9cdac1c31aa859
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Mon Jun 27 11:10:22 2016 +0400

    ploop: resurrect delayed_fua for io_kaio
    
    After long thinking it now seems to be clear how
    delayed_fua was supposed to work for io_kaio:
    
    1) An incoming bio marked as REQ_FUA leads to this bit
    set in preq->req_rw.
    
    2) kaio_submit does nothing with this bit in preq->req_rw.
    It only initiates sending data by aio_kernel_submit.
    
    3) When userspace ACKs this WRITE, kaio_complete_io_state
    discovers that even though REQ_FUA bit is set in preq->req_rw,
    eng_state == E_DATA_WBI, so we can delay flush until index
    update.
    
    NB: It is crucial here, that preq->req_rw still needs REQ_FUA
    bit set!
    
    4) index update calls ->write_page() with fua=1 because
    it detects REQ_FUA bit set in preq->req_rw.
    
    5) kaio_write_page observes fua=1 and so set PLOOP_REQ_KAIO_FSYNC
    in preq->state. Then it initiates sending data (BAT update).
    
    6) When userspace ACKs this WRITE (BAT update),
    kaio_complete_io_state detects PLOOP_REQ_KAIO_FSYNC bit set,
    so it clears it and enforces post_fsync=1.
    
    The patch fixes 3) that was broken so far.
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
    Acked-by: Dmitry Monakhov <dmonakhov at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 69df456..e4e4411 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -68,6 +68,7 @@ static void kaio_complete_io_state(struct ploop_request * preq)
 	struct ploop_device * plo   = preq->plo;
 	unsigned long flags;
 	int post_fsync = 0;
+	int need_fua = !!(preq->req_rw & REQ_FUA);
 
 	if (preq->error || !(preq->req_rw & REQ_FUA) ||
 	    preq->eng_state == PLOOP_E_INDEX_READ ||
@@ -80,14 +81,11 @@ static void kaio_complete_io_state(struct ploop_request * preq)
 
 	/* Convert requested fua to fsync */
 	if (test_and_clear_bit(PLOOP_REQ_FORCE_FUA, &preq->state) ||
-	    test_and_clear_bit(PLOOP_REQ_KAIO_FSYNC, &preq->state))
+	    test_and_clear_bit(PLOOP_REQ_KAIO_FSYNC, &preq->state) ||
+	    (need_fua && !ploop_req_delay_fua_possible(preq))) {
 		post_fsync = 1;
-
-	if (!post_fsync &&
-	    !(ploop_req_delay_fua_possible(preq) && (preq->req_rw & REQ_FUA)))
-		post_fsync = 1;
-
-	preq->req_rw &= ~REQ_FUA;
+		preq->req_rw &= ~REQ_FUA;
+	}
 
 	if (post_fsync) {
 		spin_lock_irqsave(&plo->lock, flags);


More information about the Devel mailing list