[7/8] ploop: Return maintaince mode ioctls again

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

Details

Message ID 155843498277.28886.11501347270795396307.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.
Also, move PLOOP_REQ_DISCARD check up in ploop_can_issue_discard(),
since maintaince mode based discard works independent of native
discard mode.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c     |   21 +++++++++++++--------
 drivers/block/ploop/discard.c |    9 ++++++---
 2 files changed, 19 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 4bf0240df622..36df41450c4d 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2185,12 +2185,12 @@  complete_unsupported_discard_req(struct ploop_request * preq)
 static bool ploop_can_issue_discard(struct ploop_device *plo,
 				    struct ploop_request *preq)
 {
-	if (!native_discard_support)
-		return false;
-
 	if (test_bit(PLOOP_REQ_DISCARD, &preq->state))
 		return true;
 
+	if (!native_discard_support)
+		return false;
+
 	if (test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
 		return false;
 
@@ -4566,7 +4566,8 @@  static int ploop_freeblks_ioc(struct ploop_device *plo, unsigned long arg)
 	int i;
 	int rc = 0;
 
-	return 0;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (list_empty(&plo->map.delta_list))
 		return -ENOENT;
@@ -4651,7 +4652,8 @@  static int ploop_fbget_ioc(struct ploop_device *plo, unsigned long arg)
 	struct ploop_freeblks_ctl ctl;
 	int rc = 0;
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (list_empty(&plo->map.delta_list))
 		return -ENOENT;
@@ -4677,7 +4679,8 @@  static int ploop_fbfilter_ioc(struct ploop_device *plo, unsigned long arg)
 {
 	int rc = 0;
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (plo->maintenance_type != PLOOP_MNTN_DISCARD ||
 	    !test_bit(PLOOP_S_DISCARD_LOADED, &plo->state))
@@ -4766,7 +4769,8 @@  static void ploop_discard_restart(struct ploop_device *plo, int err)
 
 static int ploop_fbdrop_ioc(struct ploop_device *plo)
 {
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (list_empty(&plo->map.delta_list))
 		return -ENOENT;
@@ -4794,7 +4798,8 @@  static int ploop_relocblks_ioc(struct ploop_device *plo, unsigned long arg)
 	int err = 0;
 	int n_free;
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (list_empty(&plo->map.delta_list))
 		return -ENOENT;
diff --git a/drivers/block/ploop/discard.c b/drivers/block/ploop/discard.c
index 1920ab05e20b..e27af9baf477 100644
--- a/drivers/block/ploop/discard.c
+++ b/drivers/block/ploop/discard.c
@@ -17,7 +17,8 @@  int ploop_discard_init_ioc(struct ploop_device *plo)
 	struct ploop_freeblks_desc *fbd;
 	struct ploop_delta *delta = ploop_top_delta(plo);
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (delta == NULL)
 		return -EINVAL;
@@ -54,7 +55,8 @@  int ploop_discard_fini_ioc(struct ploop_device *plo)
 	struct ploop_request *preq, *tmp;
 	LIST_HEAD(drop_list);
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (!test_and_clear_bit(PLOOP_S_DISCARD, &plo->state))
 		return 0;
@@ -94,7 +96,8 @@  int ploop_discard_wait_ioc(struct ploop_device *plo)
 {
 	int err;
 
-	return -EINVAL;
+	if (!test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state))
+		return -EINVAL;
 
 	if (!test_bit(PLOOP_S_DISCARD, &plo->state))
 		return 0;