[Devel] [PATCH RHEL7 COMMIT] ploop: Skip repeated discard

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 14 15:18:53 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.5.1.vz7.84.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.5.1.vz7.84.9
------>
commit 26c4b081923ab95a1b08726cd26439bf980ff35f
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Mar 14 15:18:51 2019 +0300

    ploop: Skip repeated discard
    
    We can't issue repeated discard in the same place,
    so this patch prohibits it.
    
    Otherwise there will be an allocation with
    zero size page:
    
    ploop_request::req_rw = REQ_WRITE|REQ_DISCARD
    
    struct bio_vec {
      bv_page = 0x0,
      bv_len = 0,
      bv_offset = 0
    }
    
    This hunk strangly went in the second part of patches unsent.
    
    https://jira.sw.ru/browse/PSBM-92656
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/dev.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 518b52e8f0d0..6349f0d556be 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2173,6 +2173,14 @@ void ploop_add_req_to_fsync_queue(struct ploop_request * preq)
 	spin_unlock_irq(&plo->lock);
 }
 
+static void
+complete_unsupported_discard_req(struct ploop_request * preq)
+{
+	preq->eng_state = PLOOP_E_COMPLETE;
+	preq->error = -EOPNOTSUPP;
+	ploop_complete_io_state(preq);
+}
+
 static void
 ploop_entry_request(struct ploop_request * preq)
 {
@@ -2482,6 +2490,12 @@ ploop_entry_request(struct ploop_request * preq)
 						      &sbl, iblk, cluster_size_in_sec(plo));
 			}
 		} else {
+			if (unlikely(preq->req_rw & REQ_DISCARD)) {
+				/* Skip repeated discard */
+				complete_unsupported_discard_req(preq);
+				return;
+			}
+
 			if (!whole_block(plo, preq) && map_index_fault(preq) == 0) {
 					__TRACE("f %p %u\n", preq, preq->req_cluster);
 					return;
@@ -2617,9 +2631,7 @@ static void ploop_req_state_process(struct ploop_request * preq)
 
 		if ((preq->req_rw & REQ_DISCARD) &&
 		    !ploop_can_issue_discard(plo, preq)) {
-			preq->eng_state = PLOOP_E_COMPLETE;
-			preq->error = -EOPNOTSUPP;
-			ploop_complete_io_state(preq);
+			complete_unsupported_discard_req(preq);
 #ifdef CONFIG_BEANCOUNTERS
 			if (saved_ub) {
 				saved_ub = set_exec_ub(saved_ub);



More information about the Devel mailing list