linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Howard McLauchlan <linux@hmclauchlan.com>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <clm@fb.com>,
	Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>,
	Filipe Manana <fdmanana@suse.com>,
	Filipe David Borba Manana <fdmanana@gmail.com>,
	Howard McLauchlan <hmclauchlan@fb.com>
Subject: Re: [RFC PATCH 1/6] btrfs: send, bump stream version
Date: Wed, 16 May 2018 11:25:45 -0700	[thread overview]
Message-ID: <20180516182545.GB29231@vader> (raw)
In-Reply-To: <20180509020651.7946-2-linux@hmclauchlan.com>

On Tue, May 08, 2018 at 10:06:46PM -0400, Howard McLauchlan wrote:
> From: Filipe David Borba Manana <fdmanana@gmail.com>
> 
> This increases the send stream version from version 1 to version 2, adding
> new commands:
> 
> 1) total data size - used to tell the receiver how much file data the stream
>    will add or update;
> 
> 2) fallocate - used to pre-allocate space for files and to punch holes in files;
> 
> 3) inode set flags;
> 
> 4) set inode otime.
> 
> This is preparation work for subsequent changes that implement the new features.
> 
> A version 2 stream is only produced if the send ioctl caller passes in one of the
> new flags (BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE | BTRFS_SEND_FLAG_STREAM_V2), meaning
> old clients are unaffected.
> 
> [Howard: rebased on 4.17-rc4]
> Signed-off-by: Howard McLauchlan <hmclauchlan@fb.com>
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> ---
>  fs/btrfs/send.c            |  7 ++++++-
>  fs/btrfs/send.h            | 21 ++++++++++++++++++++-
>  include/uapi/linux/btrfs.h | 21 ++++++++++++++++++++-
>  3 files changed, 46 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index c0074d2d7d6d..eccd69387065 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -649,7 +649,10 @@ static int send_header(struct send_ctx *sctx)
>  	struct btrfs_stream_header hdr;
>  
>  	strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
> -	hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);
> +	if (sctx->flags & BTRFS_SEND_FLAG_STREAM_V2)
> +		hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION_2);
> +	else
> +		hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION_1);
>  
>  	return write_buf(sctx->send_filp, &hdr, sizeof(hdr),
>  					&sctx->send_off);
> @@ -6535,6 +6538,8 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
>  	INIT_LIST_HEAD(&sctx->name_cache_list);
>  
>  	sctx->flags = arg->flags;
> +	if (sctx->flags & BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE)
> +		sctx->flags |= BTRFS_SEND_FLAG_STREAM_V2;
>  
>  	sctx->send_filp = fget(arg->send_fd);
>  	if (!sctx->send_filp) {
> diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
> index ead397f7034f..a9b5489d690e 100644
> --- a/fs/btrfs/send.h
> +++ b/fs/btrfs/send.h
> @@ -10,7 +10,8 @@
>  #include "ctree.h"
>  
>  #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
> -#define BTRFS_SEND_STREAM_VERSION 1
> +#define BTRFS_SEND_STREAM_VERSION_1 1
> +#define BTRFS_SEND_STREAM_VERSION_2 2
>  
>  #define BTRFS_SEND_BUF_SIZE SZ_64K
>  #define BTRFS_SEND_READ_SIZE (48 * SZ_1K)
> @@ -77,6 +78,15 @@ enum btrfs_send_cmd {
>  
>  	BTRFS_SEND_C_END,
>  	BTRFS_SEND_C_UPDATE_EXTENT,
> +
> +	/*
> +	 * The following commands were added in stream version 2.
> +	 */
> +	BTRFS_SEND_C_TOTAL_DATA_SIZE,
> +	BTRFS_SEND_C_FALLOCATE,
> +	BTRFS_SEND_C_INODE_SET_FLAGS,
> +	BTRFS_SEND_C_UTIMES2, /* Same as UTIMES, but it includes OTIME too. */

I've had feature requests for the ability to send compressed data
without decompressing it on the send side or the receive side. Could you
add a placeholder BTRFS_SEND_C_WRITE_COMPRESSED here? This way when I
get around to implementing it I won't have to do a v3.

Other than that,

Reviewed-by: Omar Sandoval <osandov@fb.com>

  reply	other threads:[~2018-05-16 18:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09  2:06 [RFC PATCH 0/6] btrfs send stream version 2 Howard McLauchlan
2018-05-09  2:06 ` [RFC PATCH 1/6] btrfs: send, bump stream version Howard McLauchlan
2018-05-16 18:25   ` Omar Sandoval [this message]
2018-05-09  2:06 ` [RFC PATCH 2/6] btrfs: send, implement total data size command to allow for progress estimation Howard McLauchlan
2018-05-09  2:06 ` [RFC PATCH 3/6] btrfs: send, use fallocate command to punch holes Howard McLauchlan
2018-05-09  2:06 ` [RFC PATCH 4/6] btrfs: send, use fallocate command to allocate extents Howard McLauchlan
2018-05-09  2:06 ` [RFC PATCH 5/6] btrfs: add send_stream_version attribute to sysfs Howard McLauchlan
2018-05-16 19:04   ` Omar Sandoval
2018-05-09  2:06 ` [RFC PATCH 6/6] btrfs: add chattr support for send/receive Howard McLauchlan
2018-05-16 18:59   ` Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180516182545.GB29231@vader \
    --to=osandov@osandov.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@gmail.com \
    --cc=fdmanana@suse.com \
    --cc=hmclauchlan@fb.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux@hmclauchlan.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).