[Devel] [PATCH RHEL7 COMMIT] ploop: make image fsync at I/O complete if it's required by FUA/fsync force flag or by req->req_rw

Konstantin Khorenko khorenko at odin.com
Mon May 18 21:27:14 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.1
------>
commit 0bc3bb14f31953d09e3dfdfb9a19f96c8f49d713
Author: Andrey Smetanin <asmetanin at virtuozzo.com>
Date:   Tue May 19 08:27:14 2015 +0400

    ploop: make image fsync at I/O complete if it's required by FUA/fsync force flag or by req->req_rw
    
    Series description:
    
    During relocation of ploop clusters (resize/baloon) we need to FUA/fsync
    image file after such operations:
     a) new data block wrote
     b) BAT update
     c) nullify old data block for BAT grow. We do this already nullify of old data
    block at format module -> complete_grow callback.
    
    This patch forses fsync(kaio), FUA(direct) of reloc write I/O to image
    by marking such reloc reqs(A|S) with appropriate flags. Kaio/direct modules
    tuned by patch to force fsync/FUA if these flags are set. This code does
    FUA/fsync only for a) and b) cases, while c) already implemented.
    
    Also patch fixes inconsistent bio list FUA processing in direct module.
    The problem is that for bunch of bios we only set FUA at last bio. Its possible
    in case of power outage that last bio will be stored and previos are not
    because they are stored only in cache at the time of power failure.
    To solve problem this patch marking last bio as FLUSH|FUA if more than one bio
    in list.
    
    Moreover for KAIO if fsync possible at BAT update stage we do that like we
    did in direct case instead of 2 fsync's. For direct case if we going to make
    FUA at BAT update only(optimization trick that already exists) then we need
    to mark req to FLUSH previously written(without FUA) data.
    
    Performance:
    Overall(includes EXT4 resize upto 16T) resize performance degradated by -5% of
    time.
    
    https://jira.sw.ru/browse/PSBM-31222
    https://jira.sw.ru/browse/PSBM-31225
    https://jira.sw.ru/browse/PSBM-31321
    
    Signed-off-by: Andrey Smetanin <asmetanin at parallels.com>
    
    Andrey Smetanin (7):
      ploop: define struct ploop_request->state flags to force pre FLUSH
        before write IO and FUA/fsync at I/O complete
      ploop: mark reloc reqs to force FUA/fsync(kaio) for index update I/O
      ploop: mark reloc reqs to force FUA before write of relocated data
      ploop: direct: to support truly FLUSH/FUA of req we need mark first
        bio FLUSH, write all bios and mark last bio as FLUSH/FUA
      ploop: added ploop_req_delay_fua_possible() func that detects possible
        delaying of upcoming FUA to index update stage. This function will
        be lately used in direct/kaio code to detect and delay FUA
      ploop: make image fsync at I/O complete if it's required by FUA/fsync
        force flag or by req->req_rw
      ploop: do preflush or postfua according force FUA/flush flags, and
        delay FUA if possible but add force FLUSH to req if so
    
    This patch description:
    At kaio I/O complete post fsync according to preq->state flags and preq->req_rw
    flags.
    
    https://jira.sw.ru/browse/PSBM-31222
    https://jira.sw.ru/browse/PSBM-31225
    https://jira.sw.ru/browse/PSBM-31321
    
    Signed-off-by: Andrey Smetanin <asmetanin at parallels.com>
    
    Reviewed-by: Andrew Vagin <avagin at parallels.com>
---
 drivers/block/ploop/io_kaio.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 683b5056..8f62f62 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -60,6 +60,7 @@ static void kaio_complete_io_state(struct ploop_request * preq)
 {
 	struct ploop_device * plo   = preq->plo;
 	unsigned long flags;
+	int post_fsync = 0;
 
 	if (preq->error || !(preq->req_rw & REQ_FUA) ||
 	    preq->eng_state == PLOOP_E_INDEX_READ ||
@@ -72,10 +73,26 @@ static void kaio_complete_io_state(struct ploop_request * preq)
 
 	preq->req_rw &= ~REQ_FUA;
 
-	spin_lock_irqsave(&plo->lock, flags);
-	kaio_queue_fsync_req(preq);
-	plo->st.bio_syncwait++;
-	spin_unlock_irqrestore(&plo->lock, flags);
+	/* 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))
+		post_fsync = 1;
+
+	if (!post_fsync &&
+	    !ploop_req_delay_fua_possible(preq->req_rw, preq) &&
+	    (preq->req_rw & REQ_FUA))
+		post_fsync = 1;
+
+	preq->req_rw &= ~REQ_FUA;
+
+	if (post_fsync) {
+		spin_lock_irqsave(&plo->lock, flags);
+		kaio_queue_fsync_req(preq);
+		plo->st.bio_syncwait++;
+		spin_unlock_irqrestore(&plo->lock, flags);
+	} else {
+		ploop_complete_io_state(preq);
+	}
 }
 
 static void kaio_complete_io_request(struct ploop_request * preq)
@@ -603,6 +620,11 @@ kaio_write_page(struct ploop_io * io, struct ploop_request * preq,
 		 struct page * page, sector_t sec, int fua)
 {
 	ploop_prepare_tracker(preq, sec);
+
+	/* No FUA in kaio, convert it to fsync */
+	if (fua)
+		set_bit(PLOOP_REQ_KAIO_FSYNC, &preq->state);
+
 	kaio_io_page(io, IOCB_CMD_WRITE_ITER, preq, page, sec);
 }
 



More information about the Devel mailing list