[RHEL7,COMMIT] Revert "ploop: Remove now unused PLOOP_REQ_DISCARD branches"

Submitted by Konstantin Khorenko on May 21, 2019, 2:44 p.m.

Details

Message ID 201905211444.x4LEiRJY025471@finist-ce7.sw.ru
State New
Series "Revert "ploop: Disable ioctl(PLOOP_IOC_BALLOON)""
Headers show

Commit Message

Konstantin Khorenko May 21, 2019, 2:44 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.1
------>
commit ff4a93bb0a57db2ae36f959bb4adb4ff09146cda
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue May 21 17:44:26 2019 +0300

    Revert "ploop: Remove now unused PLOOP_REQ_DISCARD branches"
    
    This reverts commit 638a5c99f1897b406d5f0e7d802b601989f731b0.
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Return maintaince mode
    
    This patch set enables it for vstorage.
    
    Also, added file /sys/block/ploopXXX/pstate/native_discard,
    which shows, whether we should use maintaince-mode based
    discard or not.
    
    https://jira.sw.ru/browse/PSBM-94662
    
    Kirill Tkhai (8):
          Revert "ploop: Remove now unused PLOOP_E_ZERO_INDEX and PLOOP_E_DELTA_ZERO_INDEX branches"
          Revert "ploop: Remove now unused PLOOP_REQ_RELOC_S branches"
          Revert "ploop: Remove now unused PLOOP_REQ_DISCARD branches"
          Revert "ploop: Remove now unused PLOOP_REQ_ZERO branches"
          Revert "ploop: Remove obsolete ioctls"
          Partial revert "ploop: Enable native discard support for kaio engine"
          ploop: Return maintaince mode ioctls again
          ploop: Show whether device supports native discard
---
 drivers/block/ploop/dev.c        | 14 +++++++++++++-
 drivers/block/ploop/events.h     |  3 ++-
 drivers/block/ploop/fmt_ploop1.c |  4 +++-
 include/linux/ploop/ploop.h      |  5 +++++
 4 files changed, 23 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index e9501f45da0c..e9239f26e5cd 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -791,6 +791,9 @@  process_discard_bio_queue(struct ploop_device * plo, struct list_head *drop_list
 		if (tmp == NULL)
 			break;
 
+		/* If PLOOP_S_DISCARD isn't set, ploop_bio_queue
+		 * will complete it with a proper error.
+		 */
 		ploop_bio_queue(plo, tmp, drop_list, 0);
 	}
 }
@@ -1770,7 +1773,8 @@  static inline bool preq_is_special(struct ploop_request * preq)
 	return state & (PLOOP_REQ_MERGE_FL |
 			PLOOP_REQ_RELOC_A_FL |
 			PLOOP_REQ_RELOC_S_FL |
-			PLOOP_REQ_RELOC_N_FL);
+			PLOOP_REQ_RELOC_N_FL |
+			PLOOP_REQ_DISCARD_FL);
 }
 
 void ploop_add_req_to_fsync_queue(struct ploop_request * preq)
@@ -1801,6 +1805,9 @@  static bool ploop_can_issue_discard(struct ploop_device *plo,
 	if (!native_discard_support)
 		return false;
 
+	if (test_bit(PLOOP_REQ_DISCARD, &preq->state))
+		return true;
+
 	if (test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
 		return false;
 
@@ -2712,6 +2719,11 @@  static int ploop_thread(void * data)
 			plo->active_reqs++;
 			ploop_entry_qlen_dec(preq);
 
+			if (test_bit(PLOOP_REQ_DISCARD, &preq->state)) {
+				BUG_ON(plo->maintenance_type != PLOOP_MNTN_DISCARD);
+				atomic_inc(&plo->maintenance_cnt);
+			}
+
 			if (test_bit(PLOOP_REQ_SORTED, &preq->state)) {
 				rb_erase(&preq->lockout_link, req_entry_tree(plo, preq->req_rw));
 				__clear_bit(PLOOP_REQ_SORTED, &preq->state);
diff --git a/drivers/block/ploop/events.h b/drivers/block/ploop/events.h
index 57f72e6b3b80..2db09d9ac34b 100644
--- a/drivers/block/ploop/events.h
+++ b/drivers/block/ploop/events.h
@@ -43,7 +43,8 @@ 
 			{ 1 << PLOOP_REQ_MERGE,		"M"},	\
 			{ 1 << PLOOP_REQ_RELOC_A,	"RA"},	\
 			{ 1 << PLOOP_REQ_RELOC_S,	"RS"},	\
-			{ 1 << PLOOP_REQ_RELOC_N,	"RN"})
+			{ 1 << PLOOP_REQ_RELOC_N,	"RN"},	\
+			{ 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/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index a09a52c651ea..2ae22179c9c5 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -356,8 +356,10 @@  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)
+	if ((preq->req_rw & REQ_DISCARD) &&
+	    !test_bit(PLOOP_REQ_DISCARD, &preq->state)) {
 		preq->iblock = 0;
+	}
 
 	ploop_index_update(preq);
 }
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 4beaa8a9f5d1..942433cc2ce8 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -53,6 +53,9 @@  enum {
 				 * consumed by userspace yet */
 	PLOOP_S_CONGESTED,	/* Too many bios submitted to us */
 	PLOOP_S_NO_FALLOC_DISCARD, /* FIXME: Remove this: Unable to handle discard requests by fallocate */
+	PLOOP_S_DISCARD,	/* Obsolete: ploop is ready to handle discard request */
+	PLOOP_S_DISCARD_LOADED,	/* Obsolete: A discard request was handled and
+				   free blocks loaded */
 	PLOOP_S_LOCKED,	        /* ploop is locked by userspace
 				   (for minor mgmt only) */
 	PLOOP_S_ONCE,	        /* An event (e.g. printk once) happened */
@@ -488,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_DISCARD,	/* Obsolete */
 	PLOOP_REQ_RSYNC,
 	PLOOP_REQ_KAIO_FSYNC,	/*force image fsync by KAIO module */
 	PLOOP_REQ_POST_SUBMIT, /* preq needs post_submit processing */
@@ -501,6 +505,7 @@  enum
 #define PLOOP_REQ_RELOC_A_FL (1 << PLOOP_REQ_RELOC_A)
 #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 */
 
 enum
 {