From patchwork Wed Oct 12 08:12:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 9372223 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 76F5060865 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 68D3329D15 for ; Wed, 12 Oct 2016 08:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D2E429D1B; 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 F301629D16 for ; Wed, 12 Oct 2016 08:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754578AbcJLINq (ORCPT ); Wed, 12 Oct 2016 04:13:46 -0400 Received: from synology.com ([59.124.61.242]:52716 "EHLO synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754591AbcJLINm (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 CEDA71273674; Wed, 12 Oct 2016 16:13:18 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1476259998; bh=2G08lu2urG4WCOP82lhGCXTzT9oUZXEjCUGCT5wtsPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RMxb/i8vjwxCCrIshf6CuVHRD0uO3/wfvxxdrqsoSGLpKmmWFazcDS2FdlaPew8e9 Uvjf7KSH+AT/GMkH0fOwSIp/0zHvAYqtyJizEOD/1aGEA3XtYE10/8pWxeRcJE5TIF Sq2Vrqy98rNcDZ3gOrkPBXh95Ka2LkAYxBTb4fjA= From: robbieko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for some corner case Date: Wed, 12 Oct 2016 16:12:48 +0800 Message-Id: <1476259970-1866-4-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: CEDA71273674.AB3C0 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 compare generation with dir items, and waiting_dir_move in the can_rmdir. Signed-off-by: Robbie Ko --- fs/btrfs/send.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 95d3718..d908624 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -237,6 +237,7 @@ struct pending_dir_move { struct waiting_dir_move { struct rb_node node; u64 ino; + u64 gen; /* * There might be some directory that could not be removed because it * was waiting for this directory inode to be moved first. Therefore @@ -2931,6 +2932,7 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen, struct btrfs_key found_key; struct btrfs_key loc; struct btrfs_dir_item *di; + u64 gen; /* * Don't try to rmdir the top/root subvolume dir. @@ -2970,8 +2972,13 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen, struct btrfs_dir_item); btrfs_dir_item_key_to_cpu(path->nodes[0], di, &loc); + ret = get_inode_info(root, loc.objectid, NULL, &gen, NULL, + NULL, NULL, NULL); + if (ret < 0) + goto out; + dm = get_waiting_dir_move(sctx, loc.objectid); - if (dm) { + if (dm && dm->gen == gen) { struct orphan_dir_info *odi; odi = add_orphan_dir_info(sctx, dir); @@ -3011,7 +3018,7 @@ static int is_waiting_for_move(struct send_ctx *sctx, u64 ino) return entry != NULL; } -static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized) +static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, u64 gen, bool orphanized) { struct rb_node **p = &sctx->waiting_dir_moves.rb_node; struct rb_node *parent = NULL; @@ -3021,6 +3028,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized) if (!dm) return -ENOMEM; dm->ino = ino; + dm->gen = gen; dm->rmdir_ino = 0; dm->orphanized = orphanized; @@ -3118,7 +3126,7 @@ static int add_pending_dir_move(struct send_ctx *sctx, goto out; } - ret = add_waiting_dir_move(sctx, pm->ino, is_orphan); + ret = add_waiting_dir_move(sctx, pm->ino, pm->gen, is_orphan); if (ret) goto out;