i_version:ext4 inode version read/store
Subsystems (2)
PATCH 3/5 i_version:ext4 inode version read/store
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.
fs/ext4/inode.c +14 -1
@@ -2709,6 +2709,13 @@ void ext4_read_inode(struct inode * inodEXT4_INODE_GET_XTIME (i_atime, inode, raw_inode);EXT4_EINODE_GET_XTIME (i_crtime, ei, raw_inode); + inode->i_version =le32_to_cpu (raw_inode->i_disk_version); +if (EXT4_INODE_SIZE (inode->i_sb) >EXT4_GOOD_OLD_INODE_SIZE ) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) + inode->i_version |= + (__u64)(le32_to_cpu (raw_inode->i_version_hi)) <<32 ; + } +if (S_ISREG (inode->i_mode)) { inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations;
@@ -2852,8 +2859,14 @@ static int ext4_do_update_inode(handle_t }else for (block =0 ; block <EXT4_N_BLOCKS ; block++) raw_inode->i_block[block] = ei->i_data[block]; -if (ei->i_extra_isize) + raw_inode->i_disk_version =cpu_to_le32 (inode->i_version); +if (ei->i_extra_isize) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) { + raw_inode->i_version_hi = +cpu_to_le32 (inode->i_version >>32 ); + } raw_inode->i_extra_isize =cpu_to_le16 (ei->i_extra_isize); + }BUFFER_TRACE (bh,"call ext4_journal_dirty_metadata" ); rc =ext4_journal_dirty_metadata (handle, bh);
include/linux/ext4_fs.h +3 -1
@@ -297,7 +297,7 @@ struct ext4_inode {__le32 i_flags;/* File flags */ union {struct { -__u32 l_i_reserved1; +__u32 l_i_version; } linux1;struct {__u32 h_i_translator;
@@ -406,6 +406,8 @@ do { \ raw_inode->xtime ## _extra); \ } while (0) +#define i_disk_version osd1.linux1.l_i_version +#if defined(__KERNEL__) || defined(__linux__)#define i_reserved1 osd1.linux1.l_i_reserved1#define i_frag osd2.linux2.l_i_frag
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:36 -0400 Mingming Cao <[email protected]> wrote:
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_hifield newly created in theext4_inode.
So reading the code here does serve to answer the question I raised against the earlier patch. A bit.
I'd have thought that this patch and the one which adds i_version_hi should be folded into a single diff?
Quoted 6 lines
Index:
linux-2.6.21/fs/ext4/inode.c
===================================================================
fs/ext4/inode.c void ext4_read_inode(struct inode * inod · line 2716
Quoted 8 lines
fs/ext4/inode.c +5
-0@@ -2709,6 +2709,13 @@ void ext4_read_inode(struct inode * inodEXT4_INODE_GET_XTIME (i_atime, inode, raw_inode);EXT4_EINODE_GET_XTIME (i_crtime, ei, raw_inode); + inode->i_version =le32_to_cpu (raw_inode->i_disk_version); +if (EXT4_INODE_SIZE (inode->i_sb) >EXT4_GOOD_OLD_INODE_SIZE ) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) + inode->i_version |= + (__u64)(le32_to_cpu (raw_inode->i_version_hi)) <<32 ;
<checks the precedence of "(type)" versus "<<">
<OK>
fs/ext4/inode.c void ext4_read_inode(struct inode * inod · line 2717
Quoted 1 line
fs/ext4/inode.c +1
-0+ }
I don't quite see how the above two tests are sufficient to unambiguously determine that the i_version_hi field is present on-disk.
I guess we're implicitly assuming that if the on-disk inode is big enough then it _must_ have i_version_hi in there? If so, why is the comparison with EXT4_GOOD_OLD_INODE_SIZE needed?
Some description of the overall approach to inode version identification would be helpful here.
fs/ext4/inode.c static int ext4_do_update_inode(handle_t · line 2864
Quoted 11 lines
fs/ext4/inode.c +3
-1if (S_ISREG (inode->i_mode)) { inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations;@@ -2852,8 +2859,14 @@ static int ext4_do_update_inode(handle_t }else for (block =0 ; block <EXT4_N_BLOCKS ; block++) raw_inode->i_block[block] = ei->i_data[block]; -if (ei->i_extra_isize) + raw_inode->i_disk_version =cpu_to_le32 (inode->i_version); +if (ei->i_extra_isize) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) {
There's no comparison with EXT4_GOOD_OLD_INODE_SIZE here...
Quoted 6 lines
fs/ext4/inode.c +4
-0+ raw_inode->i_version_hi = +cpu_to_le32 (inode->i_version >>32 ); + } raw_inode->i_extra_isize =cpu_to_le16 (ei->i_extra_isize); + }
Quoted 9 lines · Andrew Morton
Quoted 3 lines
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_hifield newly created in theext4_inode.So reading the code here does serve to answer the question I raised against the earlier patch. A bit.
I'd have thought that this patch and the one which adds
i_version_hishould be folded into a single diff?
It could be - the original patch to reserve i_version_hi was submitted to before the patches were ready to avoid that space being used by something else.
Quoted 9 lines
fs/ext4/inode.c void ext4_read_inode(struct inode * inod · line 2716
Quoted 4 lines
fs/ext4/inode.c +4
-0+if (EXT4_INODE_SIZE (inode->i_sb) >EXT4_GOOD_OLD_INODE_SIZE ) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) + inode->i_version |= + (__u64)(le32_to_cpu (raw_inode->i_version_hi)) <<32 ;<checks the precedence of "(type)" versus "<<">
<OK>
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }I don't quite see how the above two tests are sufficient to unambiguously determine that the
i_version_hifield is present on-disk.I guess we're implicitly assuming that if the on-disk inode is big enough then it _must_ have
i_version_hiin there? If so, why is the comparison withEXT4_GOOD_OLD_INODE_SIZEneeded?
The GOOT_OLD_INODE_SIZE check is needed to know if i_extra_isize is even present or valid in the on-disk inode.
Quoted 6 lines
fs/ext4/inode.c static int ext4_do_update_inode(handle_t · line 2861
Quoted 4 lines
fs/ext4/inode.c +3
-0@@ -2852,8 +2859,14 @@ static int ext4_do_update_inode(handle_t + raw_inode->i_disk_version =cpu_to_le32 (inode->i_version); +if (ei->i_extra_isize) { +if (EXT4_FITS_IN_INODE (raw_inode, ei, i_version_hi)) {There's no comparison with
EXT4_GOOD_OLD_INODE_SIZEhere...
Because this is the in-memory version and it is always valid (set to zero if there is extra space in the on-disk inode).
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.