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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Feb 16 11:11:54 MSK 2018


On 02/15/2018 04:36 AM, Andrei Vagin wrote:
>
> 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
>  };

BTW, why these new parameters are state_attributes (others are readonly, except for "aborted"),
but not tune_attributes like other rw parameters?


More information about the Devel mailing list