From patchwork Mon Jun 22 09:08:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 6654351 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 1055C9F1C1 for ; Mon, 22 Jun 2015 09:11:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7248D2062F for ; Mon, 22 Jun 2015 09:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9CC22062D for ; Mon, 22 Jun 2015 09:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932274AbbFVJJA (ORCPT ); Mon, 22 Jun 2015 05:09:00 -0400 Received: from mail.synology.com ([59.124.41.242]:5955 "EHLO mail.synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbbFVJI7 (ORCPT ); Mon, 22 Jun 2015 05:08:59 -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 6FB502B31411; Mon, 22 Jun 2015 17:08:58 +0800 (CST) From: Robbie Ko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH v2 4/7] Btrfs: incremental send, fix orphan_dir_info leak Date: Mon, 22 Jun 2015 17:08:45 +0800 Message-Id: <1434964128-31757-5-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: 6FB502B31411.A7E5B X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (cached, score=2.757, required 8, ALL_TRUSTED -1.00, AWL 1.06, 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 leak a orphan_dir_info structure. 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) Freeing an existing orphan_dir_info for a directory, when we realize we can't rmdir the directory because it has a descendant that wasn't yet processed, and the orphan_dir_info was created because it had a descendant that had its rename operation delayed. Signed-off-by: Robbie Ko --- V2: modify comment fs/btrfs/send.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index b946067..bc9efbe 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -2913,6 +2913,11 @@ 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; }