From patchwork Sun May 25 03:49:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4238181 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 3845ABF90B for ; Sun, 25 May 2014 02:56:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3381C20173 for ; Sun, 25 May 2014 02:56:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02C1320165 for ; Sun, 25 May 2014 02:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbaEYCu3 (ORCPT ); Sat, 24 May 2014 22:50:29 -0400 Received: from mail-we0-f177.google.com ([74.125.82.177]:47829 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751322AbaEYCu2 (ORCPT ); Sat, 24 May 2014 22:50:28 -0400 Received: by mail-we0-f177.google.com with SMTP id x48so6289418wes.8 for ; Sat, 24 May 2014 19:50: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:in-reply-to:references; bh=wXGO/PnSnIQLbXhNhSMbg3OWCPnBicZvO79Ytyz0XcQ=; b=XQwKD29rG9e2GlKiWd9f0+2j5c57vTmMzopCgy5JITena1kl35NqK3QMAo8DG+Inc7 6TiSO65dsfTfSOt4zPDfD27hnoXjIEoQb3E9/QtjElPDxk7p5f6uQXEcnCO3HpGktXN1 orkZ2QqoeyM1iT6Iw7JtDdSPRWlOfFe2fIM50ga2Nrw3vBQ44Tx4dxyza2pwOhOgTOgY NlfKQ5y73xIdPjBZVGL5s1L5mBroV/iSrJcGRnG7lXB0DdNHJalHJfq23IAd9kpjd604 sivdqmSWlE6Crr7ETp8JZiGhze3z12roalOiRoCbNaVTdYZHhxXbpjnXNaMq9bI7Mzp6 ntow== X-Received: by 10.194.8.200 with SMTP id t8mr9406226wja.19.1400986226749; Sat, 24 May 2014 19:50:26 -0700 (PDT) Received: from debian-vm3.lan (bl10-252-12.dsl.telepac.pt. [85.243.252.12]) by mx.google.com with ESMTPSA id wk8sm14963072wjb.22.2014.05.24.19.50.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 May 2014 19:50:25 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH v2] Btrfs: send, don't error in the presence of subvols/snapshots Date: Sun, 25 May 2014 04:49:24 +0100 Message-Id: <1400989764-2478-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400985786-16240-1-git-send-email-fdmanana@gmail.com> References: <1400985786-16240-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 If we are doing an incremental send and the base snapshot has a directory with name X that doesn't exist anymore in the second snapshot and a new subvolume/snapshot exists in the second snapshot that has the same name as the directory (name X), the incremental send would fail with -ENOENT error. This is because it attempts to lookup for an inode with a number matching the objectid of a root, which doesn't exist. Steps to reproduce: mkfs.btrfs -f /dev/sdd mount /dev/sdd /mnt mkdir /mnt/testdir btrfs subvolume snapshot -r /mnt /mnt/mysnap1 rmdir /mnt/testdir btrfs subvolume create /mnt/testdir btrfs subvolume snapshot -r /mnt /mnt/mysnap2 btrfs send -p /mnt/mysnap1 /mnt/mysnap2 -f /tmp/send.data A test case for xfstests follows. Reported-by: Robert White Signed-off-by: Filipe David Borba Manana --- V2: Simpler version. fs/btrfs/send.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 1a65a40..2722b26 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1664,6 +1664,10 @@ static int lookup_dir_item_inode(struct btrfs_root *root, goto out; } btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key); + if (key.type == BTRFS_ROOT_ITEM_KEY) { + ret = -ENOENT; + goto out; + } *found_inode = key.objectid; *found_type = btrfs_dir_type(path->nodes[0], di);