From: Jerome Marchand <jmarchan@redhat.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Pavel Emelianov <xemul@openvz.org>
Subject: [PATCH] procfs: fix numbering in /proc/locks
Date: Mon, 27 Sep 2010 17:13:41 +0200 [thread overview]
Message-ID: <4CA0B4A5.1090701@redhat.com> (raw)
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.
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
diff --git a/fs/locks.c b/fs/locks.c
index ab24d49..a5eab5e 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2161,19 +2161,18 @@ static int locks_show(struct seq_file *f, void *v)
fl = list_entry(v, struct file_lock, fl_link);
+ f->private++;
lock_get_status(f, fl, (long)f->private, "");
list_for_each_entry(bfl, &fl->fl_block, fl_block)
lock_get_status(f, bfl, (long)f->private, " ->");
- f->private++;
return 0;
}
static void *locks_start(struct seq_file *f, loff_t *pos)
{
lock_kernel();
- f->private = (void *)1;
return seq_list_start(&file_lock_list, *pos);
}
next reply other threads:[~2010-09-27 15:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-27 15:13 Jerome Marchand [this message]
2010-09-27 15:24 ` [PATCH] procfs: fix numbering in /proc/locks Pavel Emelyanov
2010-09-29 11:42 ` Jerome Marchand
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=4CA0B4A5.1090701@redhat.com \
--to=jmarchan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=xemul@openvz.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.