Commit 4ccf7a32 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] `event' removal: core kernel

Patch from Manfred Spraul

f_version and i_version are used by filesystems to check if it can
reuse the f_pos position across readdir calls without validation.

Right now f_version and i_version are modified by
    f_version = ++event;
    i_version = ++event;
    if (f_version != i_version) goto revalidate
and event is a global, exported variable.

But that's not needed,
    f_version  = 0;
    i_version++;
    if (f_version != i_version) goto revalidate
works too, without the ugly 'event' variable.

I got an ok from viro, and I had notified the fs maintainers, no
complaints either

- block_dev.c, block_llseek updates f_version to '++event'.
   grep showed that no device driver uses f_version, this is dead
   code copied from the default llseek implementation.

- the llseek implementations and get_empty_flip set f_version
   to '++event'
   This is not dead code, but
            filp->f_version = 0
   achieves the same effect:
   f_version is used by the readdir() implementation of several
   filesystems to skip the revalidation of f_pos at the beginning
   of a readdir call: If llseek was not called and the filesystem
   did not change since the last readdir call, then the value in
   f_pos can be trusted.
   The implementation (for example in ext2) is
     inode->i_version = ++event;
   in all operations that change a directory
   At the beginning of file_operation->readdir():
     if(inode->i_version != flip->f_version)
                revalidate();
     filp->f_version = inode->i_version;
   There are other users of f_version, but none of them use the
   default llseek implementation (e.g. fs/pipe.c)
parent db01fdce
......@@ -168,7 +168,6 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
if (offset >= 0 && offset <= size) {
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = ++event;
}
retval = offset;
}
......
......@@ -54,7 +54,7 @@ struct file * get_empty_filp(void)
return NULL;
}
atomic_set(&f->f_count,1);
f->f_version = ++event;
f->f_version = 0;
f->f_uid = current->fsuid;
f->f_gid = current->fsgid;
f->f_owner.lock = RW_LOCK_UNLOCKED;
......
......@@ -40,7 +40,7 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
if (offset>=0 && offset<=inode->i_sb->s_maxbytes) {
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = ++event;
file->f_version = 0;
}
retval = offset;
}
......@@ -64,7 +64,7 @@ loff_t remote_llseek(struct file *file, loff_t offset, int origin)
if (offset>=0 && offset<=file->f_dentry->d_inode->i_sb->s_maxbytes) {
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = ++event;
file->f_version = 0;
}
retval = offset;
}
......@@ -93,7 +93,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
if (offset >= 0) {
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = ++event;
file->f_version = 0;
}
retval = offset;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment