[Devel] [PATCH 3/4] ploop: allow to set discard granularity and alignment attributes

Andrei Vagin avagin at openvz.org
Thu Feb 15 04:36:06 MSK 2018


[This sender failed our fraud detection checks and may not be who they appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]

Different backing stores can have different values for these parameters.

Signed-off-by: Andrei Vagin <avagin at openvz.org>
---
 drivers/block/ploop/sysfs.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index acd18ff..835558a 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -362,6 +362,51 @@ static int store_aborted(struct ploop_device * plo, u32 val)
        return 0;
 }

+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;
+}
+
+static int store_discard_zeroes_data(struct ploop_device * plo, u32 val)
+{
+       plo->queue->limits.discard_zeroes_data = !!val;
+       return 0;
+}
+
 static u32 show_top(struct ploop_device * plo)
 {
        int top = -1;
@@ -550,6 +595,9 @@ static struct attribute *state_attributes[] = {
        _A(blockable_reqs),
        _A(blocked_bios),
        _A(freeze_state),
+       _A2(discard_granularity),
+       _A2(discard_alignment),
+       _A2(discard_zeroes_data),
        NULL
 };

--
1.8.3.1




More information about the Devel mailing list