summaryrefslogtreecommitdiff
path: root/fs/ocfs2/refcounttree.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2009-08-18 11:47:56 +0800
committerJoel Becker <joel.becker@oracle.com>2009-09-22 20:09:49 -0700
commit0fe9b66c65f3ff227da45381afe7612f91e32740 (patch)
tree14d95c15065419825adb4f0f0a26a5416a64259e /fs/ocfs2/refcounttree.c
parentbc13d347574fc0a8a666bc0f4cc2b635d202e372 (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.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 47df8c5cd3c..5d88e76f223 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3904,7 +3904,8 @@ out:
static int ocfs2_complete_reflink(struct inode *s_inode,
struct buffer_head *s_bh,
struct inode *t_inode,
- struct buffer_head *t_bh)
+ struct buffer_head *t_bh,
+ bool preserve)
{
int ret;
handle_t *handle;
@@ -3939,22 +3940,26 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
di->i_size = s_di->i_size;
di->i_dyn_features = s_di->i_dyn_features;
di->i_attr = s_di->i_attr;
- di->i_uid = s_di->i_uid;
- di->i_gid = s_di->i_gid;
- di->i_mode = s_di->i_mode;
- /*
- * update time.
- * we want mtime to appear identical to the source and update ctime.
- */
- t_inode->i_ctime = CURRENT_TIME;
+ if (preserve) {
+ di->i_uid = s_di->i_uid;
+ di->i_gid = s_di->i_gid;
+ di->i_mode = s_di->i_mode;
+
+ /*
+ * update time.
+ * we want mtime to appear identical to the source and
+ * update ctime.
+ */
+ t_inode->i_ctime = CURRENT_TIME;
- di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
- di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
+ di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
+ di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
- t_inode->i_mtime = s_inode->i_mtime;
- di->i_mtime = s_di->i_mtime;
- di->i_mtime_nsec = s_di->i_mtime_nsec;
+ t_inode->i_mtime = s_inode->i_mtime;
+ di->i_mtime = s_di->i_mtime;
+ di->i_mtime_nsec = s_di->i_mtime_nsec;
+ }
ocfs2_journal_dirty(handle, t_bh);
@@ -3966,7 +3971,8 @@ out_commit:
static int ocfs2_create_reflink_node(struct inode *s_inode,
struct buffer_head *s_bh,
struct inode *t_inode,
- struct buffer_head *t_bh)
+ struct buffer_head *t_bh,
+ bool preserve)
{
int ret;
struct buffer_head *ref_root_bh = NULL;
@@ -4001,7 +4007,7 @@ static int ocfs2_create_reflink_node(struct inode *s_inode,
goto out_unlock_refcount;
}
- ret = ocfs2_complete_reflink(s_inode, s_bh, t_inode, t_bh);
+ ret = ocfs2_complete_reflink(s_inode, s_bh, t_inode, t_bh, preserve);
if (ret)
mlog_errno(ret);