[RFC] [patch 1/3] i_version update for ext4: VFS layer This part of the patch concerns the update of the i_version in the VFS layer. Signed-off-by: Jean Noel Cordenner --- fs/attr.c | 1 + fs/bad_inode.c | 1 + fs/binfmt_misc.c | 1 + fs/inode.c | 16 ++++------------ fs/libfs.c | 9 +++++++++ fs/pipe.c | 1 + 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 97de946..f7964a1 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -113,6 +113,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr) now = current_fs_time(inode->i_sb); attr->ia_ctime = now; + inode->i_version++; if (!(ia_valid & ATTR_ATIME_SET)) attr->ia_atime = now; if (!(ia_valid & ATTR_MTIME_SET)) diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 869f519..ab2f1e3 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c @@ -343,6 +343,7 @@ void make_bad_inode(struct inode *inode) inode->i_mode = S_IFREG; inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); + inode->i_version++; inode->i_op = &bad_inode_ops; inode->i_fop = &bad_file_ops; } diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index c2e0825..9165c7a 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -508,6 +508,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode) inode->i_blocks = 0; inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); + inode->i_version = 1; } return inode; } diff --git a/fs/inode.c b/fs/inode.c index bf21dc6..85850d0 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1217,7 +1217,6 @@ void file_update_time(struct file *file) { struct inode *inode = file->f_path.dentry->d_inode; struct timespec now; - int sync_it = 0; if (IS_NOCMTIME(inode)) return; @@ -1225,18 +1224,11 @@ void file_update_time(struct file *file) return; now = current_fs_time(inode->i_sb); - if (!timespec_equal(&inode->i_mtime, &now)) { - inode->i_mtime = now; - sync_it = 1; - } - - if (!timespec_equal(&inode->i_ctime, &now)) { - inode->i_ctime = now; - sync_it = 1; - } + inode->i_mtime = now; + inode->i_ctime = now; + inode->i_version++; - if (sync_it) - mark_inode_dirty_sync(inode); + mark_inode_dirty_sync(inode); } EXPORT_SYMBOL(file_update_time); diff --git a/fs/libfs.c b/fs/libfs.c index 503898d..b298538 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -220,6 +220,7 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name, root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR; root->i_uid = root->i_gid = 0; root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME; + root->i_version = 1; dentry = d_alloc(NULL, &d_name); if (!dentry) { iput(root); @@ -243,6 +244,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den struct inode *inode = old_dentry->d_inode; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; + inode->i_version++; + dir->i_version++; inc_nlink(inode); atomic_inc(&inode->i_count); dget(dentry); @@ -275,6 +278,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry) struct inode *inode = dentry->d_inode; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; + inode->i_version++; + dir->i_version++; drop_nlink(inode); dput(dentry); return 0; @@ -312,6 +317,8 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry, old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime = inode->i_ctime = CURRENT_TIME; + old_dir->i_version++; + new_dir->i_version++; return 0; } @@ -377,6 +384,7 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files inode->i_uid = inode->i_gid = 0; inode->i_blocks = 0; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_version = 1; inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; inode->i_nlink = 2; @@ -398,6 +406,7 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files inode->i_uid = inode->i_gid = 0; inode->i_blocks = 0; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_version = 1; inode->i_fop = files->ops; inode->i_ino = i; d_add(dentry, inode); diff --git a/fs/pipe.c b/fs/pipe.c index 68090e8..14ba7cb 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -871,6 +871,7 @@ static struct inode * get_pipe_inode(void) inode->i_uid = current->fsuid; inode->i_gid = current->fsgid; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_version = 1; return inode;