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