Commit 9aefc010 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] `event' removal: ext2

Patch from Manfred Spraul

Use a local counter instead of the global 'event' variable for the
readdir() optimization.

Depends on patch-event-II

Background:
  The only user of i_version and f_version in ext2 is
  ext2_readdir(). As an optimization, ext2 performs the
  validation of the start position for readdir() only if
        flip->f_version != inode->i_version.
  If there was no llseek and no directory change since the
  last readdir() call, then f_pos can be trusted.
  f_version is set to 0 in get_empty_flip and during llseek.
  Right now, i_version set to ++event during ext2_read_inode
  and commit_chunk, i.e. at inode creation and if a directory
  is changed.
  Initializing i_version to 1, and updating with i_version++
  achieves the same effect, without the need of a global variable.
  Global uniqueness is not required, there are no other uses
  of [if]_version in ext2.

Change relative to the patch you have right now:
i_version is initialized to 1 instead of 0. For ext2 it's doesn't
matter [there is always a valid 'len' value at the beginning of a
directory data block], but it's cleaner.
parent 4ccf7a32
......@@ -66,7 +66,7 @@ static int ext2_commit_chunk(struct page *page, unsigned from, unsigned to)
{
struct inode *dir = page->mapping->host;
int err = 0;
dir->i_version = ++event;
dir->i_version++;
page->mapping->a_ops->commit_write(NULL, page, from, to);
if (IS_DIRSYNC(dir))
err = write_one_page(page, 1);
......
......@@ -1015,7 +1015,6 @@ void ext2_read_inode (struct inode * inode)
}
inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */
inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
inode->i_version = ++event;
ei->i_flags = le32_to_cpu(raw_inode->i_flags);
ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
ei->i_frag_no = raw_inode->i_frag;
......
......@@ -160,6 +160,7 @@ static struct inode *ext2_alloc_inode(struct super_block *sb)
ei->i_acl = EXT2_ACL_NOT_CACHED;
ei->i_default_acl = EXT2_ACL_NOT_CACHED;
#endif
ei->vfs_inode.i_version = 1;
return &ei->vfs_inode;
}
......
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