More patch description fixups. Standardize case.
[ext4-patch-queue.git] / inode-version-ext4.patch
blob9a139cd18ace6192b050f91d7e9dcf88e31cc261
1 ext4: Add inode version support in ext4
3 From: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
5 This patch adds 64-bit inode version support to ext4. The lower 32 bits
6 are stored in the osd1.linux1.l_i_version field while the high 32 bits
7 are stored in the i_version_hi field newly created in the ext4_inode.
8 This field is incremented in case the ext4_inode is large enough. A
9 i_version mount option has been added to enable the feature.
11 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
12 Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
13 Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
14 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
15 Signed-off-by: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
16 ---
18 fs/ext4/inode.c | 18 +++++++++++++++++-
19 fs/ext4/super.c | 10 ++++++++--
20 fs/inode.c | 17 -----------------
21 include/linux/ext4_fs.h | 6 +++++-
22 include/linux/fs.h | 16 +++++++++++++++-
23 5 files changed, 45 insertions(+), 22 deletions(-)
26 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
27 index ee0bc3a..3c013e5 100644
28 --- a/fs/ext4/inode.c
29 +++ b/fs/ext4/inode.c
30 @@ -2780,6 +2780,13 @@ void ext4_read_inode(struct inode * inode)
31 EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
32 EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
34 + inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
35 + if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
36 + if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
37 + inode->i_version |=
38 + (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
39 + }
41 if (S_ISREG(inode->i_mode)) {
42 inode->i_op = &ext4_file_inode_operations;
43 inode->i_fop = &ext4_file_operations;
44 @@ -2962,8 +2969,14 @@ static int ext4_do_update_inode(handle_t *handle,
45 } else for (block = 0; block < EXT4_N_BLOCKS; block++)
46 raw_inode->i_block[block] = ei->i_data[block];
48 - if (ei->i_extra_isize)
49 + raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
50 + if (ei->i_extra_isize) {
51 + if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
52 + raw_inode->i_version_hi =
53 + cpu_to_le32(inode->i_version >> 32);
54 raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
55 + }
58 BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
59 rc = ext4_journal_dirty_metadata(handle, bh);
60 @@ -3190,6 +3203,9 @@ int ext4_mark_iloc_dirty(handle_t *handle,
62 int err = 0;
64 + if (test_opt(inode->i_sb, I_VERSION))
65 + inode_inc_iversion(inode);
67 /* the do_update_inode consumes one bh->b_count */
68 get_bh(iloc->bh);
70 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
71 index f7479d3..aa22acd 100644
72 --- a/fs/ext4/super.c
73 +++ b/fs/ext4/super.c
74 @@ -732,6 +732,8 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
75 seq_puts(seq, ",nobh");
76 if (!test_opt(sb, EXTENTS))
77 seq_puts(seq, ",noextents");
78 + if (test_opt(sb, I_VERSION))
79 + seq_puts(seq, ",i_version");
81 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
82 seq_puts(seq, ",data=journal");
83 @@ -874,7 +876,7 @@ enum {
84 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
85 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
86 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
87 - Opt_grpquota, Opt_extents, Opt_noextents,
88 + Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
91 static match_table_t tokens = {
92 @@ -928,6 +930,7 @@ static match_table_t tokens = {
93 {Opt_barrier, "barrier=%u"},
94 {Opt_extents, "extents"},
95 {Opt_noextents, "noextents"},
96 + {Opt_i_version, "i_version"},
97 {Opt_err, NULL},
98 {Opt_resize, "resize"},
100 @@ -1273,6 +1276,10 @@ clear_qf_name:
101 case Opt_noextents:
102 clear_opt (sbi->s_mount_opt, EXTENTS);
103 break;
104 + case Opt_i_version:
105 + set_opt(sbi->s_mount_opt, I_VERSION);
106 + sb->s_flags |= MS_I_VERSION;
107 + break;
108 default:
109 printk (KERN_ERR
110 "EXT4-fs: Unrecognized mount option \"%s\" "
111 @@ -3197,7 +3204,6 @@ out:
112 i_size_write(inode, off+len-towrite);
113 EXT4_I(inode)->i_disksize = inode->i_size;
115 - inode->i_version++;
116 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
117 ext4_mark_inode_dirty(handle, inode);
118 mutex_unlock(&inode->i_mutex);
119 diff --git a/fs/inode.c b/fs/inode.c
120 index b48324a..276ffd6 100644
121 --- a/fs/inode.c
122 +++ b/fs/inode.c
123 @@ -1243,23 +1243,6 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
124 EXPORT_SYMBOL(touch_atime);
127 - * inode_inc_iversion - increments i_version
128 - * @inode: inode that need to be updated
130 - * Every time the inode is modified, the i_version field
131 - * will be incremented.
132 - * The filesystem has to be mounted with i_version flag
134 - */
136 -void inode_inc_iversion(struct inode *inode)
138 - spin_lock(&inode->i_lock);
139 - inode->i_version++;
140 - spin_unlock(&inode->i_lock);
143 -/**
144 * file_update_time - update mtime and ctime time
145 * @file: file accessed
147 diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
148 index cd406db..b609294 100644
149 --- a/include/linux/ext4_fs.h
150 +++ b/include/linux/ext4_fs.h
151 @@ -292,7 +292,7 @@ struct ext4_inode {
152 __le32 i_flags; /* File flags */
153 union {
154 struct {
155 - __u32 l_i_reserved1;
156 + __le32 l_i_version;
157 } linux1;
158 struct {
159 __u32 h_i_translator;
160 @@ -334,6 +334,7 @@ struct ext4_inode {
161 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
162 __le32 i_crtime; /* File Creation time */
163 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
164 + __le32 i_version_hi; /* high 32 bits for 64-bit version */
168 @@ -407,6 +408,8 @@ do { \
169 raw_inode->xtime ## _extra); \
170 } while (0)
172 +#define i_disk_version osd1.linux1.l_i_version
174 #if defined(__KERNEL__) || defined(__linux__)
175 #define i_reserved1 osd1.linux1.l_i_reserved1
176 #define i_file_acl_high osd2.linux2.l_i_file_acl_high
177 @@ -469,6 +472,7 @@ do { \
178 #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
179 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
180 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
181 +#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
182 /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
183 #ifndef _LINUX_EXT2_FS_H
184 #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
185 diff --git a/include/linux/fs.h b/include/linux/fs.h
186 index 94cf5d8..2ac81ee 100644
187 --- a/include/linux/fs.h
188 +++ b/include/linux/fs.h
189 @@ -1396,7 +1396,21 @@ static inline void inode_dec_link_count(struct inode *inode)
190 mark_inode_dirty(inode);
193 -extern void inode_inc_iversion(struct inode *inode);
194 +/**
195 + * inode_inc_iversion - increments i_version
196 + * @inode: inode that need to be updated
198 + * Every time the inode is modified, the i_version field will be incremented.
199 + * The filesystem has to be mounted with i_version flag
200 + */
202 +static inline void inode_inc_iversion(struct inode *inode)
204 + spin_lock(&inode->i_lock);
205 + inode->i_version++;
206 + spin_unlock(&inode->i_lock);
209 extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
210 static inline void file_accessed(struct file *file)