[Devel] [PATCH RHEL7 COMMIT] ploop: move standby mode setting to separate function

Konstantin Khorenko khorenko at virtuozzo.com
Tue Nov 20 13:10:44 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.20.2.vz7.73.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.20.2.vz7.73.6
------>
commit c3d2ac37dec20a1a44da23bd36c36871a7e97e98
Author: Anton Nefedov <anton.nefedov at virtuozzo.com>
Date:   Fri Nov 16 12:46:27 2018 +0300

    ploop: move standby mode setting to separate function
    
    It will be reused in the next patch.
    
    https://pmc.acronis.com/browse/VSTOR-17613
    
    Signed-off-by: Anton Nefedov <anton.nefedov at virtuozzo.com>
    Acked-by: Andrey Zaitsev <azaitsev at virtuozzo.com>
    Acked-by: Sergey Lysanov <slysanov at virtuozzo.com>
    
    ===========================
    Patchset description:
    
    ploop: more cases for standby mode
    
    standby mode motivation:
    
      commit bdadef81aba572fdcfd59e4c5c7b18736c962ebd
      Author: Andrei Vagin <avagin at openvz.org>
      Date:   Thu Mar 1 11:07:34 2018 +0300
    
        ploop: add a standby mode
    
        This mode shows that a delta lease was stolen and it is impossible to
        handle any requests.
    
        We want to know about this situation from the iscsi target. When HA
        decides that the current target is broken, it can initialize another
        target with the same delta. In this case, the first target has to complete
        all in-porgress commands and set the ASCQ_04H_ALUA_TG_PT_STANDBY bit in
        their status.
    
        In Linux, bio-s are always completed with EIO in error cases, so we need
        another way how to determine this state. This patch addes a new block
        queue flag QUEUE_FLAG_STANDBY.
    
    Anton Nefedov (3):
      ploop: move standby mode setting to separate function
      ploop: move to standby mode after fsync() error too
      ploop: move to standby after -ENOTCONN too
---
 drivers/block/ploop/io_kaio.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 3a89d6abb679..03d5a471b310 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -109,6 +109,24 @@ struct kaio_req {
 	struct bio_vec	      bvecs[0];
 };
 
+static void check_standby_mode(long res, struct ploop_device *plo) {
+	struct request_queue *q = plo->queue;
+	int prev;
+
+	/* move to standby if delta lease was stolen */
+	if (res != -EBUSY) {
+		return;
+	}
+
+	spin_lock_irq(q->queue_lock);
+	prev = queue_flag_test_and_set(QUEUE_FLAG_STANDBY, q);
+	spin_unlock_irq(q->queue_lock);
+
+	if (!prev)
+		printk("ploop%d was switched into "
+		       "the standby mode\n", plo->index);
+}
+
 static void kaio_rw_aio_complete(u64 data, long res)
 {
 	struct ploop_request * preq = (struct ploop_request *)data;
@@ -126,22 +144,8 @@ static void kaio_rw_aio_complete(u64 data, long res)
 			printk(" bio=%p: bi_sector=%ld bi_size=%d\n",
 			       b, b->bi_sector, b->bi_size);
 
-		if (res == -EBUSY) { /* a delta lease was stolen */
-			struct request_queue *q = preq->plo->queue;
-			int prev;
-
-			spin_lock_irq(q->queue_lock);
-			prev = queue_flag_test_and_set(QUEUE_FLAG_STANDBY, q);
-			spin_unlock_irq(q->queue_lock);
-
-			if (!prev)
-				printk("ploop%d was switched into "
-					"the standby mode\n", preq->plo->index);
-
-			ploop_req_set_error(preq, res);
-		} else {
-			PLOOP_REQ_SET_ERROR(preq, res);
-		}
+		check_standby_mode(res, preq->plo);
+		PLOOP_REQ_SET_ERROR(preq, res);
 	}
 
 	kaio_complete_io_request(preq);



More information about the Devel mailing list