Rebase patches and cleanup/update patch descriptions
[ext4-patch-queue.git] / i_version_2_ext4_specific_code
blob24d8e274ab507924e8e9a72cc2bbf535e8149b95
1 [RFC] [patch 2/3] i_version update for ext4: ext4 specific code
3 This part of the patch contains the definition of the on-disk i_version
4 field and its update
6 Signed-off-by: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
7 ---
9  fs/ext4/ialloc.c        |    1 +
10  fs/ext4/inode.c         |    4 ++++
11  fs/ext4/ioctl.c         |    2 ++
12  fs/ext4/namei.c         |    7 +++++++
13  fs/ext4/super.c         |    2 +-
14  fs/ext4/xattr.c         |    1 +
15  include/linux/ext4_fs.h |    4 ++--
16  7 files changed, 18 insertions(+), 3 deletions(-)
18 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
19 index c88b439..a5fe729 100644
20 --- a/fs/ext4/ialloc.c
21 +++ b/fs/ext4/ialloc.c
22 @@ -564,6 +564,7 @@ got:
23         /* This is the optimal IO size (for stat), not the fs block size */
24         inode->i_blocks = 0;
25         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
26 +       inode->i_version = 1;
28         memset(ei->i_data, 0, sizeof(ei->i_data));
29         ei->i_dir_start_lookup = 0;
30 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
31 index 71fe60d..d66c3a4 100644
32 --- a/fs/ext4/inode.c
33 +++ b/fs/ext4/inode.c
34 @@ -728,6 +728,7 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode,
35         /* We are done with atomic stuff, now do the rest of housekeeping */
37         inode->i_ctime = CURRENT_TIME_SEC;
38 +       inode->i_version++;
39         ext4_mark_inode_dirty(handle, inode);
41         /* had we spliced it onto indirect block? */
42 @@ -2472,6 +2473,7 @@ do_indirects:
44         mutex_unlock(&ei->truncate_mutex);
45         inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
46 +       inode->i_version++;
47         ext4_mark_inode_dirty(handle, inode);
49         /*
50 @@ -2710,6 +2712,7 @@ void ext4_read_inode(struct inode * inode)
51         inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->i_ctime);
52         inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->i_mtime);
53         inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
54 +       inode->i_version = le32_to_cpu(raw_inode->ext4_i_version);
56         ei->i_state = 0;
57         ei->i_dir_start_lookup = 0;
58 @@ -2868,6 +2871,7 @@ static int ext4_do_update_inode(handle_t *handle,
59         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
60         raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
61         raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
62 +       raw_inode->ext4_i_version = cpu_to_le32(inode->i_version);
63         raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
64         raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
65         raw_inode->i_flags = cpu_to_le32(ei->i_flags);
66 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
67 index 4914d0e..44c4f6c 100644
68 --- a/fs/ext4/ioctl.c
69 +++ b/fs/ext4/ioctl.c
70 @@ -98,6 +98,7 @@ int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
72                 ext4_set_inode_flags(inode);
73                 inode->i_ctime = CURRENT_TIME_SEC;
74 +               inode->i_version++;
76                 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
77  flags_err:
78 @@ -135,6 +136,7 @@ flags_err:
79                 err = ext4_reserve_inode_write(handle, inode, &iloc);
80                 if (err == 0) {
81                         inode->i_ctime = CURRENT_TIME_SEC;
82 +                       inode->i_version++;
83                         inode->i_generation = generation;
84                         err = ext4_mark_iloc_dirty(handle, inode, &iloc);
85                 }
86 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
87 index e5a74a5..ac865f8 100644
88 --- a/fs/ext4/namei.c
89 +++ b/fs/ext4/namei.c
90 @@ -2059,6 +2059,7 @@ static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
91         inode->i_size = 0;
92         ext4_orphan_add(handle, inode);
93         inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
94 +       inode->i_version++;
95         ext4_mark_inode_dirty(handle, inode);
96         drop_nlink(dir);
97         ext4_update_dx_flag(dir);
98 @@ -2109,12 +2110,14 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
99         if (retval)
100                 goto end_unlink;
101         dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
102 +       dir->i_version++;
103         ext4_update_dx_flag(dir);
104         ext4_mark_inode_dirty(handle, dir);
105         drop_nlink(inode);
106         if (!inode->i_nlink)
107                 ext4_orphan_add(handle, inode);
108         inode->i_ctime = dir->i_ctime;
109 +       inode->i_version++;
110         ext4_mark_inode_dirty(handle, inode);
111         retval = 0;
113 @@ -2200,6 +2203,7 @@ retry:
114                 handle->h_sync = 1;
116         inode->i_ctime = CURRENT_TIME_SEC;
117 +       inode->i_version++;
118         ext4_inc_count(handle, inode);
119         atomic_inc(&inode->i_count);
121 @@ -2302,6 +2306,7 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
122          * rename.
123          */
124         old_inode->i_ctime = CURRENT_TIME_SEC;
125 +       old_inode->i_version++;
126         ext4_mark_inode_dirty(handle, old_inode);
128         /*
129 @@ -2335,8 +2340,10 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
130         if (new_inode) {
131                 drop_nlink(new_inode);
132                 new_inode->i_ctime = CURRENT_TIME_SEC;
133 +               new_inode->i_version++;
134         }
135         old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
136 +       old_dir->i_version++;
137         ext4_update_dx_flag(old_dir);
138         if (dir_bh) {
139                 BUFFER_TRACE(dir_bh, "get_write_access");
140 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
141 index 84ef0b9..0dffe91 100644
142 --- a/fs/ext4/super.c
143 +++ b/fs/ext4/super.c
144 @@ -2799,8 +2799,8 @@ out:
145                 i_size_write(inode, off+len-towrite);
146                 EXT4_I(inode)->i_disksize = inode->i_size;
147         }
148 -       inode->i_version++;
149         inode->i_mtime = inode->i_ctime = CURRENT_TIME;
150 +       inode->i_version = 1;
151         ext4_mark_inode_dirty(handle, inode);
152         mutex_unlock(&inode->i_mutex);
153         return len - towrite;
154 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
155 index dc969c3..58c9632 100644
156 --- a/fs/ext4/xattr.c
157 +++ b/fs/ext4/xattr.c
158 @@ -1005,6 +1005,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
159         if (!error) {
160                 ext4_xattr_update_super_block(handle, inode->i_sb);
161                 inode->i_ctime = CURRENT_TIME_SEC;
162 +               inode->i_version++;
163                 error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
164                 /*
165                  * The bh is consumed by ext4_mark_iloc_dirty, even with
166 diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
167 index 0f60034..a52f35d 100644
168 --- a/include/linux/ext4_fs.h
169 +++ b/include/linux/ext4_fs.h
170 @@ -305,7 +305,7 @@ struct ext4_inode {
171         __le32  i_flags;        /* File flags */
172         union {
173                 struct {
174 -                       __u32  l_i_reserved1;
175 +                       __u32  l_i_version;
176                 } linux1;
177                 struct {
178                         __u32  h_i_translator;
179 @@ -350,7 +350,7 @@ struct ext4_inode {
180  #define i_size_high    i_dir_acl
182  #if defined(__KERNEL__) || defined(__linux__)
183 -#define i_reserved1    osd1.linux1.l_i_reserved1
184 +#define ext4_i_version  osd1.linux1.l_i_version
185  #define i_frag         osd2.linux2.l_i_frag
186  #define i_fsize                osd2.linux2.l_i_fsize
187  #define i_file_acl_high        osd2.linux2.l_i_file_acl_high