From: Jerome Marchand <jmarchan@redhat.com>
To: Pavel Emelyanov <xemul@parallels.com>
Cc: Matthew Wilcox <matthew@wil.cx>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] procfs: fix numbering in /proc/locks
Date: Wed, 29 Sep 2010 13:42:30 +0200 [thread overview]
Message-ID: <4CA32626.8040700@redhat.com> (raw)
In-Reply-To: <4CA0B743.2050801@parallels.com>
On 09/27/2010 05:24 PM, Pavel Emelyanov wrote:
> On 09/27/2010 07:13 PM, Jerome Marchand wrote:
>>
>> The lock number in /proc/locks (first field) is implemented by a counter
>> (private field of struct seq_file) which is incremented at each call of
>> locks_show(). Currently it is reset each time locks_start() is called,
>> that is each time we call the read() syscall on /proc/locks. Because of
>> that, the numbering erratically restarts at 1 several times when reading
>> a long /proc/locks file.
>> We want the counter to be initialized at opening time and then never
>> reset until we close the file. Fortunately, seq_open() memzeros the
>> seq_file structure, so we can just drop the reset in locks_start() and
>> move the increment the counter before actually printing the line so the
>> numbering still starts at 1.
>
> IMHO the implementation is wrong. If you want the proper sequence number
> while file is open you should increase on in the ->next callback of the
> seq_ops, not in show.
Good point. My implementation is definitely wrong. But I'm afraid that
moving the increment in locks_next() won't help either. It will fail when
a program do something more than just read the file sequentially (use
of lseek() for instance). We need a better way to keep track of the
current position in the list.
Thanks,
Jerome
next prev parent reply other threads:[~2010-09-29 11:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-27 15:13 [PATCH] procfs: fix numbering in /proc/locks Jerome Marchand
2010-09-27 15:24 ` Pavel Emelyanov
2010-09-29 11:42 ` Jerome Marchand [this message]
2010-09-29 11:43 ` Pavel Emelyanov
2010-09-29 11:52 ` Jerome Marchand
2010-09-29 11:56 ` Pavel Emelyanov
2010-09-29 12:00 ` Jerome Marchand
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=4CA32626.8040700@redhat.com \
--to=jmarchan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--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