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 | |
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>
-rw-r--r-- | fs/ext4/inode.c | 18 | ||||
-rw-r--r-- | fs/ext4/super.c | 10 | ||||
-rw-r--r-- | fs/inode.c | 17 | ||||
-rw-r--r-- | include/linux/ext4_fs.h | 6 | ||||
-rw-r--r-- | include/linux/fs.h | 16 |
5 files changed, 45 insertions, 22 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 | * |
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h index cd406dba0e64..b6092940c8b8 100644 --- a/include/linux/ext4_fs.h +++ b/include/linux/ext4_fs.h | |||
@@ -292,7 +292,7 @@ struct ext4_inode { | |||
292 | __le32 i_flags; /* File flags */ | 292 | __le32 i_flags; /* File flags */ |
293 | union { | 293 | union { |
294 | struct { | 294 | struct { |
295 | __u32 l_i_reserved1; | 295 | __le32 l_i_version; |
296 | } linux1; | 296 | } linux1; |
297 | struct { | 297 | struct { |
298 | __u32 h_i_translator; | 298 | __u32 h_i_translator; |
@@ -334,6 +334,7 @@ struct ext4_inode { | |||
334 | __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ | 334 | __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ |
335 | __le32 i_crtime; /* File Creation time */ | 335 | __le32 i_crtime; /* File Creation time */ |
336 | __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ | 336 | __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ |
337 | __le32 i_version_hi; /* high 32 bits for 64-bit version */ | ||
337 | }; | 338 | }; |
338 | 339 | ||
339 | 340 | ||
@@ -407,6 +408,8 @@ do { \ | |||
407 | raw_inode->xtime ## _extra); \ | 408 | raw_inode->xtime ## _extra); \ |
408 | } while (0) | 409 | } while (0) |
409 | 410 | ||
411 | #define i_disk_version osd1.linux1.l_i_version | ||
412 | |||
410 | #if defined(__KERNEL__) || defined(__linux__) | 413 | #if defined(__KERNEL__) || defined(__linux__) |
411 | #define i_reserved1 osd1.linux1.l_i_reserved1 | 414 | #define i_reserved1 osd1.linux1.l_i_reserved1 |
412 | #define i_file_acl_high osd2.linux2.l_i_file_acl_high | 415 | #define i_file_acl_high osd2.linux2.l_i_file_acl_high |
@@ -469,6 +472,7 @@ do { \ | |||
469 | #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */ | 472 | #define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */ |
470 | #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */ | 473 | #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */ |
471 | #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ | 474 | #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ |
475 | #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */ | ||
472 | /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */ | 476 | /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */ |
473 | #ifndef _LINUX_EXT2_FS_H | 477 | #ifndef _LINUX_EXT2_FS_H |
474 | #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt | 478 | #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 9608839552b3..a516b6716870 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1396,7 +1396,21 @@ static inline void inode_dec_link_count(struct inode *inode) | |||
1396 | mark_inode_dirty(inode); | 1396 | mark_inode_dirty(inode); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | extern void inode_inc_iversion(struct inode *inode); | 1399 | /** |
1400 | * inode_inc_iversion - increments i_version | ||
1401 | * @inode: inode that need to be updated | ||
1402 | * | ||
1403 | * Every time the inode is modified, the i_version field will be incremented. | ||
1404 | * The filesystem has to be mounted with i_version flag | ||
1405 | */ | ||
1406 | |||
1407 | static inline void inode_inc_iversion(struct inode *inode) | ||
1408 | { | ||
1409 | spin_lock(&inode->i_lock); | ||
1410 | inode->i_version++; | ||
1411 | spin_unlock(&inode->i_lock); | ||
1412 | } | ||
1413 | |||
1400 | extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry); | 1414 | extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry); |
1401 | static inline void file_accessed(struct file *file) | 1415 | static inline void file_accessed(struct file *file) |
1402 | { | 1416 | { |