From patchwork Thu Jun 4 11:18:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 6546031 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 C37309F1CC for ; Thu, 4 Jun 2015 11:28:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E558B205CB for ; Thu, 4 Jun 2015 11:28:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13A3D204CF for ; Thu, 4 Jun 2015 11:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753000AbbFDL14 (ORCPT ); Thu, 4 Jun 2015 07:27:56 -0400 Received: from mail.synology.com ([59.124.41.242]:58398 "EHLO mail.synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752335AbbFDL1y (ORCPT ); Thu, 4 Jun 2015 07:27:54 -0400 X-Greylist: delayed 571 seconds by postgrey-1.27 at vger.kernel.org; Thu, 04 Jun 2015 07:27:54 EDT 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 830C21DE6923; Thu, 4 Jun 2015 19:18:18 +0800 (CST) From: Robbie Ko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH 3/5] Btrfs: incremental send, fix orphan_dir_info not completely cleared Date: Thu, 4 Jun 2015 19:18:08 +0800 Message-Id: <1433416690-19177-4-git-send-email-robbieko@synology.com> In-Reply-To: <1433416690-19177-1-git-send-email-robbieko@synology.com> References: <1433416690-19177-1-git-send-email-robbieko@synology.com> X-MailScanner-ID: 830C21DE6923.A7FF2 X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (cached, score=1.821, required 8, ALL_TRUSTED -1.00, AWL 2.02, BAYES_00 -1.90, DNS_FROM_AHBL_RHSBL 2.70, URIBL_BLOCKED 0.00) X-MailScanner-From: robbieko@synology.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 not clear orphan_dir_info issue. Example: Parent snapshot: |---- a/ (ino 279) |---- c (ino 282) |---- del/ (ino 281) |---- tmp/ (ino 280) |---- long/ (ino 283) |---- longlong/ (ino 284) Send snapshot: |---- a/ (ino 279) |---- long (ino 283) |---- longlong (ino 284) |---- c/ (ino 282) |---- tmp/ (ino 280) Here we process 281 use can_rmdir check, but 280 is waiting, so create orphan_dir_info and when 282 is move to dest, so 280 can move to c/tmp, and now run can_rmdir check again. Return is false, because 283 and 284 is unprocess, but now not release orphan_dir_info. When 283 and 284 is processd, 281 be delete, but not delete orphan_dir_info. So fix this by release orphan_dir_info for this case. Signed-off-by: Robbie Ko --- fs/btrfs/send.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 596b9dc..ff9d052 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -2785,12 +2785,6 @@ add_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino) struct rb_node *parent = NULL; struct orphan_dir_info *entry, *odi; - odi = kmalloc(sizeof(*odi), GFP_NOFS); - if (!odi) - return ERR_PTR(-ENOMEM); - odi->ino = dir_ino; - odi->gen = 0; - while (*p) { parent = *p; entry = rb_entry(parent, struct orphan_dir_info, node); @@ -2799,11 +2793,16 @@ add_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino) } else if (dir_ino > entry->ino) { p = &(*p)->rb_right; } else { - kfree(odi); return entry; } } + odi = kmalloc(sizeof(*odi), GFP_NOFS); + if (!odi) + return ERR_PTR(-ENOMEM); + odi->ino = dir_ino; + odi->gen = 0; + rb_link_node(&odi->node, parent, p); rb_insert_color(&odi->node, &sctx->orphan_dirs); return odi; @@ -2913,6 +2912,12 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen, } if (loc.objectid > send_progress) { + struct orphan_dir_info *odi; + + odi = get_orphan_dir_info(sctx, dir); + if (odi) { + free_orphan_dir_info(sctx, odi); + } ret = 0; goto out; }