From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Fengguang Wu <wfg@mail.ustc.edu.cn>
Cc: Al Viro <viro@ftp.linux.org.uk>,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
Randy Dunlap <rddunlap@osdl.org>,
Martin Bligh <mbligh@google.com>
Subject: Re: [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators
Date: Sat, 18 Aug 2007 11:56:09 -0400 [thread overview]
Message-ID: <20070818155609.GA20219@Krystal> (raw)
In-Reply-To: <20070815084625.GA18892@mail.ustc.edu.cn>
* Fengguang Wu (wfg@mail.ustc.edu.cn) wrote:
> Al Viro,
>
> Does this sounds like a good fix?
> ===
>
> seq_file version fixes
>
> - f_version is 'unsigned long', it's pointless to do more than that.
Hrm, this is weird...
fs.h:
struct inode
u64 i_version;
and
struct file
unsigned long f_version;
Users do:
fs/ext3/dir.c:
if (filp->f_version != inode->i_version) {
So why isn't f_version a u64 ? It becomes a problem if versions gets
higher than 2^32 and we are on an architecture where longs are 32 bits.
I think the problem is the f_version field type, not in seq_file at all.
I'll prepare a patch for this.
> - m->version should not be reset when we are bumping up the buf size.
>
Hrmmmm, what is this twisted use of versions anyway ?!?
If I look at other version users elsewhere in the kernel, they mostly
do:
repeat:
f_version = i_version
do something
if (f_version != i_version)
repeat;
So they can see if the underlying inode has changed during the
operation. seq_file does it completely the other way around:
m->version = f_version;
do something
and, well, versions are never really used at all.
If we want to use versioning there, we should keep a version counter
associated with the ressource pointed used by seq_files that would be
incremented each time the data structures are modified.
Then, in the read side, we could sanely do:
seq open():
f_version = current version
seq read():
repeat:
m->version = f_version;
do something
if (m->version != current version)
repeat;
This would only make sure that the given read operation has consistent
data. It would not certify data consistency across reads.
I have looked at fs/proc.c/task_mmu.c use of m->version, and I think it
is just really weird. I think the proper way to do it would be to put
the last_addr in a field of a structure to which m->private would point
to.
Mathieu
> Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
> ---
> fs/seq_file.c | 1 -
> include/linux/seq_file.h | 2 +-
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> --- linux-2.6.23-rc3.orig/include/linux/seq_file.h
> +++ linux-2.6.23-rc3/include/linux/seq_file.h
> @@ -18,7 +18,7 @@ struct seq_file {
> size_t from;
> size_t count;
> loff_t index;
> - loff_t version;
> + unsigned long version;
> struct mutex lock;
> const struct seq_operations *op;
> void *private;
> --- linux-2.6.23-rc3.orig/fs/seq_file.c
> +++ linux-2.6.23-rc3/fs/seq_file.c
> @@ -134,7 +134,6 @@ ssize_t seq_read(struct file *file, char
> if (!m->buf)
> goto Enomem;
> m->count = 0;
> - m->version = 0;
> }
> m->op->stop(m, p);
> m->count = 0;
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2007-08-18 15:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-12 15:08 [patch 0/2] Sorted seq_file Mathieu Desnoyers
2007-08-12 15:08 ` [patch 1/2] Seq_file add support for sorted list Mathieu Desnoyers
2007-08-12 15:08 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
[not found] ` <20070815033945.GA13134@mail.ustc.edu.cn>
2007-08-15 3:39 ` Fengguang Wu
2007-08-15 4:18 ` Al Viro
[not found] ` <20070815063741.GB5175@mail.ustc.edu.cn>
2007-08-15 6:37 ` Fengguang Wu
2007-08-15 6:53 ` Al Viro
[not found] ` <20070815083645.GA6544@mail.ustc.edu.cn>
2007-08-15 8:36 ` Fengguang Wu
[not found] ` <20070815084625.GA18892@mail.ustc.edu.cn>
2007-08-15 8:46 ` Fengguang Wu
2007-08-18 15:56 ` Mathieu Desnoyers [this message]
2007-08-18 16:09 ` [PATCH] Fix f_version type: should be u64 instead of unsigned long Mathieu Desnoyers
2007-08-24 15:39 ` [PATCH] Sort module list - use ppos instead of m->private Mathieu Desnoyers
2007-08-24 23:34 ` Andrew Morton
2007-08-25 0:05 ` Mathieu Desnoyers
-- strict thread matches above, loose matches on Subject: below --
2007-08-20 20:26 [patch 0/2] Sort module list Mathieu Desnoyers
2007-08-20 20:26 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
2007-08-21 0:08 ` Rusty Russell
2007-08-24 15:45 ` Mathieu Desnoyers
2007-08-25 21:44 ` Rusty Russell
2007-08-25 21:53 ` Mathieu Desnoyers
2007-08-27 16:02 [patch 0/2] Sort module list for /proc/modules seq file reads Mathieu Desnoyers
2007-08-27 16:02 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
2007-09-06 20:05 [patch 0/2] Sort module list for /proc/modules Mathieu Desnoyers
2007-09-06 20:05 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
2007-09-17 18:43 [patch 0/2] Sort module list Mathieu Desnoyers
2007-09-17 18:43 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
2007-09-18 21:09 [patch 0/2] Sorted Module List for 2.6.23-rc6-mm1 Mathieu Desnoyers
2007-09-18 21:09 ` [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators Mathieu Desnoyers
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=20070818155609.GA20219@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbligh@google.com \
--cc=rddunlap@osdl.org \
--cc=viro@ftp.linux.org.uk \
--cc=wfg@mail.ustc.edu.cn \
/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