ploop: Add native discard support parameter

Submitted by Kirill Tkhai on April 9, 2019, 4:22 p.m.

Details

Message ID 155482693862.13002.10069427131285308980.stgit@localhost.localdomain
State New
Series "ploop: Add native discard support parameter"
Headers show

Commit Message

Kirill Tkhai April 9, 2019, 4:22 p.m.
This adds a possibility to determ whether driver supports
native discard (without maintaince mode).

Currently, we show features in module parameters
and this was started since "large_disk_support".
The patch continues the way, but the parameter
is made RW to allow prohibit the feature on flight.

https://jira.sw.ru/browse/PSBM-93731

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

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 01f70c6abec9..815c74438dd6 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -59,6 +59,7 @@  static long root_threshold __read_mostly = 2L * 1024 * 1024; /* 2GB in KB */
 static long user_threshold __read_mostly = 4L * 1024 * 1024; /* 4GB in KB */
 
 static int large_disk_support __read_mostly = 1; /* true */
+static int native_discard_support __read_mostly = 1;
 
 static struct rb_root ploop_devices_tree = RB_ROOT;
 static DEFINE_MUTEX(ploop_devices_mutex);
@@ -2184,6 +2185,9 @@  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;
 
@@ -5637,6 +5641,8 @@  module_param(user_threshold, long, 0644);
 MODULE_PARM_DESC(user_threshold, "Disk space reserved for user (in kilobytes)");
 module_param(large_disk_support, int, 0444);
 MODULE_PARM_DESC(ploop_large_disk_support, "Support of large disks (>2TB)");
+module_param(native_discard_support, int, 0644);
+MODULE_PARM_DESC(native_discard_support, "Native discard support");
 
 static int __init ploop_mod_init(void)
 {