ocfs2: Add reflink file support. V5
cover ocfs2: Add reflink file support. V5
Hi all,
As reflink system call may not be merged into .32, I re-generate the
patch set and now it only uses ioctl to reflink a file.
Most patches are unmodified, the big change exists in the last one. So I only send it out for review.
[View]
http://oss.oracle.com/git/?p=tma/linux-2.6.git;a=shortlog;h=refcount_no_sysctl
[Pull]git://oss.oracle.com/git/tma/linux-2.6.git refcount_no_sysctl.
Regards,
Tao
PATCH 42/42 ocfs2: Add ioctl for reflink.
The ioctl will take 3 parameters: old_path, new_path and preserve and call vfs_reflink. It is useful when we backport reflink features to old kernels.
Signed-off-by Tao Ma <[email protected]>
--- fs/ocfs2/ioctl.c | 14 ++++ fs/ocfs2/ocfs2_fs.h | 9 +++ fs/ocfs2/refcounttree.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++ fs/ocfs2/refcounttree.h | 4 + 4 files changed, 193 insertions(+), 0 deletions(-)
fs/ocfs2/ioctl.c +14 -0
@@ -22,6 +22,7 @@#include "ocfs2_fs.h" #include "ioctl.h" #include "resize.h" +#include "refcounttree.h" #include <linux/ext2_fs.h>
@@ -116,6 +117,9 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)int status;struct ocfs2_space_resv sr;struct ocfs2_new_group_input input; +struct reflink_arguments args; +const char *old_path, *new_path; +bool preserve;switch (cmd) {case OCFS2_IOC_GETFLAGS :
@@ -161,6 +165,15 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)return -EFAULT ;return ocfs2_group_add (inode, &input); +case OCFS2_IOC_REFLINK : +if (copy_from_user (&args, (struct reflink_arguments *)arg, +sizeof (args))) +return -EFAULT ; + old_path = (const char *)(unsigned long )args.old_path; + new_path = (const char *)(unsigned long )args.new_path; + preserve = (args.preserve !=0 ); + +return ocfs2_reflink_ioctl (inode, old_path, new_path, preserve);default :return -ENOTTY ; }
@@ -183,6 +196,7 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)case OCFS2_IOC_GROUP_EXTEND :case OCFS2_IOC_GROUP_ADD :case OCFS2_IOC_GROUP_ADD64 : +case OCFS2_IOC_REFLINK :break ;default :return -ENOIOCTLCMD ;
fs/ocfs2/ocfs2_fs.h +9 -0
@@ -301,6 +301,15 @@ struct ocfs2_new_group_input {#define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)#define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input) +/* Used to pass 2 file names to reflink. */ +struct reflink_arguments { +__u64 old_path; +__u64 new_path; +__u64 preserve; +}; +#define OCFS2_IOC_REFLINK _IOW('o', 4, struct reflink_arguments) + +/* * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) */
fs/ocfs2/refcounttree.c +166 -0
175 lines not on this page · raw message
fs/ocfs2/refcounttree.h +4 -0
@@ -99,4 +99,8 @@ int ocfs2_increase_refcount(handle_t *handle, u64 cpos, u32 len, struct ocfs2_alloc_context *meta_ac, struct ocfs2_cached_dealloc_ctxt *dealloc); +int ocfs2_reflink_ioctl (struct inode *inode, +const char __user *oldname, +const char __user *newname, +bool preserve);#endif /* OCFS2_REFCOUNTTREE_H */
Signature · 1 line
1.6.2.rc2.16.gf474c