diff options
author | chandan r <chandanrmail@gmail.com> | 2012-07-04 03:18:07 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-02-02 21:39:16 -0500 |
commit | 9cc97d646216b6f2473fa4ab9f103514b86c6814 (patch) | |
tree | dae8cc90e44503e85ea05b9111ab9e96bdfdb16a /fs | |
parent | a937b9791ec2ee71d5e303d2c02c8c1ad8abff35 (diff) |
Btrfs: Add code to support file creation time
This patch adds a new member to the 'struct btrfs_inode' structure to hold
the file creation time.
Signed-off-by: chandan <chandanrmail@gmail.com>
[refreshed, removed btrfs_inode_otime]
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 3 | ||||
-rw-r--r-- | fs/btrfs/delayed-inode.c | 10 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 25 |
3 files changed, 36 insertions, 2 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 4aadadcfab20..de5e4f2adfea 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -185,6 +185,9 @@ struct btrfs_inode { | |||
185 | 185 | ||
186 | struct btrfs_delayed_node *delayed_node; | 186 | struct btrfs_delayed_node *delayed_node; |
187 | 187 | ||
188 | /* File creation time. */ | ||
189 | struct timespec i_otime; | ||
190 | |||
188 | struct inode vfs_inode; | 191 | struct inode vfs_inode; |
189 | }; | 192 | }; |
190 | 193 | ||
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 116eb4bed8d3..82f0c7c95474 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
@@ -1769,6 +1769,11 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans, | |||
1769 | inode->i_ctime.tv_sec); | 1769 | inode->i_ctime.tv_sec); |
1770 | btrfs_set_stack_timespec_nsec(&inode_item->ctime, | 1770 | btrfs_set_stack_timespec_nsec(&inode_item->ctime, |
1771 | inode->i_ctime.tv_nsec); | 1771 | inode->i_ctime.tv_nsec); |
1772 | |||
1773 | btrfs_set_stack_timespec_sec(&inode_item->otime, | ||
1774 | BTRFS_I(inode)->i_otime.tv_sec); | ||
1775 | btrfs_set_stack_timespec_nsec(&inode_item->otime, | ||
1776 | BTRFS_I(inode)->i_otime.tv_nsec); | ||
1772 | } | 1777 | } |
1773 | 1778 | ||
1774 | int btrfs_fill_inode(struct inode *inode, u32 *rdev) | 1779 | int btrfs_fill_inode(struct inode *inode, u32 *rdev) |
@@ -1810,6 +1815,11 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev) | |||
1810 | inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(&inode_item->ctime); | 1815 | inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(&inode_item->ctime); |
1811 | inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->ctime); | 1816 | inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->ctime); |
1812 | 1817 | ||
1818 | BTRFS_I(inode)->i_otime.tv_sec = | ||
1819 | btrfs_stack_timespec_sec(&inode_item->otime); | ||
1820 | BTRFS_I(inode)->i_otime.tv_nsec = | ||
1821 | btrfs_stack_timespec_nsec(&inode_item->otime); | ||
1822 | |||
1813 | inode->i_generation = BTRFS_I(inode)->generation; | 1823 | inode->i_generation = BTRFS_I(inode)->generation; |
1814 | BTRFS_I(inode)->index_cnt = (u64)-1; | 1824 | BTRFS_I(inode)->index_cnt = (u64)-1; |
1815 | 1825 | ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 575164d802af..b0292333fd84 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3535,6 +3535,11 @@ static void btrfs_read_locked_inode(struct inode *inode) | |||
3535 | inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->ctime); | 3535 | inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->ctime); |
3536 | inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->ctime); | 3536 | inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->ctime); |
3537 | 3537 | ||
3538 | BTRFS_I(inode)->i_otime.tv_sec = | ||
3539 | btrfs_timespec_sec(leaf, &inode_item->otime); | ||
3540 | BTRFS_I(inode)->i_otime.tv_nsec = | ||
3541 | btrfs_timespec_nsec(leaf, &inode_item->otime); | ||
3542 | |||
3538 | inode_set_bytes(inode, btrfs_inode_nbytes(leaf, inode_item)); | 3543 | inode_set_bytes(inode, btrfs_inode_nbytes(leaf, inode_item)); |
3539 | BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item); | 3544 | BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item); |
3540 | BTRFS_I(inode)->last_trans = btrfs_inode_transid(leaf, inode_item); | 3545 | BTRFS_I(inode)->last_trans = btrfs_inode_transid(leaf, inode_item); |
@@ -3669,6 +3674,11 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, | |||
3669 | btrfs_set_token_timespec_nsec(leaf, &item->ctime, | 3674 | btrfs_set_token_timespec_nsec(leaf, &item->ctime, |
3670 | inode->i_ctime.tv_nsec, &token); | 3675 | inode->i_ctime.tv_nsec, &token); |
3671 | 3676 | ||
3677 | btrfs_set_token_timespec_sec(leaf, &item->otime, | ||
3678 | BTRFS_I(inode)->i_otime.tv_sec, &token); | ||
3679 | btrfs_set_token_timespec_nsec(leaf, &item->otime, | ||
3680 | BTRFS_I(inode)->i_otime.tv_nsec, &token); | ||
3681 | |||
3672 | btrfs_set_token_inode_nbytes(leaf, item, inode_get_bytes(inode), | 3682 | btrfs_set_token_inode_nbytes(leaf, item, inode_get_bytes(inode), |
3673 | &token); | 3683 | &token); |
3674 | btrfs_set_token_inode_generation(leaf, item, BTRFS_I(inode)->generation, | 3684 | btrfs_set_token_inode_generation(leaf, item, BTRFS_I(inode)->generation, |
@@ -5260,7 +5270,10 @@ static struct inode *new_simple_dir(struct super_block *s, | |||
5260 | inode->i_op = &btrfs_dir_ro_inode_operations; | 5270 | inode->i_op = &btrfs_dir_ro_inode_operations; |
5261 | inode->i_fop = &simple_dir_operations; | 5271 | inode->i_fop = &simple_dir_operations; |
5262 | inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; | 5272 | inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; |
5263 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 5273 | inode->i_mtime = CURRENT_TIME; |
5274 | inode->i_atime = inode->i_mtime; | ||
5275 | inode->i_ctime = inode->i_mtime; | ||
5276 | BTRFS_I(inode)->i_otime = inode->i_mtime; | ||
5264 | 5277 | ||
5265 | return inode; | 5278 | return inode; |
5266 | } | 5279 | } |
@@ -5828,7 +5841,12 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
5828 | 5841 | ||
5829 | inode_init_owner(inode, dir, mode); | 5842 | inode_init_owner(inode, dir, mode); |
5830 | inode_set_bytes(inode, 0); | 5843 | inode_set_bytes(inode, 0); |
5831 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 5844 | |
5845 | inode->i_mtime = CURRENT_TIME; | ||
5846 | inode->i_atime = inode->i_mtime; | ||
5847 | inode->i_ctime = inode->i_mtime; | ||
5848 | BTRFS_I(inode)->i_otime = inode->i_mtime; | ||
5849 | |||
5832 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], | 5850 | inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], |
5833 | struct btrfs_inode_item); | 5851 | struct btrfs_inode_item); |
5834 | memset_extent_buffer(path->nodes[0], 0, (unsigned long)inode_item, | 5852 | memset_extent_buffer(path->nodes[0], 0, (unsigned long)inode_item, |
@@ -8577,6 +8595,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
8577 | 8595 | ||
8578 | ei->delayed_node = NULL; | 8596 | ei->delayed_node = NULL; |
8579 | 8597 | ||
8598 | ei->i_otime.tv_sec = 0; | ||
8599 | ei->i_otime.tv_nsec = 0; | ||
8600 | |||
8580 | inode = &ei->vfs_inode; | 8601 | inode = &ei->vfs_inode; |
8581 | extent_map_tree_init(&ei->extent_tree); | 8602 | extent_map_tree_init(&ei->extent_tree); |
8582 | extent_io_tree_init(&ei->io_tree, &inode->i_data); | 8603 | extent_io_tree_init(&ei->io_tree, &inode->i_data); |