btrfs: add "no file data" flag to btrfs send ioctl
PATCH RESEND 1/1 btrfs: add "no file data" flag to btrfs send ioctl
This patch adds the flag, BTRFS_SEND_FLAG_NO_FILE_DATA to the btrfs send ioctl code. When this flag is set, the btrfs send code will never write file data into the stream (thus also avoiding expensive reads of that data in the first place). BTRFS_SEND_C_UPDATE_EXTENT commands will be sent (instead of BTRFS_SEND_C_WRITE) with an offset, length pair indicating the extent in question.
This patch does not affect the operation of BTRFS_SEND_C_CLONE commands - they will continue to be sent when a search finds an appropriate extent to clone from.
--- fs/btrfs/ioctl.h | 7 +++++++ fs/btrfs/send.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- fs/btrfs/send.h | 1 + 3 files changed, 52 insertions(+), 4 deletions(-)
fs/btrfs/ioctl.h +7 -0
@@ -363,6 +363,13 @@ struct btrfs_ioctl_received_subvol_args {__u64 reserved[16 ];/* in */ }; +/* +* Caller doesn't want file data in the send stream, even if the +* search of clone sources doesn't find an extent. UPDATE_EXTENT +* commands will be sent instead of WRITE commands. +*/ +#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 +struct btrfs_ioctl_send_args {__s64 send_fd;/* in */ __u64 clone_sources_count;/* in */
fs/btrfs/send.c +44 -4
79 lines not on this page · raw message
fs/btrfs/send.h +1 -0
@@ -86,6 +86,7 @@ enum btrfs_send_cmd {BTRFS_SEND_C_UTIMES ,BTRFS_SEND_C_END , +BTRFS_SEND_C_UPDATE_EXTENT , __BTRFS_SEND_C_MAX, };#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
Signature · 1 line
1.7.10.4
fs/btrfs/send.c long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) · line 4609
Quoted 6 lines · Mark Fasheh
fs/btrfs/send.c +2
-0@@ -4570,6 +4605,11 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)INIT_RADIX_TREE (&sctx->name_cache,GFP_NOFS );INIT_LIST_HEAD (&sctx->name_cache_list); +if (arg->flags & ~BTRFS_SEND_FLAG_NO_FILE_DATA ) +return -EINVAL ;
Doing just return skips the cleanup block (goto out;), also the test can be placed just after the access_ok() call and skip allocation and init of sctx.
Quoted 6 lines
fs/btrfs/send.c +3
-0+ + sctx->flags = arg->flags; + sctx->send_filp =fget (arg->send_fd);if (IS_ERR (sctx->send_filp)) { ret =PTR_ERR (sctx->send_filp);
Quoted 11 lines · David Sterba
Review long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) · line 4609
Quoted 6 lines · Mark Fasheh
(quoted diff) +2
-0@@ -4570,6 +4605,11 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) INIT_RADIX_TREE(&sctx->name_cache, GFP_NOFS); INIT_LIST_HEAD(&sctx->name_cache_list); + if (arg->flags & ~BTRFS_SEND_FLAG_NO_FILE_DATA) + return -EINVAL;Doing just return skips the cleanup block (goto out;), also the test can be placed just after the
access_ok()call and skip allocation and init of sctx.
Ahh, good catch. Sad I missed that one :( A corrected patch is below.
--Mark
--
Mark Fasheh
From: Mark Fasheh <[email protected]>
[PATCH] btrfs: add "no file data" flag to btrfs send ioctl
This patch adds the flag, BTRFS_SEND_FLAG_NO_FILE_DATA to the btrfs send ioctl code. When this flag is set, the btrfs send code will never write file data into the stream (thus also avoiding expensive reads of that data in the first place). BTRFS_SEND_C_UPDATE_EXTENT commands will be sent (instead of BTRFS_SEND_C_WRITE) with an offset, length pair indicating the extent in question.
This patch does not affect the operation of BTRFS_SEND_C_CLONE commands - they will continue to be sent when a search finds an appropriate extent to clone from.
--- fs/btrfs/ioctl.h | 7 +++++++ fs/btrfs/send.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- fs/btrfs/send.h | 1 + 3 files changed, 54 insertions(+), 4 deletions(-)
fs/btrfs/ioctl.h +7 -0
@@ -363,6 +363,13 @@ struct btrfs_ioctl_received_subvol_args {__u64 reserved[16 ];/* in */ }; +/* +* Caller doesn't want file data in the send stream, even if the +* search of clone sources doesn't find an extent. UPDATE_EXTENT +* commands will be sent instead of WRITE commands. +*/ +#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 +struct btrfs_ioctl_send_args {__s64 send_fd;/* in */ __u64 clone_sources_count;/* in */
fs/btrfs/send.c +46 -4
87 lines not on this page · raw message
fs/btrfs/send.h +1 -0
@@ -86,6 +86,7 @@ enum btrfs_send_cmd {BTRFS_SEND_C_UTIMES ,BTRFS_SEND_C_END , +BTRFS_SEND_C_UPDATE_EXTENT , __BTRFS_SEND_C_MAX, };#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
Signature · 1 line
1.7.10.4