Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476480

Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs
Date 2016-09-05 16:20 +0200
Message-ID <se2UF-4Qu-3@gated-at.bofh.it> (permalink)
References <rMVnP-76s-3@gated-at.bofh.it> <se28j-4is-59@gated-at.bofh.it> <se2rE-4pk-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Sep 05, 2016 at 03:46:28PM +0200, Greg Kroah-Hartman wrote:
> On Mon, Sep 05, 2016 at 04:25:48PM +0300, Konstantin Khlebnikov wrote:
> > Bump
> 
> Huh?
> 
> > On Wed, Jun 22, 2016 at 9:42 PM, Konstantin Khlebnikov
> > <khlebnikov@yandex-team.ru> wrote:
> > > Attributes declared with __ATTR_PREALLOC use sysfs_kf_read() which returns
> > > zero bytes for non-zero offset. This breaks script checkarray in mdadm tool
> > > in debian where /bin/sh is 'dash' because its builtin 'read' reads only one
> > > byte at a time. Script gets 'i' instead of 'idle' when reads current action
> > > from /sys/block/$dev/md/sync_action and as a result does nothing.
> > >
> > > This patch adds trivial implementation of partial read: generate whole
> > > string and move required part into buffer head.
> > >
> > > Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> > > Fixes: 4ef67a8c95f3 ("sysfs/kernfs: make read requests on pre-alloc files use the buffer.")
> > > Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787950
> > > Cc: Stable <stable@vger.kernel.org> # v3.19+
> > > ---
> > >  fs/sysfs/file.c |    8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
> > > index f35523d4fa3a..b803213d1307 100644
> > > --- a/fs/sysfs/file.c
> > > +++ b/fs/sysfs/file.c
> > > @@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,
> > >          * If buf != of->prealloc_buf, we don't know how
> > >          * large it is, so cannot safely pass it to ->show
> > >          */
> > > -       if (pos || WARN_ON_ONCE(buf != of->prealloc_buf))
> > > +       if (WARN_ON_ONCE(buf != of->prealloc_buf))
> > >                 return 0;
> > >         len = ops->show(kobj, of->kn->priv, buf);
> > > +       if (pos) {
> > > +               if (len <= pos)
> > > +                       return 0;
> > > +               len -= pos;
> > > +               memmove(buf, buf + pos, len);
> > > +       }
> > >         return min(count, len);
> > >  }
> 
> I don't have this in any queue of mine, so I don't understand what you
> are asking about.
> 
> totally confused,

Wait, this is already in Linus's tree, what are you asking for here?

still confused,

greg k-h

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Konstantin Khlebnikov <koct9i@gmail.com> - 2016-09-05 15:30 +0200
  Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-05 15:50 +0200
    Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2016-09-05 16:10 +0200
      Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-05 16:20 +0200
    Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-05 16:20 +0200
      Re: [PATCH] sysfs: correctly handle read offset on PREALLOC attrs Konstantin Khlebnikov <koct9i@gmail.com> - 2016-09-05 16:20 +0200

csiph-web