[1/8] Revert "ploop: Remove now unused PLOOP_E_ZERO_INDEX and PLOOP_E_DELTA_ZERO_INDEX branches"

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

Details

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

Commit Message

Kirill Tkhai May 21, 2019, 10:35 a.m.
This reverts commit a1a81d3c859c17c056fb333ce94fb64679456b2a.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c   |   52 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ploop/ploop.h |    3 ++
 2 files changed, 55 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index eb60d37cd9df..9a7c6aa4f2bf 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2296,6 +2296,58 @@  static void ploop_req_state_process(struct ploop_request * preq)
 					 &sbl, cluster_size_in_sec(plo));
 		break;
 	}
+	case PLOOP_E_ZERO_INDEX:
+	{
+		preq->eng_state = PLOOP_E_DATA_WBI;
+		top_delta = ploop_top_delta(plo);
+		plo->st.bio_out++;
+		if (whole_block(plo, preq)) {
+			top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
+						  &preq->bl, preq->iblock,
+						  preq->req_size);
+		} else {
+			struct bio_list sbl;
+			struct bio * b;
+			int i;
+
+			if (!preq->aux_bio)
+				preq->aux_bio = bio_alloc(GFP_NOFS, block_vecs(plo));
+
+			if (!preq->aux_bio ||
+			    fill_bio(plo, preq->aux_bio, preq->req_cluster)) {
+				PLOOP_REQ_FAIL_IMMEDIATE(preq, -ENOMEM);
+				break;
+			}
+
+			for (i = 0; i < preq->aux_bio->bi_vcnt; i++)
+				memset(page_address(preq->aux_bio->bi_io_vec[i].bv_page),
+				       0, PAGE_SIZE);
+
+			bio_list_for_each(b, &preq->bl) {
+				bio_bcopy(preq->aux_bio, b, plo);
+			}
+
+			sbl.head = sbl.tail = preq->aux_bio;
+			top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
+						  &sbl, preq->iblock, cluster_size_in_sec(plo));
+		}
+		break;
+	}
+	case PLOOP_E_DELTA_ZERO_INDEX:
+	{
+		struct bio_list sbl;
+
+		BUG_ON (preq->aux_bio == NULL);
+
+		preq->eng_state = PLOOP_E_DATA_WBI;
+		sbl.head = sbl.tail = preq->aux_bio;
+		top_delta = ploop_top_delta(plo);
+		plo->st.bio_out++;
+		top_delta->io.ops->submit(&top_delta->io, preq, preq->req_rw,
+					  &sbl, preq->iblock,
+					  cluster_size_in_sec(plo));
+		break;
+	}
 	case PLOOP_E_RELOC_DATA_READ:
 	{
 		struct bio_list sbl;
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 0854faef680f..0bf75437ade3 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -518,6 +518,9 @@  enum
 	PLOOP_E_DATA_WBI,	/* Data writeback is in progress and index
 				 * is not updated.
 				 */
+	PLOOP_E_ZERO_INDEX,	/* Zeroing index of free block; original request
+				   can use .submit on completion */
+	PLOOP_E_DELTA_ZERO_INDEX,/* the same but for PLOOP_E_DELTA_READ */
 	PLOOP_E_FSYNC_PENDED,   /* INDEX_WB needs io->ops->sync() to proceed */
 };