[4/8] Revert "ploop: Remove now unused PLOOP_REQ_ZERO branches"

Submitted by Kirill Tkhai on May 21, 2019, 10:36 a.m.

Details

Message ID 155843496677.28886.437981692807254903.stgit@localhost.localdomain
State New
Series "Revert "ploop: Disable ioctl(PLOOP_IOC_BALLOON)""
Headers show

Commit Message

Kirill Tkhai May 21, 2019, 10:36 a.m.
This reverts commit 7782c0be0c18fe3b27984388cde50dfa04c07f4e.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c    |    5 ++++-
 drivers/block/ploop/events.h |    1 +
 drivers/block/ploop/map.c    |   19 ++++++++++++++++++-
 include/linux/ploop/ploop.h  |    2 ++
 4 files changed, 25 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index e9239f26e5cd..4d3b62d85251 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -244,6 +244,8 @@  void ploop_preq_drop(struct ploop_device * plo, struct list_head *drop_list)
 		put_beancounter(preq->preq_ub);
 		preq->preq_ub = NULL;
 #endif
+
+		BUG_ON (test_bit(PLOOP_REQ_ZERO, &preq->state));
 		ploop_test_and_clear_blockable(plo, preq);
 		drop_qlen++;
 	}
@@ -1774,7 +1776,8 @@  static inline bool preq_is_special(struct ploop_request * preq)
 			PLOOP_REQ_RELOC_A_FL |
 			PLOOP_REQ_RELOC_S_FL |
 			PLOOP_REQ_RELOC_N_FL |
-			PLOOP_REQ_DISCARD_FL);
+			PLOOP_REQ_DISCARD_FL |
+			PLOOP_REQ_ZERO_FL);
 }
 
 void ploop_add_req_to_fsync_queue(struct ploop_request * preq)
diff --git a/drivers/block/ploop/events.h b/drivers/block/ploop/events.h
index 2db09d9ac34b..62144e1b79d6 100644
--- a/drivers/block/ploop/events.h
+++ b/drivers/block/ploop/events.h
@@ -44,6 +44,7 @@ 
 			{ 1 << PLOOP_REQ_RELOC_A,	"RA"},	\
 			{ 1 << PLOOP_REQ_RELOC_S,	"RS"},	\
 			{ 1 << PLOOP_REQ_RELOC_N,	"RN"},	\
+			{ 1 << PLOOP_REQ_ZERO,		"Z"},	\
 			{ 1 << PLOOP_REQ_DISCARD,	"D"})
 
 #define PREQ_FORMAT "preq=0x%p cluster=0x%x iblock=0x%x size=0x%x eng_state=0x%lx state=%s rw=%s"
diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index e03df205b0ab..b8103cfcc79b 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -913,6 +913,14 @@  void ploop_index_update(struct ploop_request * preq)
 		}
 	}
 
+	BUG_ON (test_bit(PLOOP_REQ_ZERO, &preq->state) && preq->iblock);
+	if (test_bit(PLOOP_REQ_ZERO, &preq->state) && !blk) {
+		printk("Either map_node is corrupted or bug in "
+		       "ploop-balloon (%u)\n", preq->req_cluster);
+		PLOOP_REQ_SET_ERROR(preq, -EIO);
+		goto corrupted;
+	}
+
 	if (blk == preq->iblock && top_delta->level == old_level)
 		goto out;
 
@@ -959,6 +967,7 @@  void ploop_index_update(struct ploop_request * preq)
 
 enomem:
 	PLOOP_REQ_SET_ERROR(preq, -ENOMEM);
+corrupted:
 	set_bit(PLOOP_S_ABORT, &plo->state);
 out:
 	preq->eng_state = PLOOP_E_COMPLETE;
@@ -1078,12 +1087,20 @@  static void map_wb_complete(struct map_node * m, int err)
 				struct ploop_request *pr = preq;
 				int do_levels_update = 0;
 
+				if (unlikely(test_bit(PLOOP_REQ_ZERO, &preq->state))) {
+					BUG_ON (list_empty(&preq->delay_list));
+					pr = list_first_entry(&preq->delay_list,
+							      struct ploop_request,
+							      list);
+				}
+
 				if (m->levels &&  m->levels[idx] != top_delta->level) {
 					spin_lock_irq(&plo->lock);
 					do_levels_update = 1;
 				}
 
-				if (unlikely(test_bit(PLOOP_REQ_RELOC_A, &preq->state)))
+				if (unlikely(test_bit(PLOOP_REQ_RELOC_A, &preq->state) ||
+					     test_bit(PLOOP_REQ_ZERO, &preq->state)))
 					map_idx_swap(m, idx, &pr->iblock,
 						     ploop_map_log(plo));
 				else
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 942433cc2ce8..1493e4138254 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -491,6 +491,7 @@  enum
 	PLOOP_REQ_RELOC_A,	/* 'A' stands for allocate() */
 	PLOOP_REQ_RELOC_S,	/* Obsolete: 'S' stands for submit() */
 	PLOOP_REQ_RELOC_N,	/* 'N' stands for "nullify" */
+	PLOOP_REQ_ZERO,		/* Obsolete */
 	PLOOP_REQ_DISCARD,	/* Obsolete */
 	PLOOP_REQ_RSYNC,
 	PLOOP_REQ_KAIO_FSYNC,	/*force image fsync by KAIO module */
@@ -506,6 +507,7 @@  enum
 #define PLOOP_REQ_RELOC_S_FL (1 << PLOOP_REQ_RELOC_S) /* Obsolete */
 #define PLOOP_REQ_RELOC_N_FL (1 << PLOOP_REQ_RELOC_N)
 #define PLOOP_REQ_DISCARD_FL (1 << PLOOP_REQ_DISCARD)	/* Obsolete */
+#define PLOOP_REQ_ZERO_FL (1 << PLOOP_REQ_ZERO)		/* Obsolete */
 
 enum
 {