[Devel] [PATCH RHEL7 COMMIT] ploop: allow to set discard granularity and alignment attributes
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Feb 15 17:34:48 MSK 2018
The commit is pushed to "branch-rh7-3.10.0-693.17.1.vz7.43.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.17.1.vz7.43.5
------>
commit b1000c102485989296264158dd54572789101bdd
Author: Andrei Vagin <avagin at openvz.org>
Date: Thu Feb 15 17:34:47 2018 +0300
ploop: allow to set discard granularity and alignment attributes
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 acd18ff7a426..835558a29777 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
};
More information about the Devel
mailing list