Signed-off-by: Kirill Tkhai <[email protected]>
---
 drivers/md/dm-ploop-map.c |   27 +++++++++++++++------------
 drivers/md/dm-ploop.h     |    2 +-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index ca4a3a154578..a0bbb4607923 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -91,6 +91,7 @@ static void init_pio(struct ploop *ploop, unsigned int bi_op, 
struct pio *pio)
        pio->ploop = ploop;
        pio->bi_op = bi_op;
        pio->action = PLOOP_END_IO_NONE;
+       pio->is_data_alloc = false;
        pio->ref_index = PLOOP_REF_INDEX_INVALID;
        pio->bi_status = BLK_STS_OK;
        pio->piwb = NULL;
@@ -863,13 +864,14 @@ static int ploop_alloc_cluster(struct ploop *ploop, 
struct ploop_index_wb *piwb,
        return ret;
 }
 
-
-static int ploop_data_pio_end(struct pio *pio)
+static bool ploop_data_pio_end(struct pio *pio)
 {
        struct ploop_index_wb *piwb = pio->piwb;
        unsigned long flags;
        bool completed;
 
+       dec_nr_inflight(piwb->ploop, pio);
+
        spin_lock_irqsave(&piwb->lock, flags);
        completed = piwb->completed;
        if (!completed)
@@ -878,13 +880,9 @@ static int ploop_data_pio_end(struct pio *pio)
                pio->bi_status = piwb->bi_status;
        spin_unlock_irqrestore(&piwb->lock, flags);
 
-       dec_nr_inflight(piwb->ploop, pio);
-
-       if (!completed)
-               return DM_ENDIO_INCOMPLETE;
-
        put_piwb(piwb);
-       return DM_ENDIO_DONE;
+
+       return completed;
 }
 
 static bool ploop_attach_end_action(struct pio *h, struct ploop_index_wb *piwb)
@@ -898,7 +896,7 @@ static bool ploop_attach_end_action(struct pio *h, struct 
ploop_index_wb *piwb)
        if (!atomic_inc_not_zero(&piwb->count))
                return false;
 
-       h->action = PLOOP_END_IO_DATA_BIO;
+       h->is_data_alloc = true;
        h->piwb = piwb;
 
        return true;
@@ -926,9 +924,17 @@ static void ploop_read_aio_complete(struct kiocb *iocb, 
long ret, long ret2)
 
 static void data_rw_complete(struct pio *pio)
 {
+       bool completed;
+
        if (pio->ret != pio->bi_iter.bi_size)
                 pio->bi_status = BLK_STS_IOERR;
 
+       if (pio->is_data_alloc) {
+               completed = ploop_data_pio_end(pio);
+               if (!completed)
+                       return;
+       }
+
        pio_endio(pio);
 }
 
@@ -1761,9 +1767,6 @@ static int ploop_endio(struct ploop *ploop, struct pio 
*pio)
         * processing, and that we are going to call bi_end_io
         * directly later again.
         */
-       if (pio->action == PLOOP_END_IO_DATA_BIO)
-               ret = ploop_data_pio_end(pio);
-
        if (pio->action == PLOOP_END_IO_DISCARD_INDEX_BIO)
                ret = ploop_discard_index_pio_end(ploop, pio);
 
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 59f706ac8af5..0b28fa8b453e 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -257,9 +257,9 @@ struct pio {
        unsigned int cluster;
 
 #define PLOOP_END_IO_NONE              0
-#define PLOOP_END_IO_DATA_BIO          1
 #define PLOOP_END_IO_DISCARD_INDEX_BIO 3
        unsigned int action:2;
+       bool is_data_alloc:1;
        /*
         * 0 and 1 are related to inflight_bios_ref[],
         * 2 means index is not assigned.


_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to