[Devel] [PATCH] ploop: Prohibit custom discard alignment and granuality

Kirill Tkhai ktkhai at virtuozzo.com
Thu Mar 14 14:31:21 MSK 2019


We can zero ploop1 fmt index only in case of full block
discarding is requested. Correct limits are already set
in ploop_set_discard_limits(), so this patch prohibits
custom ones.

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

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index 11326613d75c..b2203d152c2c 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -367,35 +367,11 @@ static u32 show_discard_granularity(struct ploop_device * plo)
 	return plo->queue->limits.discard_granularity;
 }
 
-static int store_discard_granularity(struct ploop_device * plo, u32 val)
-{
-	int q = ilog2(val);
-
-	/* look at kaio_fill_zero_submit */
-	if (1 << q != val || val > PAGE_SIZE || val < 512)
-		return -EINVAL;
-
-	plo->queue->limits.discard_granularity = val;
-	return 0;
-}
-
 static u32 show_discard_alignment(struct ploop_device * plo)
 {
 	return plo->queue->limits.discard_alignment;
 }
 
-static int store_discard_alignment(struct ploop_device * plo, u32 val)
-{
-	int q = ilog2(val);
-
-	/* look at kaio_fill_zero_submit */
-	if (1 << q != val || val > PAGE_SIZE || val < 512)
-		return -EINVAL;
-
-	plo->queue->limits.discard_alignment = val;
-	return 0;
-}
-
 static u32 show_discard_zeroes_data(struct ploop_device * plo)
 {
 	return plo->queue->limits.discard_zeroes_data;
@@ -616,8 +592,8 @@ static struct attribute *tune_attributes[] = {
 	_A2(congestion_low_watermark),
 	_A2(max_active_requests),
 	_A2(push_backup_timeout),
-	_A2(discard_granularity),
-	_A2(discard_alignment),
+	_A(discard_granularity),
+	_A(discard_alignment),
 	_A2(discard_zeroes_data),
 	NULL
 };



More information about the Devel mailing list