From patchwork Mon Jun 22 09:08:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 6654371 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5EACF9F1C1 for ; Mon, 22 Jun 2015 09:12:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4D0F2062D for ; Mon, 22 Jun 2015 09:12:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01FAF205FE for ; Mon, 22 Jun 2015 09:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932929AbbFVJKS (ORCPT ); Mon, 22 Jun 2015 05:10:18 -0400 Received: from mail.synology.com ([59.124.41.242]:13788 "EHLO mail.synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754347AbbFVJJA (ORCPT ); Mon, 22 Jun 2015 05:09:00 -0400 Received: from localhost.localdomain (unknown [192.168.0.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robbieko@synology.com) by mail.synology.com (Postfix) with ESMTPSA id E9C9D2B31416; Mon, 22 Jun 2015 17:08:58 +0800 (CST) From: Robbie Ko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH v2 5/7] Btrfs: incremental send, fix rmdir but dir have a unprocess item Date: Mon, 22 Jun 2015 17:08:46 +0800 Message-Id: <1434964128-31757-6-git-send-email-robbieko@synology.com> In-Reply-To: <1434964128-31757-1-git-send-email-robbieko@synology.com> References: <1434964128-31757-1-git-send-email-robbieko@synology.com> X-MailScanner-ID: E9C9D2B31416.A8BD1 X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (cached, score=2.749, required 8, ALL_TRUSTED -1.00, AWL 1.05, BAYES_40 -0.00, DNS_FROM_AHBL_RHSBL 2.70, URIBL_BLOCKED 0.00) X-MailScanner-From: robbieko@synology.com X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's one case where we attempt to rmdir a directory prematurely. Example: Parent snapshot: |---- a/ (ino 279) |---- c (ino 282) |---- del/ (ino 281) |---- tmp/ (ino 280) |---- long/ (ino 283) Send snapshot: |---- a/ (ino 279) |---- long (ino 283) |---- c/ (ino 282) |---- tmp/ (ino 280) While process inode 281, since inode 280 is waiting for inode 282, rmdir_ino of struct waitng_dir_move for inode 280 will assigned to 281 and an orphan_dir_info will be created for node 281 in can_rmdir(). Such that, when process inode 282, we will do following steps. First, move inode 282 from a/c to c Second, move inode 280 from del/tmp to c/tmp Third, try to remove inode 281 In Third step, we pass 283 (sctx->cur_ino + 1) as the send_progress to the can_rmdir() function and that makes it return true when it shouldn't, because the inode 283 wasn't processed yet and it's still a child of the directory with inode number 281, which makes the receiver run into an ENOTEMPTY error when attempting to remove the directory. Signed-off-by: Robbie Ko --- V2:modify comment fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index bc9efbe..cd22f7d 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3213,7 +3213,7 @@ static int apply_dir_move(struct send_ctx *sctx, struct pending_dir_move *pm) /* already deleted */ goto finish; } - ret = can_rmdir(sctx, rmdir_ino, odi->gen, sctx->cur_ino + 1); + ret = can_rmdir(sctx, rmdir_ino, odi->gen, sctx->cur_ino); if (ret < 0) goto out; if (!ret)