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

Andrei Vagin avagin at virtuozzo.com
Wed Feb 28 01:31:25 MSK 2018


On Fri, Feb 16, 2018 at 11:11:54AM +0300, Konstantin Khorenko wrote:
> 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?

It was done by mistake. I have sent a fix. Thank you!


More information about the Devel mailing list