[RH7,5/6] ploop: Allow FUSE to avoid maintaince mode based discard

Submitted by Kirill Tkhai on Sept. 3, 2020, 2:13 p.m.

Details

Message ID 159914238153.142757.9834324305893304500.stgit@localhost.localdomain
State New
Series "ploop: Rework queue_settings autoconfig and allow fuse 4K discard"
Headers show

Commit Message

Kirill Tkhai Sept. 3, 2020, 2:13 p.m.
Check whether delta stack configuration allows fallocate
based discard, and enable it if so when requested.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/sysfs.c |    7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index b6875ba971f0..4cb5d9d99456 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -386,6 +386,11 @@  static int store_discard_granularity(struct ploop_device *plo, u32 val)
 		goto unlock;
 	}
 
+	if (!may_allow_falloc_discard(plo)) {
+		ret = -EINVAL;
+		goto unlock;
+	}
+
 	q = plo->queue;
 	if (val == q->limits.discard_granularity)
 		goto unlock;
@@ -397,6 +402,7 @@  static int store_discard_granularity(struct ploop_device *plo, u32 val)
 	}
 
 	if (val == cluster_size_in_bytes(plo)) {
+		clear_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state);
 		ploop_set_discard_limits(plo);
 		plo->force_split_discard_reqs = false;
 		goto unlock;
@@ -408,6 +414,7 @@  static int store_discard_granularity(struct ploop_device *plo, u32 val)
 		goto unlock;
 	}
 
+	clear_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state);
 	q->limits.discard_granularity = val;
 	/*
 	 * There is no a way to force block engine to split a request