[RHEL7,COMMIT] ploop: Allow FUSE to avoid maintaince mode based discard

Submitted by Vasily Averin on Sept. 4, 2020, 7:31 a.m.

Details

Message ID 202009040731.0847VE7o025030@vz7build.vvs.sw.ru
State New
Series "ploop: Rework queue_settings autoconfig and allow fuse 4K discard"
Headers show

Commit Message

Vasily Averin Sept. 4, 2020, 7:31 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.16
------>
commit d7329e04617ddaaf9bbf270a617e697ebc388d40
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Sep 4 10:31:14 2020 +0300

    ploop: Allow FUSE to avoid maintaince mode based discard
    
    Check whether delta stack configuration allows fallocate
    based discard, and enable it if so when requested.
    
    https://jira.sw.ru/browse/PSBM-107598
    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 b6875ba..4cb5d9d 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