From: Andrey Wagin <avagin@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Vagin <avagin@parallels.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
Jonathan Corbet <corbet@lwn.net>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@poochiereds.net>,
"J. Bruce Fields" <bfields@fieldses.org>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Pavel Emelyanov <xemul@parallels.com>,
Joe Perches <joe@perches.com>
Subject: Re: [PATCH] proc: show locks in /proc/pid/fdinfo/X
Date: Fri, 13 Mar 2015 00:31:17 +0300 [thread overview]
Message-ID: <CANaxB-zai9dZF=LYtzexm2=9sDo=YbmBy7YyNShRLfLrMNzUaw@mail.gmail.com> (raw)
In-Reply-To: <20150312122331.d8c27baf40d56e764f223193@linux-foundation.org>
2015-03-12 22:23 GMT+03:00 Andrew Morton <akpm@linux-foundation.org>:
> On Thu, 12 Mar 2015 18:54:42 +0300 Andrew Vagin <avagin@parallels.com> wrote:
>
>> v2: use seq_has_overflowed() properly
>
> --- a/fs/proc/fd.c~proc-show-locks-in-proc-pid-fdinfo-x-v2
> +++ a/fs/proc/fd.c
> @@ -57,17 +57,15 @@ static int seq_show(struct seq_file *m,
> real_mount(file->f_path.mnt)->mnt_id);
>
> show_fd_locks(m, file, files);
> - ret = seq_has_overflowed(m);
> - if (ret)
> + if (seq_has_overflowed(m))
> goto out;
>
> if (file->f_op->show_fdinfo)
> file->f_op->show_fdinfo(m, file);
> - ret = seq_has_overflowed(m);
>
> out:
> fput(file);
> - return ret;
> + return 0;
> }
>
> static int seq_fdinfo_open(struct inode *inode, struct file *file)
>
>
> So it returns "success" when the output has overflowed? Why this,
> rather than returning an error?
I have read fs/seq_file.c and looks like it's the right way.
seq_has_overflowed() is used to avoid useless work. If we call it or
don't call it, the result must be the same in both cases. So from this
point of view it looks logically correct too.
There are two interesting places from seq_file.c
error = m->op->show(m, p);
if (error < 0)
break;
if (unlikely(error)) {
error = 0;
m->count = 0;
}
if (seq_has_overflowed(m))
goto Eoverflow;
...
err = m->op->show(m, p);
if (err < 0)
break;
if (unlikely(err))
m->count = 0;
if (unlikely(!m->count)) {
p = m->op->next(m, p, &pos);
m->index = pos;
continue;
}
if (m->count < m->size)
goto Fill;
m->op->stop(m, p);
kvfree(m->buf);
m->count = 0;
m->buf = seq_buf_alloc(m->size <<= 1);
Thanks,
Andrey
prev parent reply other threads:[~2015-03-12 21:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 15:37 [PATCH] proc: show locks in /proc/pid/fdinfo/X Andrey Vagin
2015-03-05 19:11 ` Jeff Layton
2015-03-06 14:19 ` Andrew Vagin
2015-03-06 8:38 ` Cyrill Gorcunov
2015-03-06 14:41 ` J. Bruce Fields
2015-03-07 13:00 ` Jeff Layton
2015-03-11 22:08 ` Andrew Morton
2015-03-12 15:54 ` Andrew Vagin
2015-03-12 19:23 ` Andrew Morton
2015-03-12 21:31 ` Andrey Wagin [this message]
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='CANaxB-zai9dZF=LYtzexm2=9sDo=YbmBy7YyNShRLfLrMNzUaw@mail.gmail.com' \
--to=avagin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@parallels.com \
--cc=bfields@fieldses.org \
--cc=corbet@lwn.net \
--cc=gorcunov@openvz.org \
--cc=jlayton@poochiereds.net \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.com \
/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).