diff options
author | Jean Noel Cordenner <jean-noel.cordenner@bull.net> | 2008-01-28 23:58:27 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-01-28 23:58:27 -0500 |
commit | 25ec56b518257a56d2ff41a941d288e4b5ff9488 (patch) | |
tree | 77e84d38a5ad242f9d73a006f009649f223378f1 /fs | |
parent | 7a224228ed79d587ece2304869000aad1b8e97dd (diff) |
ext4: Add inode version support in ext4
This patch adds 64-bit inode version support to ext4. The lower 32 bits
are stored in the osd1.linux1.l_i_version field while the high 32 bits
are stored in the i_version_hi field newly created in the ext4_inode.
This field is incremented in case the ext4_inode is large enough. A
i_version mount option has been added to enable the feature.
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 18 | ||||
-rw-r--r-- | fs/ext4/super.c | 10 | ||||
-rw-r--r-- | fs/inode.c | 17 |
3 files changed, 25 insertions, 20 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 89cd35386ff5..a06a3b7cfc34 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2781,6 +2781,13 @@ void ext4_read_inode(struct inode * inode) | |||
2781 | EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode); | 2781 | EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode); |
2782 | EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode); | 2782 | EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode); |
2783 | 2783 | ||
2784 | inode->i_version = le32_to_cpu(raw_inode->i_disk_version); | ||
2785 | if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { | ||
2786 | if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi)) | ||
2787 | inode->i_version |= | ||
2788 | (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32; | ||
2789 | } | ||
2790 | |||
2784 | if (S_ISREG(inode->i_mode)) { | 2791 | if (S_ISREG(inode->i_mode)) { |
2785 | inode->i_op = &ext4_file_inode_operations; | 2792 | inode->i_op = &ext4_file_inode_operations; |
2786 | inode->i_fop = &ext4_file_operations; | 2793 | inode->i_fop = &ext4_file_operations; |
@@ -2963,8 +2970,14 @@ static int ext4_do_update_inode(handle_t *handle, | |||
2963 | } else for (block = 0; block < EXT4_N_BLOCKS; block++) | 2970 | } else for (block = 0; block < EXT4_N_BLOCKS; block++) |
2964 | raw_inode->i_block[block] = ei->i_data[block]; | 2971 | raw_inode->i_block[block] = ei->i_data[block]; |
2965 | 2972 | ||
2966 | if (ei->i_extra_isize) | 2973 | raw_inode->i_disk_version = cpu_to_le32(inode->i_version); |
2974 | if (ei->i_extra_isize) { | ||
2975 | if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi)) | ||
2976 | raw_inode->i_version_hi = | ||
2977 | cpu_to_le32(inode->i_version >> 32); | ||
2967 | raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); | 2978 | raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); |
2979 | } | ||
2980 | |||
2968 | 2981 | ||
2969 | BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata"); | 2982 | BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata"); |
2970 | rc = ext4_journal_dirty_metadata(handle, bh); | 2983 | rc = ext4_journal_dirty_metadata(handle, bh); |
@@ -3191,6 +3204,9 @@ int ext4_mark_iloc_dirty(handle_t *handle, | |||
3191 | { | 3204 | { |
3192 | int err = 0; | 3205 | int err = 0; |
3193 | 3206 | ||
3207 | if (test_opt(inode->i_sb, I_VERSION)) | ||
3208 | inode_inc_iversion(inode); | ||
3209 | |||
3194 | /* the do_update_inode consumes one bh->b_count */ | 3210 | /* the do_update_inode consumes one bh->b_count */ |
3195 | get_bh(iloc->bh); | 3211 | get_bh(iloc->bh); |
3196 | 3212 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f7479d30735e..aa22acd6eb06 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -732,6 +732,8 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
732 | seq_puts(seq, ",nobh"); | 732 | seq_puts(seq, ",nobh"); |
733 | if (!test_opt(sb, EXTENTS)) | 733 | if (!test_opt(sb, EXTENTS)) |
734 | seq_puts(seq, ",noextents"); | 734 | seq_puts(seq, ",noextents"); |
735 | if (test_opt(sb, I_VERSION)) | ||
736 | seq_puts(seq, ",i_version"); | ||
735 | 737 | ||
736 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) | 738 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) |
737 | seq_puts(seq, ",data=journal"); | 739 | seq_puts(seq, ",data=journal"); |
@@ -874,7 +876,7 @@ enum { | |||
874 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 876 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
875 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 877 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
876 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, | 878 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, |
877 | Opt_grpquota, Opt_extents, Opt_noextents, | 879 | Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, |
878 | }; | 880 | }; |
879 | 881 | ||
880 | static match_table_t tokens = { | 882 | static match_table_t tokens = { |
@@ -928,6 +930,7 @@ static match_table_t tokens = { | |||
928 | {Opt_barrier, "barrier=%u"}, | 930 | {Opt_barrier, "barrier=%u"}, |
929 | {Opt_extents, "extents"}, | 931 | {Opt_extents, "extents"}, |
930 | {Opt_noextents, "noextents"}, | 932 | {Opt_noextents, "noextents"}, |
933 | {Opt_i_version, "i_version"}, | ||
931 | {Opt_err, NULL}, | 934 | {Opt_err, NULL}, |
932 | {Opt_resize, "resize"}, | 935 | {Opt_resize, "resize"}, |
933 | }; | 936 | }; |
@@ -1273,6 +1276,10 @@ clear_qf_name: | |||
1273 | case Opt_noextents: | 1276 | case Opt_noextents: |
1274 | clear_opt (sbi->s_mount_opt, EXTENTS); | 1277 | clear_opt (sbi->s_mount_opt, EXTENTS); |
1275 | break; | 1278 | break; |
1279 | case Opt_i_version: | ||
1280 | set_opt(sbi->s_mount_opt, I_VERSION); | ||
1281 | sb->s_flags |= MS_I_VERSION; | ||
1282 | break; | ||
1276 | default: | 1283 | default: |
1277 | printk (KERN_ERR | 1284 | printk (KERN_ERR |
1278 | "EXT4-fs: Unrecognized mount option \"%s\" " | 1285 | "EXT4-fs: Unrecognized mount option \"%s\" " |
@@ -3197,7 +3204,6 @@ out: | |||
3197 | i_size_write(inode, off+len-towrite); | 3204 | i_size_write(inode, off+len-towrite); |
3198 | EXT4_I(inode)->i_disksize = inode->i_size; | 3205 | EXT4_I(inode)->i_disksize = inode->i_size; |
3199 | } | 3206 | } |
3200 | inode->i_version++; | ||
3201 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 3207 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
3202 | ext4_mark_inode_dirty(handle, inode); | 3208 | ext4_mark_inode_dirty(handle, inode); |
3203 | mutex_unlock(&inode->i_mutex); | 3209 | mutex_unlock(&inode->i_mutex); |
diff --git a/fs/inode.c b/fs/inode.c index b48324a94c2b..276ffd6b6fdd 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -1243,23 +1243,6 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry) | |||
1243 | EXPORT_SYMBOL(touch_atime); | 1243 | EXPORT_SYMBOL(touch_atime); |
1244 | 1244 | ||
1245 | /** | 1245 | /** |
1246 | * inode_inc_iversion - increments i_version | ||
1247 | * @inode: inode that need to be updated | ||
1248 | * | ||
1249 | * Every time the inode is modified, the i_version field | ||
1250 | * will be incremented. | ||
1251 | * The filesystem has to be mounted with i_version flag | ||
1252 | * | ||
1253 | */ | ||
1254 | |||
1255 | void inode_inc_iversion(struct inode *inode) | ||
1256 | { | ||
1257 | spin_lock(&inode->i_lock); | ||
1258 | inode->i_version++; | ||
1259 | spin_unlock(&inode->i_lock); | ||
1260 | } | ||
1261 | |||
1262 | /** | ||
1263 | * file_update_time - update mtime and ctime time | 1246 | * file_update_time - update mtime and ctime time |
1264 | * @file: file accessed | 1247 | * @file: file accessed |
1265 | * | 1248 | * |