From patchwork Tue Apr 15 16:40:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3993891 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 B6A15BFF02 for ; Tue, 15 Apr 2014 15:40:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A338C2022D for ; Tue, 15 Apr 2014 15:40:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA47520222 for ; Tue, 15 Apr 2014 15:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751920AbaDOPk2 (ORCPT ); Tue, 15 Apr 2014 11:40:28 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:45922 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232AbaDOPk1 (ORCPT ); Tue, 15 Apr 2014 11:40:27 -0400 Received: by mail-we0-f180.google.com with SMTP id p61so9503904wes.25 for ; Tue, 15 Apr 2014 08:40:26 -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; bh=zqsdP8QrQmfJwqBbZ1t32UUnmP1LbEq6OXpmOw0e01M=; b=JgKcMCgYzQslGNu+p5AAbc6ZlBwzF/05wHXcc2j7RWfg2qHWR1n7fGhsmo2WGsQ1+4 EbJCI3I3YKUmkgMFHyusjKxxBTmtCVvgylInyaYNmzini2IumaMa9M/gpv+3ebCP1zJq 6DoqhAWV2o3dJYuGttxmpIu7HifFlTwJ2ZAt+o/kozrXGuOLl04x0uGrNqrdYDDgO5vd ZzmeN0fTd9uR5EgN/EcmfhrPw48e/mnSdj/eiL7Vznnw92zTe6JfGC2F9Mamw5zL6+mf 56DTbImPReBuVglS9opZjKG6aQiFp/2A4q4zBvndwjh/b71BqY5drzhIQ+vqhGhDSwYR N6Kw== X-Received: by 10.194.88.230 with SMTP id bj6mr488611wjb.85.1397576426067; Tue, 15 Apr 2014 08:40:26 -0700 (PDT) Received: from debian-vm3.lan (bl10-141-238.dsl.telepac.pt. [85.243.141.238]) by mx.google.com with ESMTPSA id w6sm30193922wjq.29.2014.04.15.08.40.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Apr 2014 08:40:24 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 1/4] Btrfs: send, bump stream version Date: Tue, 15 Apr 2014 17:40:18 +0100 Message-Id: <1397580021-26598-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 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). Signed-off-by: Filipe David Borba Manana --- fs/btrfs/send.h | 13 ++++++++++++- include/uapi/linux/btrfs.h | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h index 48d425a..7b5df08 100644 --- a/fs/btrfs/send.h +++ b/fs/btrfs/send.h @@ -20,7 +20,7 @@ #include "ctree.h" #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) @@ -87,6 +87,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) @@ -125,10 +130,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 diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index b4d6909..444893d 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -464,10 +464,21 @@ struct btrfs_ioctl_received_subvol_args { */ #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4 +/* + * Calculate the amount (in bytes) of new file data between the send and + * parent snapshots, or in case of a full send, the total amount of file data + * we will send. + * This corresponds to the sum of the data lengths of each write, clone and + * fallocate commands that are sent through the send stream. The receiving end + * can use this information to compute progress. + */ +#define BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE 0x8 + #define BTRFS_SEND_FLAG_MASK \ (BTRFS_SEND_FLAG_NO_FILE_DATA | \ BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \ - BTRFS_SEND_FLAG_OMIT_END_CMD) + BTRFS_SEND_FLAG_OMIT_END_CMD | \ + BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE) struct btrfs_ioctl_send_args { __s64 send_fd; /* in */