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

Kirill Tkhai ktkhai at virtuozzo.com
Thu Sep 3 17:13:01 MSK 2020


Check whether delta stack configuration allows fallocate
based discard, and enable it if so when requested.

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

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




More information about the Devel mailing list