diff options
author | Tao Ma <tao.ma@oracle.com> | 2009-08-17 23:47:56 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-22 23:09:49 -0400 |
commit | 0fe9b66c65f3ff227da45381afe7612f91e32740 (patch) | |
tree | 14d95c15065419825adb4f0f0a26a5416a64259e /fs/ocfs2/refcounttree.c | |
parent | bc13d347574fc0a8a666bc0f4cc2b635d202e372 (diff) |
ocfs2: Add preserve to reflink.
reflink has 2 options for the destination file:
1. snapshot: reflink will attempt to preserve ownership, permissions,
and all other security state in order to create a full snapshot.
2. new file: it will acquire the data extent sharing but will see the
file's security state and attributes initialized as a new file.
So add the option to ocfs2.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/refcounttree.c')
-rw-r--r-- | fs/ocfs2/refcounttree.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 47df8c5cd3c5..5d88e76f223a 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
@@ -3904,7 +3904,8 @@ out: | |||
3904 | static int ocfs2_complete_reflink(struct inode *s_inode, | 3904 | static int ocfs2_complete_reflink(struct inode *s_inode, |
3905 | struct buffer_head *s_bh, | 3905 | struct buffer_head *s_bh, |
3906 | struct inode *t_inode, | 3906 | struct inode *t_inode, |
3907 | struct buffer_head *t_bh) | 3907 | struct buffer_head *t_bh, |
3908 | bool preserve) | ||
3908 | { | 3909 | { |
3909 | int ret; | 3910 | int ret; |
3910 | handle_t *handle; | 3911 | handle_t *handle; |
@@ -3939,22 +3940,26 @@ static int ocfs2_complete_reflink(struct inode *s_inode, | |||
3939 | di->i_size = s_di->i_size; | 3940 | di->i_size = s_di->i_size; |
3940 | di->i_dyn_features = s_di->i_dyn_features; | 3941 | di->i_dyn_features = s_di->i_dyn_features; |
3941 | di->i_attr = s_di->i_attr; | 3942 | di->i_attr = s_di->i_attr; |
3942 | di->i_uid = s_di->i_uid; | ||
3943 | di->i_gid = s_di->i_gid; | ||
3944 | di->i_mode = s_di->i_mode; | ||
3945 | 3943 | ||
3946 | /* | 3944 | if (preserve) { |
3947 | * update time. | 3945 | di->i_uid = s_di->i_uid; |
3948 | * we want mtime to appear identical to the source and update ctime. | 3946 | di->i_gid = s_di->i_gid; |
3949 | */ | 3947 | di->i_mode = s_di->i_mode; |
3950 | t_inode->i_ctime = CURRENT_TIME; | 3948 | |
3949 | /* | ||
3950 | * update time. | ||
3951 | * we want mtime to appear identical to the source and | ||
3952 | * update ctime. | ||
3953 | */ | ||
3954 | t_inode->i_ctime = CURRENT_TIME; | ||
3951 | 3955 | ||
3952 | di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec); | 3956 | di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec); |
3953 | di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec); | 3957 | di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec); |
3954 | 3958 | ||
3955 | t_inode->i_mtime = s_inode->i_mtime; | 3959 | t_inode->i_mtime = s_inode->i_mtime; |
3956 | di->i_mtime = s_di->i_mtime; | 3960 | di->i_mtime = s_di->i_mtime; |
3957 | di->i_mtime_nsec = s_di->i_mtime_nsec; | 3961 | di->i_mtime_nsec = s_di->i_mtime_nsec; |
3962 | } | ||
3958 | 3963 | ||
3959 | ocfs2_journal_dirty(handle, t_bh); | 3964 | ocfs2_journal_dirty(handle, t_bh); |
3960 | 3965 | ||
@@ -3966,7 +3971,8 @@ out_commit: | |||
3966 | static int ocfs2_create_reflink_node(struct inode *s_inode, | 3971 | static int ocfs2_create_reflink_node(struct inode *s_inode, |
3967 | struct buffer_head *s_bh, | 3972 | struct buffer_head *s_bh, |
3968 | struct inode *t_inode, | 3973 | struct inode *t_inode, |
3969 | struct buffer_head *t_bh) | 3974 | struct buffer_head *t_bh, |
3975 | bool preserve) | ||
3970 | { | 3976 | { |
3971 | int ret; | 3977 | int ret; |
3972 | struct buffer_head *ref_root_bh = NULL; | 3978 | struct buffer_head *ref_root_bh = NULL; |
@@ -4001,7 +4007,7 @@ static int ocfs2_create_reflink_node(struct inode *s_inode, | |||
4001 | goto out_unlock_refcount; | 4007 | goto out_unlock_refcount; |
4002 | } | 4008 | } |
4003 | 4009 | ||
4004 | ret = ocfs2_complete_reflink(s_inode, s_bh, t_inode, t_bh); | 4010 | ret = ocfs2_complete_reflink(s_inode, s_bh, t_inode, t_bh, preserve); |
4005 | if (ret) | 4011 | if (ret) |
4006 | mlog_errno(ret); | 4012 | mlog_errno(ret); |
4007 | 4013 | ||