Commit 9448b90c authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] `event' removal: other filesystems

Patch from Manfred Spraul

Several filesystems compare f_version and i_version to validate
directory positions in readdir(): The directory position is revalidated
if i_version is not equal f_version.  Operations that could invalidate
the cached position set i_version or f_version to '++event', event is a
global variable.  Global uniqueness is not needed, 'i_version++' and
'f_version=0' is sufficient to guarantee that the next readdir() will
revalidate the directory position, and that avoids the need for an ugly
global variable.

The attached patch converts all filesystems except ext2, which was
converted with a seperate patch.
parent 9aefc010
...@@ -69,7 +69,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh) ...@@ -69,7 +69,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
affs_brelse(dir_bh); affs_brelse(dir_bh);
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
dir->i_version = ++event; dir->i_version++;
mark_inode_dirty(dir); mark_inode_dirty(dir);
return 0; return 0;
...@@ -121,7 +121,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh) ...@@ -121,7 +121,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)
affs_brelse(bh); affs_brelse(bh);
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
dir->i_version = ++event; dir->i_version++;
mark_inode_dirty(dir); mark_inode_dirty(dir);
return retval; return retval;
......
...@@ -92,6 +92,7 @@ static struct inode *affs_alloc_inode(struct super_block *sb) ...@@ -92,6 +92,7 @@ static struct inode *affs_alloc_inode(struct super_block *sb)
ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL); ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -2248,7 +2248,6 @@ void ext3_read_inode(struct inode * inode) ...@@ -2248,7 +2248,6 @@ void ext3_read_inode(struct inode * inode)
* (for stat), not the fs block * (for stat), not the fs block
* size */ * size */
inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); 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_flags = le32_to_cpu(raw_inode->i_flags);
#ifdef EXT3_FRAGMENTS #ifdef EXT3_FRAGMENTS
ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
......
...@@ -1201,7 +1201,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, ...@@ -1201,7 +1201,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
*/ */
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
ext3_update_dx_flag(dir); ext3_update_dx_flag(dir);
dir->i_version = ++event; dir->i_version++;
ext3_mark_inode_dirty(handle, dir); ext3_mark_inode_dirty(handle, dir);
BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
err = ext3_journal_dirty_metadata(handle, bh); err = ext3_journal_dirty_metadata(handle, bh);
...@@ -1520,7 +1520,7 @@ static int ext3_delete_entry (handle_t *handle, ...@@ -1520,7 +1520,7 @@ static int ext3_delete_entry (handle_t *handle,
le16_to_cpu(de->rec_len)); le16_to_cpu(de->rec_len));
else else
de->inode = 0; de->inode = 0;
dir->i_version = ++event; dir->i_version++;
BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
ext3_journal_dirty_metadata(handle, bh); ext3_journal_dirty_metadata(handle, bh);
return 0; return 0;
...@@ -1964,7 +1964,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) ...@@ -1964,7 +1964,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry)
ext3_warning (inode->i_sb, "ext3_rmdir", ext3_warning (inode->i_sb, "ext3_rmdir",
"empty directory has nlink!=2 (%d)", "empty directory has nlink!=2 (%d)",
inode->i_nlink); inode->i_nlink);
inode->i_version = ++event; inode->i_version++;
inode->i_nlink = 0; inode->i_nlink = 0;
/* There's no need to set i_disksize: the fact that i_nlink is /* There's no need to set i_disksize: the fact that i_nlink is
* zero will ensure that the right thing happens during any * zero will ensure that the right thing happens during any
...@@ -2214,7 +2214,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, ...@@ -2214,7 +2214,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
if (EXT3_HAS_INCOMPAT_FEATURE(new_dir->i_sb, if (EXT3_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
EXT3_FEATURE_INCOMPAT_FILETYPE)) EXT3_FEATURE_INCOMPAT_FILETYPE))
new_de->file_type = old_de->file_type; new_de->file_type = old_de->file_type;
new_dir->i_version = ++event; new_dir->i_version++;
BUFFER_TRACE(new_bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(new_bh, "call ext3_journal_dirty_metadata");
ext3_journal_dirty_metadata(handle, new_bh); ext3_journal_dirty_metadata(handle, new_bh);
brelse(new_bh); brelse(new_bh);
......
...@@ -434,6 +434,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb) ...@@ -434,6 +434,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
ei->i_acl = EXT3_ACL_NOT_CACHED; ei->i_acl = EXT3_ACL_NOT_CACHED;
ei->i_default_acl = EXT3_ACL_NOT_CACHED; ei->i_default_acl = EXT3_ACL_NOT_CACHED;
#endif #endif
ei->vfs_inode.i_version = 0;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -403,7 +403,7 @@ int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen, ...@@ -403,7 +403,7 @@ int hpfs_add_dirent(struct inode *i, unsigned char *name, unsigned namelen,
c = 1; c = 1;
goto ret; goto ret;
} }
i->i_version = ++event; i->i_version++;
c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0);
ret: ret:
if (!cdepth) hpfs_unlock_creation(i->i_sb); if (!cdepth) hpfs_unlock_creation(i->i_sb);
...@@ -710,7 +710,7 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, ...@@ -710,7 +710,7 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de,
return 2; return 2;
} }
} }
i->i_version = ++event; i->i_version++;
for_all_poss(i, hpfs_pos_del, (t = get_pos(dnode, de)) + 1, 1); for_all_poss(i, hpfs_pos_del, (t = get_pos(dnode, de)) + 1, 1);
hpfs_delete_de(i->i_sb, dnode, de); hpfs_delete_de(i->i_sb, dnode, de);
hpfs_mark_4buffers_dirty(qbh); hpfs_mark_4buffers_dirty(qbh);
......
...@@ -84,7 +84,6 @@ void hpfs_read_inode(struct inode *i) ...@@ -84,7 +84,6 @@ void hpfs_read_inode(struct inode *i)
hpfs_inode->i_ea_uid = 0; hpfs_inode->i_ea_uid = 0;
hpfs_inode->i_ea_gid = 0; hpfs_inode->i_ea_gid = 0;
hpfs_inode->i_ea_size = 0; hpfs_inode->i_ea_size = 0;
i->i_version = ++event;
hpfs_inode->i_rddir_off = NULL; hpfs_inode->i_rddir_off = NULL;
hpfs_inode->i_dirty = 0; hpfs_inode->i_dirty = 0;
......
...@@ -166,6 +166,7 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb) ...@@ -166,6 +166,7 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb)
ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_KERNEL); ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -495,7 +495,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -495,7 +495,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
* This is for checking whether an inode has changed w.r.t. a file so * This is for checking whether an inode has changed w.r.t. a file so
* that the file can be updated if necessary (compare with f_version). * that the file can be updated if necessary (compare with f_version).
*/ */
vi->i_version = ++event; vi->i_version = 0;
vi->i_uid = vol->uid; vi->i_uid = vol->uid;
vi->i_gid = vol->gid; vi->i_gid = vol->gid;
......
...@@ -353,7 +353,7 @@ ino_t ufs_inode_by_name(struct inode * dir, struct dentry *dentry) ...@@ -353,7 +353,7 @@ ino_t ufs_inode_by_name(struct inode * dir, struct dentry *dentry)
void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
struct buffer_head *bh, struct inode *inode) struct buffer_head *bh, struct inode *inode)
{ {
dir->i_version = ++event; dir->i_version++;
de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (IS_DIRSYNC(dir)) { if (IS_DIRSYNC(dir)) {
...@@ -463,7 +463,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -463,7 +463,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
} }
brelse (bh); brelse (bh);
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
dir->i_version = ++event; dir->i_version++;
mark_inode_dirty(dir); mark_inode_dirty(dir);
UFSD(("EXIT\n")) UFSD(("EXIT\n"))
...@@ -504,7 +504,7 @@ int ufs_delete_entry (struct inode * inode, struct ufs_dir_entry * dir, ...@@ -504,7 +504,7 @@ int ufs_delete_entry (struct inode * inode, struct ufs_dir_entry * dir,
fs16_add(sb, &pde->d_reclen, fs16_add(sb, &pde->d_reclen,
fs16_to_cpu(sb, dir->d_reclen)); fs16_to_cpu(sb, dir->d_reclen));
dir->d_ino = 0; dir->d_ino = 0;
inode->i_version = ++event; inode->i_version++;
inode->i_ctime = inode->i_mtime = CURRENT_TIME; inode->i_ctime = inode->i_mtime = CURRENT_TIME;
mark_inode_dirty(inode); mark_inode_dirty(inode);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
......
...@@ -519,7 +519,7 @@ void ufs_read_inode (struct inode * inode) ...@@ -519,7 +519,7 @@ void ufs_read_inode (struct inode * inode)
inode->i_mtime = fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec); inode->i_mtime = fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec);
inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat) */ inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat) */
inode->i_version = ++event; inode->i_version++;
ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen); ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen);
ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
......
...@@ -1006,6 +1006,7 @@ static struct inode *ufs_alloc_inode(struct super_block *sb) ...@@ -1006,6 +1006,7 @@ static struct inode *ufs_alloc_inode(struct super_block *sb)
ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL); ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL);
if (!ei) if (!ei)
return NULL; return NULL;
ei->vfs_inode.i_version = 0;
return &ei->vfs_inode; 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