From patchwork Wed Oct 12 08:12:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 9372225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E90A608A0 for ; Wed, 12 Oct 2016 08:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 812BD29D15 for ; Wed, 12 Oct 2016 08:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75DFA29D19; Wed, 12 Oct 2016 08:13:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 229F529D17 for ; Wed, 12 Oct 2016 08:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754616AbcJLINs (ORCPT ); Wed, 12 Oct 2016 04:13:48 -0400 Received: from synology.com ([59.124.61.242]:52714 "EHLO synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754466AbcJLINm (ORCPT ); Wed, 12 Oct 2016 04:13:42 -0400 Received: from localhost.localdomain (unknown [10.12.12.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robbieko@synology.com) by synology.com (Postfix) with ESMTPSA id 547261273505; Wed, 12 Oct 2016 16:13:19 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1476259999; bh=VZEcDG7yKXC4Q61DrSkHv3Lnr/qGi428jvw9KzyJXgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ex6SkSA+y2Eiml427hCNysBKn6tMBHodzhKsv98YfzvmdjnMKFvCA3/nT7ogL/EVw Wx+t2lJiUJW+W8pIpfyj+kVeHp+n/j2Y4q7w0LZ1CTCoQ+PSuTwRduT3eBPPlb7Rkh 8ekSJ+SqIE3tfZSDNlaVwixqToyoCIXFCIAfBtbM= From: robbieko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref Date: Wed, 12 Oct 2016 16:12:49 +0800 Message-Id: <1476259970-1866-5-git-send-email-robbieko@synology.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476259970-1866-1-git-send-email-robbieko@synology.com> References: <1476259970-1866-1-git-send-email-robbieko@synology.com> X-MailScanner-ID: 547261273505.A6EFE X-MailScanner: Found to be clean X-MailScanner-MCPCheck: MCP-Clean, MCP-Checker (score=0, required 80) X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, score=-0.09, required 4.5, ALL_TRUSTED -1.00, BAYES_50 0.80, DKIM_SIGNED 0.10, T_DKIM_INVALID 0.01) X-MailScanner-From: robbieko@synology.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Robbie Ko There a some case similar as before. add check parent generation in the did_overwrite_ref. Signed-off-by: Robbie Ko --- fs/btrfs/send.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d908624..e090db2 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1939,6 +1939,19 @@ static int did_overwrite_ref(struct send_ctx *sctx, if (ret <= 0) goto out; + if (dir != BTRFS_FIRST_FREE_OBJECTID) { + ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL, + NULL, NULL, NULL); + if (ret < 0 && ret != -ENOENT) + goto out; + if (ret) { + ret = 0; + goto out; + } + if (gen != dir_gen) + goto out; + } + /* check if the ref was overwritten by another ref */ ret = lookup_dir_item_inode(sctx->send_root, dir, name, name_len, &ow_inode, &other_type);