[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANaxB-zai9dZF=LYtzexm2=9sDo=YbmBy7YyNShRLfLrMNzUaw@mail.gmail.com>
Date: Fri, 13 Mar 2015 00:31:17 +0300
From: Andrey Wagin <avagin@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andrew Vagin <avagin@...allels.com>,
LKML <linux-kernel@...r.kernel.org>,
linux-fsdevel@...r.kernel.org, linux-doc@...r.kernel.org,
Jonathan Corbet <corbet@....net>,
Alexander Viro <viro@...iv.linux.org.uk>,
Jeff Layton <jlayton@...chiereds.net>,
"J. Bruce Fields" <bfields@...ldses.org>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Pavel Emelyanov <xemul@...allels.com>,
Joe Perches <joe@...ches.com>
Subject: Re: [PATCH] proc: show locks in /proc/pid/fdinfo/X
2015-03-12 22:23 GMT+03:00 Andrew Morton <akpm@...ux-foundation.org>:
> On Thu, 12 Mar 2015 18:54:42 +0300 Andrew Vagin <avagin@...allels.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists