From patchwork Wed Apr 16 14:54:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4001731 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7EF65BFF02 for ; Wed, 16 Apr 2014 13:54:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D73820306 for ; Wed, 16 Apr 2014 13:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0B8F20303 for ; Wed, 16 Apr 2014 13:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161137AbaDPNyI (ORCPT ); Wed, 16 Apr 2014 09:54:08 -0400 Received: from mail-we0-f176.google.com ([74.125.82.176]:54218 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161051AbaDPNyG (ORCPT ); Wed, 16 Apr 2014 09:54:06 -0400 Received: by mail-we0-f176.google.com with SMTP id x48so10965728wes.35 for ; Wed, 16 Apr 2014 06:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A5rAftuGlWQGDCEREiKdnIMC0BwHkLx2O/PPxPTW2g4=; b=uaK9v4qcKQ+NHBDBqDn+M20YtWl0aobyrOuqBNtDv6DfqV+KJSUqL/9uoXy9lzaG6K hmZEPpOL2C67WDS2UboPRaCi2xDOTC6naBBjsvIiGBaKvDyvAgvfVb1fuYANqgXQmiRS vjSCwW/QpuMjs1JWZ+HFi15ANXhchQ7DdPbxsyz3ie31F82rRY6kV6w7Nlj4tS7/uKyh mqseRcPemZsLAfv6OIAr6JCdapX+YcT3655oKEXU/EbAWzWyxQLmgWt4ImZk415QhGF+ MPe1b/eXodM7g+BgfyYE7JRTNEmsb5+4N4Xk5VBXeI2I9IT62EvvxgRXRp643wTqO91C BI/Q== X-Received: by 10.180.210.171 with SMTP id mv11mr7708181wic.44.1397656444817; Wed, 16 Apr 2014 06:54:04 -0700 (PDT) Received: from debian-vm3.lan (bl10-198-83.dsl.telepac.pt. [85.243.198.83]) by mx.google.com with ESMTPSA id fw13sm3083052wic.6.2014.04.16.06.54.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Apr 2014 06:54:04 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 1/4 v2] Btrfs-progs: send, bump stream version Date: Wed, 16 Apr 2014 15:54:38 +0100 Message-Id: <1397660078-7897-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1397580051-26643-1-git-send-email-fdmanana@gmail.com> References: <1397580051-26643-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This increases the send stream version from version 1 to version 2, adding 2 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. This is preparation work for subsequent changes that implement the new features (computing total data size and use fallocate for better performance). This doesn't break compatibility with older kernels or clients. In order to get a version 2 send stream, new flags must be passed to the send ioctl. Signed-off-by: Filipe David Borba Manana --- V2: Added new send ioctl flag BTRFS_SEND_FLAG_SUPPORT_FALLOCATE. A version 2 stream is now only produced is the ioctl caller specifies at least one of the new send flags (BTRFS_SEND_FLAG_SUPPORT_FALLOCATE or BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE). ioctl.h | 18 ++++++++++++++++++ send.h | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ioctl.h b/ioctl.h index 231660a..e2c506b 100644 --- a/ioctl.h +++ b/ioctl.h @@ -392,6 +392,24 @@ struct btrfs_ioctl_received_subvol_args { */ #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4 +/* + * The sum of all length fields the receiver will get in write, clone and + * fallocate commands. + * This can be used by the receiver to compute progress, at the expense of some + * initial metadata scan performed by the sender (kernel). + * + * Added in send stream version 2. + */ +#define BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE 0x8 + +/* + * Use fallocate command to pre-allocate file extents and punch file holes, + * instead of write commands with data buffers filled with 0 value bytes. + * + * Added in send stream version 2. + */ +#define BTRFS_SEND_FLAG_SUPPORT_FALLOCATE 0x10 + struct btrfs_ioctl_send_args { __s64 send_fd; /* in */ __u64 clone_sources_count; /* in */ diff --git a/send.h b/send.h index e8da785..69e81fb 100644 --- a/send.h +++ b/send.h @@ -24,7 +24,7 @@ extern "C" { #endif #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" -#define BTRFS_SEND_STREAM_VERSION 1 +#define BTRFS_SEND_STREAM_VERSION 2 #define BTRFS_SEND_BUF_SIZE (1024 * 64) #define BTRFS_SEND_READ_SIZE (1024 * 48) @@ -91,6 +91,11 @@ enum btrfs_send_cmd { BTRFS_SEND_C_END, BTRFS_SEND_C_UPDATE_EXTENT, + + /* added in stream version 2 */ + BTRFS_SEND_C_TOTAL_DATA_SIZE, + BTRFS_SEND_C_FALLOCATE, + __BTRFS_SEND_C_MAX, }; #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1) @@ -129,10 +134,16 @@ enum { BTRFS_SEND_A_CLONE_OFFSET, BTRFS_SEND_A_CLONE_LEN, + /* added in stream version 2 */ + BTRFS_SEND_A_FALLOCATE_FLAGS, + __BTRFS_SEND_A_MAX, }; #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1) +#define BTRFS_SEND_A_FALLOCATE_FLAG_KEEP_SIZE (1 << 0) +#define BTRFS_SEND_A_FALLOCATE_FLAG_PUNCH_HOLE (1 << 1) + #ifdef __KERNEL__ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg); #endif