[08/10] ploop: Zero indexes on discard

Submitted by Kirill Tkhai on March 26, 2019, 3:19 p.m.

Details

Message ID 155361355847.12708.4601876347548548431.stgit@localhost.localdomain
State New
Series "ploop: Discard with zeroing of ploop1 indexes support"
Headers show

Commit Message

Kirill Tkhai March 26, 2019, 3:19 p.m.
Shitch preq into PLOOP_E_DATA_WBI state
to continue execution after discard's write
is finished.
Zero index in that stage.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c        |    5 ++++-
 drivers/block/ploop/fmt_ploop1.c |    5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 618d22bf02ec..3ada41f91867 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2461,7 +2461,10 @@  ploop_entry_request(struct ploop_request * preq)
 					spin_unlock_irq(&plo->lock);
 				}
 				preq->iblock = iblk;
-				preq->eng_state = PLOOP_E_COMPLETE;
+				if (!(preq->req_rw & REQ_DISCARD))
+					preq->eng_state = PLOOP_E_COMPLETE;
+				else
+					preq->eng_state = PLOOP_E_DATA_WBI;
 				__TRACE("T %p %u\n", preq, preq->req_cluster);
 				plo->st.bio_out++;
 				delta->io.ops->submit(&delta->io, preq, preq->req_rw,
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 370aa6369a8a..9cfc56296e5e 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -250,6 +250,11 @@  ploop1_allocate(struct ploop_delta * delta, struct ploop_request * preq,
 static void
 ploop1_allocate_complete(struct ploop_delta * delta, struct ploop_request * preq)
 {
+	if ((preq->req_rw & REQ_DISCARD) &&
+	    !test_bit(PLOOP_REQ_DISCARD, &preq->state)) {
+		preq->iblock = 0;
+	}
+
 	ploop_index_update(preq);
 }