ext4: fix how i_version is modified and turn it on by default
Subsystems (3)
PATCH 1/1 ext4: fix how i_version is modified and turn it on by default
This makes MS_I_VERSION be turned on by default. Ext4 had been unconditionally doing i_version++ in a few cases anway so the mount option was kind of silly. This patch also removes the update in mark_inode_dirty and makes all of the cases where we update ctime also do inode_inc_iversion. file_update_time takes care of the write case and all the places where we update iversion are protected by the i_mutex so there should be no extra i_lock overhead in the normal non-exported fs case. Thanks,
--- fs/ext4/acl.c | 1 + fs/ext4/extents.c | 3 +++ fs/ext4/indirect.c | 1 + fs/ext4/inode.c | 3 --- fs/ext4/ioctl.c | 2 ++ fs/ext4/namei.c | 14 ++++++++++---- fs/ext4/super.c | 5 +++-- fs/ext4/xattr.c | 1 + 8 files changed, 21 insertions(+), 9 deletions(-)
fs/ext4/acl.c +1 -0
@@ -202,6 +202,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,if (error <0 )return error;else { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);if (error ==0 )
fs/ext4/extents.c +3 -0
@@ -4249,6 +4249,7 @@ out_stop:if (inode->i_nlink)ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);
@@ -4261,6 +4262,7 @@ static void ext4_falloc_update_inode(struct inode *inode,if (update_ctime) { now =current_fs_time (inode->i_sb); +inode_inc_iversion (inode);if (!timespec_equal (&inode->i_ctime, &now)) inode->i_ctime = now; }
@@ -4905,6 +4907,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) out:ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);
fs/ext4/indirect.c +1 -0
@@ -1476,6 +1476,7 @@ do_indirects: out_unlock:up_write (&ei->i_data_sem); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);
fs/ext4/inode.c +0 -3
@@ -4314,9 +4314,6 @@ int ext4_mark_iloc_dirty(handle_t *handle, {int err =0 ; -if (test_opt (inode->i_sb,I_VERSION )) -inode_inc_iversion (inode); -/* the do_update_inode consumes one bh->b_count */ get_bh (iloc->bh);
fs/ext4/ioctl.c +2 -0
@@ -120,6 +120,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ei->i_flags = flags;ext4_set_inode_flags (inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); err =ext4_mark_iloc_dirty (handle, inode, &iloc);
@@ -168,6 +169,7 @@ flags_out: } err =ext4_reserve_inode_write (handle, inode, &iloc);if (err ==0 ) { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); inode->i_generation = generation; err =ext4_mark_iloc_dirty (handle, inode, &iloc);
fs/ext4/namei.c +10 -4
@@ -1316,9 +1316,9 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,* happen is that the times are slightly out of date * and/or different from the directory change time. */ +inode_inc_iversion (dir); dir->i_mtime = dir->i_ctime =ext4_current_time (dir);ext4_update_dx_flag (dir); - dir->i_version++;ext4_mark_inode_dirty (handle, dir);BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);
@@ -1668,7 +1668,6 @@ static int ext4_delete_entry(handle_t *handle, blocksize); else de->inode = 0; - dir->i_version++;BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);if (unlikely (err)) {
@@ -2158,13 +2157,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_warning (inode->i_sb,"empty directory has too many links (%d)" , inode->i_nlink); - inode->i_version++;clear_nlink (inode);/* There's no need to set i_disksize: the fact that i_nlink is * zero will ensure that the right thing happens during any * recovery. */ inode->i_size =0 ;ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); +inode_inc_iversion (dir); inode->i_ctime = dir->i_ctime = dir->i_mtime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_dec_count (handle, dir);
@@ -2218,12 +2218,14 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval =ext4_delete_entry (handle, dir, de, bh);if (retval) goto end_unlink; +inode_inc_iversion (dir); dir->i_ctime = dir->i_mtime =ext4_current_time (dir);ext4_update_dx_flag (dir);ext4_mark_inode_dirty (handle, dir);drop_nlink (inode);if (!inode->i_nlink)ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode); retval =0 ;
@@ -2363,6 +2365,7 @@ retry:if (IS_DIRSYNC (dir))ext4_handle_sync (handle); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_inc_count (handle, inode);ihold (inode);
@@ -2470,7 +2473,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (EXT4_HAS_INCOMPAT_FEATURE (new_dir->i_sb,EXT4_FEATURE_INCOMPAT_FILETYPE )) new_de->file_type = old_de->file_type; - new_dir->i_version++; +inode_inc_iversion (new_dir); new_dir->i_ctime = new_dir->i_mtime =ext4_current_time (new_dir);ext4_mark_inode_dirty (handle, new_dir);
@@ -2488,6 +2491,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,* Like most other Unix systems, set the ctime for inodes on a * rename. */ +inode_inc_iversion (old_inode); old_inode->i_ctime =ext4_current_time (old_inode);ext4_mark_inode_dirty (handle, old_inode);
@@ -2521,8 +2525,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_inode) {ext4_dec_count (handle, new_inode); +inode_inc_iversion (new_inode); new_inode->i_ctime =ext4_current_time (new_inode); } +inode_inc_iversion (old_dir); old_dir->i_ctime = old_dir->i_mtime =ext4_current_time (old_dir);ext4_update_dx_flag (old_dir);if (dir_bh) {
fs/ext4/super.c +3 -2
@@ -1813,8 +1813,7 @@ set_qf_format: "Ignoring deprecated bh option");break ;case Opt_i_version: -set_opt (sb,I_VERSION ); - sb->s_flags |=MS_I_VERSION ; +/* On by default now */ break ;case Opt_nodelalloc:clear_opt (sb,DELALLOC );
@@ -3132,6 +3131,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto out_free_orig; } sb->s_fs_info = sbi; + sb->s_flags |=MS_I_VERSION ; sbi->s_mount_opt =0 ; sbi->s_resuid =EXT4_DEF_RESUID ; sbi->s_resgid =EXT4_DEF_RESGID ;
@@ -4831,6 +4831,7 @@ static int ext4_quota_off(struct super_block *sb, int type) handle =ext4_journal_start (inode,1 );if (IS_ERR (handle)) goto out; +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =CURRENT_TIME ;ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);
fs/ext4/xattr.c +1 -0
@@ -1048,6 +1048,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, }if (!error) {ext4_xattr_update_super_block (handle, inode->i_sb); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);if (!value)ext4_clear_inode_state (inode,EXT4_STATE_NO_EXPAND );
Signature · 6 lines
1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Josef Bacik
This makes
MS_I_VERSIONbe turned on by default. Ext4 had been unconditionally doing i_version++ in a few cases anway so the mount option was kind of silly. This patch also removes the update inmark_inode_dirtyand makes all of the cases where we update ctime also doinode_inc_iversion.file_update_timetakes care of the write case and all the places where we update iversion are protected by thei_mutexso there should be no extrai_lockoverhead in the normal non-exported fs case. Thanks,
Looks OK but it seems slightly fragile (forgetting to update i_version
when we add a place where we update i_ctime looks rather easy). So maybe we should have a small helper like ext4_inode_update_time() which would update c/mtime and i_version?
Honza
Quoted 237 lines
Signed-off-by Josef Bacik <[email protected]>--- fs/ext4/acl.c | 1 + fs/ext4/extents.c | 3 +++ fs/ext4/indirect.c | 1 + fs/ext4/inode.c | 3 --- fs/ext4/ioctl.c | 2 ++ fs/ext4/namei.c | 14 ++++++++++---- fs/ext4/super.c | 5 +++-- fs/ext4/xattr.c | 1 + 8 files changed, 21 insertions(+), 9 deletions(-)fs/ext4/acl.c +1
-0@@ -202,6 +202,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,if (error <0 )return error;else { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);if (error ==0 )fs/ext4/extents.c +3
-0@@ -4249,6 +4249,7 @@ out_stop:if (inode->i_nlink)ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);@@ -4261,6 +4262,7 @@ static void ext4_falloc_update_inode(struct inode *inode,if (update_ctime) { now =current_fs_time (inode->i_sb); +inode_inc_iversion (inode);if (!timespec_equal (&inode->i_ctime, &now)) inode->i_ctime = now; }@@ -4905,6 +4907,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) out:ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/indirect.c +1
-0@@ -1476,6 +1476,7 @@ do_indirects: out_unlock:up_write (&ei->i_data_sem); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);fs/ext4/inode.c +0
-3@@ -4314,9 +4314,6 @@ int ext4_mark_iloc_dirty(handle_t *handle, {int err =0 ; -if (test_opt (inode->i_sb,I_VERSION )) -inode_inc_iversion (inode); -/* the do_update_inode consumes one bh->b_count */ get_bh (iloc->bh);fs/ext4/ioctl.c +2
-0@@ -120,6 +120,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ei->i_flags = flags;ext4_set_inode_flags (inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); err =ext4_mark_iloc_dirty (handle, inode, &iloc);@@ -168,6 +169,7 @@ flags_out: } err =ext4_reserve_inode_write (handle, inode, &iloc);if (err ==0 ) { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); inode->i_generation = generation; err =ext4_mark_iloc_dirty (handle, inode, &iloc);fs/ext4/namei.c +10
-4@@ -1316,9 +1316,9 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,* happen is that the times are slightly out of date * and/or different from the directory change time. */ +inode_inc_iversion (dir); dir->i_mtime = dir->i_ctime =ext4_current_time (dir);ext4_update_dx_flag (dir); - dir->i_version++;ext4_mark_inode_dirty (handle, dir);BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);@@ -1668,7 +1668,6 @@ static int ext4_delete_entry(handle_t *handle, blocksize); else de->inode = 0; - dir->i_version++;BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);if (unlikely (err)) {@@ -2158,13 +2157,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_warning (inode->i_sb,"empty directory has too many links (%d)" , inode->i_nlink); - inode->i_version++;clear_nlink (inode);/* There's no need to set i_disksize: the fact that i_nlink is * zero will ensure that the right thing happens during any * recovery. */ inode->i_size =0 ;ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); +inode_inc_iversion (dir); inode->i_ctime = dir->i_ctime = dir->i_mtime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_dec_count (handle, dir);@@ -2218,12 +2218,14 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval =ext4_delete_entry (handle, dir, de, bh);if (retval) goto end_unlink; +inode_inc_iversion (dir); dir->i_ctime = dir->i_mtime =ext4_current_time (dir);ext4_update_dx_flag (dir);ext4_mark_inode_dirty (handle, dir);drop_nlink (inode);if (!inode->i_nlink)ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode); retval =0 ;@@ -2363,6 +2365,7 @@ retry:if (IS_DIRSYNC (dir))ext4_handle_sync (handle); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_inc_count (handle, inode);ihold (inode);@@ -2470,7 +2473,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (EXT4_HAS_INCOMPAT_FEATURE (new_dir->i_sb,EXT4_FEATURE_INCOMPAT_FILETYPE )) new_de->file_type = old_de->file_type; - new_dir->i_version++; +inode_inc_iversion (new_dir); new_dir->i_ctime = new_dir->i_mtime =ext4_current_time (new_dir);ext4_mark_inode_dirty (handle, new_dir);@@ -2488,6 +2491,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,* Like most other Unix systems, set the ctime for inodes on a * rename. */ +inode_inc_iversion (old_inode); old_inode->i_ctime =ext4_current_time (old_inode);ext4_mark_inode_dirty (handle, old_inode);@@ -2521,8 +2525,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_inode) {ext4_dec_count (handle, new_inode); +inode_inc_iversion (new_inode); new_inode->i_ctime =ext4_current_time (new_inode); } +inode_inc_iversion (old_dir); old_dir->i_ctime = old_dir->i_mtime =ext4_current_time (old_dir);ext4_update_dx_flag (old_dir);if (dir_bh) {fs/ext4/super.c +3
-2@@ -1813,8 +1813,7 @@ set_qf_format: "Ignoring deprecated bh option");break ;case Opt_i_version: -set_opt (sb,I_VERSION ); - sb->s_flags |=MS_I_VERSION ; +/* On by default now */ break ;case Opt_nodelalloc:clear_opt (sb,DELALLOC );@@ -3132,6 +3131,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto out_free_orig; } sb->s_fs_info = sbi; + sb->s_flags |=MS_I_VERSION ; sbi->s_mount_opt =0 ; sbi->s_resuid =EXT4_DEF_RESUID ; sbi->s_resgid =EXT4_DEF_RESGID ;@@ -4831,6 +4831,7 @@ static int ext4_quota_off(struct super_block *sb, int type) handle =ext4_journal_start (inode,1 );if (IS_ERR (handle)) goto out; +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =CURRENT_TIME ;ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/xattr.c +1
-0@@ -1048,6 +1048,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, }if (!error) {ext4_xattr_update_super_block (handle, inode->i_sb); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);if (!value)ext4_clear_inode_state (inode,EXT4_STATE_NO_EXPAND );Signature · 6 lines
1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Jan Kara <[email protected]> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Jan Kara
Quoted 7 lines · Josef Bacik
This makes
MS_I_VERSIONbe turned on by default. Ext4 had been unconditionally doing i_version++ in a few cases anway so the mount option was kind of silly. This patch also removes the update inmark_inode_dirtyand makes all of the cases where we update ctime also doinode_inc_iversion.file_update_timetakes care of the write case and all the places where we update iversion are protected by thei_mutexso there should be no extrai_lockoverhead in the normal non-exported fs case. Thanks,
Quoted 7 lines
Looks OK but it seems slightly fragile (forgetting to update
i_version
when we add a place where we updatei_ctimelooks rather easy). So maybe we should have a small helper likeext4_inode_update_time()which would update c/mtime andi_version?Honza
Exactly my thought. And there is already an helper function - inode_inc_iversion() But I agree that a name change is appropriate.
Cheers
Boaz
Quoted 237 lines
Quoted 237 lines
Signed-off-by Josef Bacik <[email protected]>--- fs/ext4/acl.c | 1 + fs/ext4/extents.c | 3 +++ fs/ext4/indirect.c | 1 + fs/ext4/inode.c | 3 --- fs/ext4/ioctl.c | 2 ++ fs/ext4/namei.c | 14 ++++++++++---- fs/ext4/super.c | 5 +++-- fs/ext4/xattr.c | 1 + 8 files changed, 21 insertions(+), 9 deletions(-)fs/ext4/acl.c +1
-0@@ -202,6 +202,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,if (error <0 )return error;else { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);if (error ==0 )fs/ext4/extents.c +3
-0@@ -4249,6 +4249,7 @@ out_stop:if (inode->i_nlink)ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);@@ -4261,6 +4262,7 @@ static void ext4_falloc_update_inode(struct inode *inode,if (update_ctime) { now =current_fs_time (inode->i_sb); +inode_inc_iversion (inode);if (!timespec_equal (&inode->i_ctime, &now)) inode->i_ctime = now; }@@ -4905,6 +4907,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) out:ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/indirect.c +1
-0@@ -1476,6 +1476,7 @@ do_indirects: out_unlock:up_write (&ei->i_data_sem); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);fs/ext4/inode.c +0
-3@@ -4314,9 +4314,6 @@ int ext4_mark_iloc_dirty(handle_t *handle, {int err =0 ; -if (test_opt (inode->i_sb,I_VERSION )) -inode_inc_iversion (inode); -/* the do_update_inode consumes one bh->b_count */ get_bh (iloc->bh);fs/ext4/ioctl.c +2
-0@@ -120,6 +120,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ei->i_flags = flags;ext4_set_inode_flags (inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); err =ext4_mark_iloc_dirty (handle, inode, &iloc);@@ -168,6 +169,7 @@ flags_out: } err =ext4_reserve_inode_write (handle, inode, &iloc);if (err ==0 ) { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); inode->i_generation = generation; err =ext4_mark_iloc_dirty (handle, inode, &iloc);fs/ext4/namei.c +10
-4@@ -1316,9 +1316,9 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,* happen is that the times are slightly out of date * and/or different from the directory change time. */ +inode_inc_iversion (dir); dir->i_mtime = dir->i_ctime =ext4_current_time (dir);ext4_update_dx_flag (dir); - dir->i_version++;ext4_mark_inode_dirty (handle, dir);BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);@@ -1668,7 +1668,6 @@ static int ext4_delete_entry(handle_t *handle, blocksize); else de->inode = 0; - dir->i_version++;BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);if (unlikely (err)) {@@ -2158,13 +2157,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_warning (inode->i_sb,"empty directory has too many links (%d)" , inode->i_nlink); - inode->i_version++;clear_nlink (inode);/* There's no need to set i_disksize: the fact that i_nlink is * zero will ensure that the right thing happens during any * recovery. */ inode->i_size =0 ;ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); +inode_inc_iversion (dir); inode->i_ctime = dir->i_ctime = dir->i_mtime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_dec_count (handle, dir);@@ -2218,12 +2218,14 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval =ext4_delete_entry (handle, dir, de, bh);if (retval) goto end_unlink; +inode_inc_iversion (dir); dir->i_ctime = dir->i_mtime =ext4_current_time (dir);ext4_update_dx_flag (dir);ext4_mark_inode_dirty (handle, dir);drop_nlink (inode);if (!inode->i_nlink)ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode); retval =0 ;@@ -2363,6 +2365,7 @@ retry:if (IS_DIRSYNC (dir))ext4_handle_sync (handle); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_inc_count (handle, inode);ihold (inode);@@ -2470,7 +2473,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (EXT4_HAS_INCOMPAT_FEATURE (new_dir->i_sb,EXT4_FEATURE_INCOMPAT_FILETYPE )) new_de->file_type = old_de->file_type; - new_dir->i_version++; +inode_inc_iversion (new_dir); new_dir->i_ctime = new_dir->i_mtime =ext4_current_time (new_dir);ext4_mark_inode_dirty (handle, new_dir);@@ -2488,6 +2491,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,* Like most other Unix systems, set the ctime for inodes on a * rename. */ +inode_inc_iversion (old_inode); old_inode->i_ctime =ext4_current_time (old_inode);ext4_mark_inode_dirty (handle, old_inode);@@ -2521,8 +2525,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_inode) {ext4_dec_count (handle, new_inode); +inode_inc_iversion (new_inode); new_inode->i_ctime =ext4_current_time (new_inode); } +inode_inc_iversion (old_dir); old_dir->i_ctime = old_dir->i_mtime =ext4_current_time (old_dir);ext4_update_dx_flag (old_dir);if (dir_bh) {fs/ext4/super.c +3
-2@@ -1813,8 +1813,7 @@ set_qf_format: "Ignoring deprecated bh option");break ;case Opt_i_version: -set_opt (sb,I_VERSION ); - sb->s_flags |=MS_I_VERSION ; +/* On by default now */ break ;case Opt_nodelalloc:clear_opt (sb,DELALLOC );@@ -3132,6 +3131,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto out_free_orig; } sb->s_fs_info = sbi; + sb->s_flags |=MS_I_VERSION ; sbi->s_mount_opt =0 ; sbi->s_resuid =EXT4_DEF_RESUID ; sbi->s_resgid =EXT4_DEF_RESGID ;@@ -4831,6 +4831,7 @@ static int ext4_quota_off(struct super_block *sb, int type) handle =ext4_journal_start (inode,1 );if (IS_ERR (handle)) goto out; +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =CURRENT_TIME ;ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/xattr.c +1
-0@@ -1048,6 +1048,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, }if (!error) {ext4_xattr_update_super_block (handle, inode->i_sb); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);if (!value)ext4_clear_inode_state (inode,EXT4_STATE_NO_EXPAND );Signature · 6 lines
1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 15 lines · Boaz Harrosh
Quoted 13 lines · Jan Kara
Quoted 7 lines · Josef Bacik
This makes
MS_I_VERSIONbe turned on by default. Ext4 had been unconditionally doing i_version++ in a few cases anway so the mount option was kind of silly. This patch also removes the update inmark_inode_dirtyand makes all of the cases where we update ctime also doinode_inc_iversion.file_update_timetakes care of the write case and all the places where we update iversion are protected by thei_mutexso there should be no extrai_lockoverhead in the normal non-exported fs case. Thanks,Looks OK but it seems slightly fragile (forgetting to update
i_version
when we add a place where we updatei_ctimelooks rather easy). So maybe we should have a small helper likeext4_inode_update_time()which would update c/mtime andi_version?
Quoted 7 lines
Quoted 2 lines
Honza
Exactly my thought. And there is already an helper function -
inode_inc_iversion()But I agree that a name change is appropriate.
Rrrr, strike that, need that morning coffee now.
But yes an helper was what I thought as well.
Sorry
Boaz
Quoted 236 lines
Cheers
BoazQuoted 233 lines
Quoted 233 lines
Signed-off-by Josef Bacik <[email protected]>--- fs/ext4/acl.c | 1 + fs/ext4/extents.c | 3 +++ fs/ext4/indirect.c | 1 + fs/ext4/inode.c | 3 --- fs/ext4/ioctl.c | 2 ++ fs/ext4/namei.c | 14 ++++++++++---- fs/ext4/super.c | 5 +++-- fs/ext4/xattr.c | 1 + 8 files changed, 21 insertions(+), 9 deletions(-)fs/ext4/acl.c +1
-0@@ -202,6 +202,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,if (error <0 )return error;else { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);if (error ==0 )fs/ext4/extents.c +3
-0@@ -4249,6 +4249,7 @@ out_stop:if (inode->i_nlink)ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);@@ -4261,6 +4262,7 @@ static void ext4_falloc_update_inode(struct inode *inode,if (update_ctime) { now =current_fs_time (inode->i_sb); +inode_inc_iversion (inode);if (!timespec_equal (&inode->i_ctime, &now)) inode->i_ctime = now; }@@ -4905,6 +4907,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) out:ext4_orphan_del (handle, inode); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/indirect.c +1
-0@@ -1476,6 +1476,7 @@ do_indirects: out_unlock:up_write (&ei->i_data_sem); +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);fs/ext4/inode.c +0
-3@@ -4314,9 +4314,6 @@ int ext4_mark_iloc_dirty(handle_t *handle, {int err =0 ; -if (test_opt (inode->i_sb,I_VERSION )) -inode_inc_iversion (inode); -/* the do_update_inode consumes one bh->b_count */ get_bh (iloc->bh);fs/ext4/ioctl.c +2
-0@@ -120,6 +120,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ei->i_flags = flags;ext4_set_inode_flags (inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); err =ext4_mark_iloc_dirty (handle, inode, &iloc);@@ -168,6 +169,7 @@ flags_out: } err =ext4_reserve_inode_write (handle, inode, &iloc);if (err ==0 ) { +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode); inode->i_generation = generation; err =ext4_mark_iloc_dirty (handle, inode, &iloc);fs/ext4/namei.c +10
-4@@ -1316,9 +1316,9 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,* happen is that the times are slightly out of date * and/or different from the directory change time. */ +inode_inc_iversion (dir); dir->i_mtime = dir->i_ctime =ext4_current_time (dir);ext4_update_dx_flag (dir); - dir->i_version++;ext4_mark_inode_dirty (handle, dir);BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);@@ -1668,7 +1668,6 @@ static int ext4_delete_entry(handle_t *handle, blocksize); else de->inode = 0; - dir->i_version++;BUFFER_TRACE (bh,"call ext4_handle_dirty_metadata" ); err =ext4_handle_dirty_metadata (handle, dir, bh);if (unlikely (err)) {@@ -2158,13 +2157,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_warning (inode->i_sb,"empty directory has too many links (%d)" , inode->i_nlink); - inode->i_version++;clear_nlink (inode);/* There's no need to set i_disksize: the fact that i_nlink is * zero will ensure that the right thing happens during any * recovery. */ inode->i_size =0 ;ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); +inode_inc_iversion (dir); inode->i_ctime = dir->i_ctime = dir->i_mtime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode);ext4_dec_count (handle, dir);@@ -2218,12 +2218,14 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval =ext4_delete_entry (handle, dir, de, bh);if (retval) goto end_unlink; +inode_inc_iversion (dir); dir->i_ctime = dir->i_mtime =ext4_current_time (dir);ext4_update_dx_flag (dir);ext4_mark_inode_dirty (handle, dir);drop_nlink (inode);if (!inode->i_nlink)ext4_orphan_add (handle, inode); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_mark_inode_dirty (handle, inode); retval =0 ;@@ -2363,6 +2365,7 @@ retry:if (IS_DIRSYNC (dir))ext4_handle_sync (handle); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);ext4_inc_count (handle, inode);ihold (inode);@@ -2470,7 +2473,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (EXT4_HAS_INCOMPAT_FEATURE (new_dir->i_sb,EXT4_FEATURE_INCOMPAT_FILETYPE )) new_de->file_type = old_de->file_type; - new_dir->i_version++; +inode_inc_iversion (new_dir); new_dir->i_ctime = new_dir->i_mtime =ext4_current_time (new_dir);ext4_mark_inode_dirty (handle, new_dir);@@ -2488,6 +2491,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,* Like most other Unix systems, set the ctime for inodes on a * rename. */ +inode_inc_iversion (old_inode); old_inode->i_ctime =ext4_current_time (old_inode);ext4_mark_inode_dirty (handle, old_inode);@@ -2521,8 +2525,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_inode) {ext4_dec_count (handle, new_inode); +inode_inc_iversion (new_inode); new_inode->i_ctime =ext4_current_time (new_inode); } +inode_inc_iversion (old_dir); old_dir->i_ctime = old_dir->i_mtime =ext4_current_time (old_dir);ext4_update_dx_flag (old_dir);if (dir_bh) {fs/ext4/super.c +3
-2@@ -1813,8 +1813,7 @@ set_qf_format: "Ignoring deprecated bh option");break ;case Opt_i_version: -set_opt (sb,I_VERSION ); - sb->s_flags |=MS_I_VERSION ; +/* On by default now */ break ;case Opt_nodelalloc:clear_opt (sb,DELALLOC );@@ -3132,6 +3131,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto out_free_orig; } sb->s_fs_info = sbi; + sb->s_flags |=MS_I_VERSION ; sbi->s_mount_opt =0 ; sbi->s_resuid =EXT4_DEF_RESUID ; sbi->s_resgid =EXT4_DEF_RESGID ;@@ -4831,6 +4831,7 @@ static int ext4_quota_off(struct super_block *sb, int type) handle =ext4_journal_start (inode,1 );if (IS_ERR (handle)) goto out; +inode_inc_iversion (inode); inode->i_mtime = inode->i_ctime =CURRENT_TIME ;ext4_mark_inode_dirty (handle, inode);ext4_journal_stop (handle);fs/ext4/xattr.c +1
-0@@ -1048,6 +1048,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, }if (!error) {ext4_xattr_update_super_block (handle, inode->i_sb); +inode_inc_iversion (inode); inode->i_ctime =ext4_current_time (inode);if (!value)ext4_clear_inode_state (inode,EXT4_STATE_NO_EXPAND );Signature · 1 line
1.7.7.6
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html