[v2,8/8] ploop: Show whether device supports native discard

Submitted by Kirill Tkhai on May 21, 2019, 11:37 a.m.

Details

Message ID 7691efa5-2cca-29c7-03a8-0a3608455f2d@virtuozzo.com
State New
Series "Revert "ploop: Disable ioctl(PLOOP_IOC_BALLOON)""
Headers show

Commit Message

Kirill Tkhai May 21, 2019, 11:37 a.m.
... or not support discard at all.

Shown in: /sys/block/ploopXXX/pstate/discard_mode

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

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index b2203d152c2c..705ad36b6e41 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -484,6 +484,17 @@  static u32 show_freeze_state(struct ploop_device * plo)
 	return plo->freeze_state;
 }
 
+static u32 show_discard_mode(struct ploop_device *plo)
+{
+	/*
+	 * 0 - discard disabled (not implemented)
+	 * 1 - maintaince mode-based discard
+	 * 2 - hole-based discard
+	 * 3 - move-tail-block discard (not implemented)
+	 */
+	return test_bit(PLOOP_S_NO_FALLOC_DISCARD, &plo->state) ? 1 : 2;
+}
+
 #define _TUNE_U32(_name)				\
 static u32 show_##_name(struct ploop_device * plo)	\
 {							\
@@ -571,6 +582,7 @@  static struct attribute *state_attributes[] = {
 	_A(blockable_reqs),
 	_A(blocked_bios),
 	_A(freeze_state),
+	_A(discard_mode),
 	NULL
 };