linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	dan.j.williams@intel.com, Al Viro <viro@zeniv.linux.org.uk>,
	aleksey.obitotskiy@intel.com, pawel.baldysiak@intel.com,
	artur.paszkiewicz@intel.com, maksymilian.kunt@intel.com
Subject: Re: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator
Date: Wed, 26 Oct 2016 11:17:13 +0200	[thread overview]
Message-ID: <CAELBmZAFPHu-SaMTJq0wH-2_OxUPVwfpRSxdMFW93po1SybRXA@mail.gmail.com> (raw)
In-Reply-To: <1476274060-1785-1-git-send-email-tomasz.majchrzak@intel.com>

On Wed, Oct 12, 2016 at 2:07 PM, Tomasz Majchrzak
<tomasz.majchrzak@intel.com> wrote:
> If kernfs file is empty on a first read, successive read operations
> using the same file descriptor will return no data, even when data is
> available. Default kernfs 'seq_next' implementation advances iterator
> position even when next object is not there. Kernfs 'seq_start' for
> following requests will not return iterator as position is already on
> the second object.
>
> This bug doesn't allow to monitor badblocks sysfs files from MD raid.
> They are initially empty but if data appears at some stage, userspace is
> not able to read it. It doesn't affect any released applications but it
> is necessary for upcoming bad block support for external metadata in MD
> raid.

What is the expectation from the userspace application?  Should
seq_file support "tail -f" as more data is added to the file?  AFAICS
this patch doesn't address that generally, just the empty->nonempty
transition (with the single record case).

Why does userspace app not do open+read+close each time it polls the
badblocks file?

Thanks,
Miklos







>
> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  fs/seq_file.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index 6dc4296..74197f4 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -235,7 +235,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
>         p = m->op->start(m, &pos);
>         while (1) {
>                 err = PTR_ERR(p);
> -               if (!p || IS_ERR(p))
> +               if (IS_ERR_OR_NULL(p))
>                         break;
>                 err = m->op->show(m, p);
>                 if (err < 0)
> @@ -244,7 +244,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
>                         m->count = 0;
>                 if (unlikely(!m->count)) {
>                         p = m->op->next(m, p, &pos);
> -                       m->index = pos;
> +                       if (!IS_ERR_OR_NULL(p))
> +                               m->index = pos;
>                         continue;
>                 }
>                 if (m->count < m->size)
> --
> 1.8.3.1
>

  reply	other threads:[~2016-10-26  9:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 12:07 [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator Tomasz Majchrzak
2016-10-26  9:17 ` Miklos Szeredi [this message]
2016-10-31  9:32   ` Tomasz Majchrzak
2016-11-02  9:11     ` Miklos Szeredi
2016-11-24 15:23       ` Tomasz Majchrzak
2016-11-24 15:39         ` Miklos Szeredi
2016-11-28 15:11           ` [PATCH v3] seq_file: reset iterator to first record for zero offset Tomasz Majchrzak
2016-11-29  9:58             ` Miklos Szeredi
2016-11-29 14:18               ` [PATCH v4] " Tomasz Majchrzak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAELBmZAFPHu-SaMTJq0wH-2_OxUPVwfpRSxdMFW93po1SybRXA@mail.gmail.com \
    --to=miklos@szeredi.hu \
    --cc=aleksey.obitotskiy@intel.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maksymilian.kunt@intel.com \
    --cc=pawel.baldysiak@intel.com \
    --cc=tomasz.majchrzak@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).