From patchwork Fri Oct 7 02:01:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: robbieko X-Patchwork-Id: 9365575 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 EC9006075E for ; Fri, 7 Oct 2016 02:07:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5CE2292A9 for ; Fri, 7 Oct 2016 02:07:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2BB3292AB; Fri, 7 Oct 2016 02:07:15 +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 99C14292A9 for ; Fri, 7 Oct 2016 02:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938591AbcJGCHL (ORCPT ); Thu, 6 Oct 2016 22:07:11 -0400 Received: from synology.com ([59.124.61.242]:46598 "EHLO synology.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934855AbcJGCHK (ORCPT ); Thu, 6 Oct 2016 22:07:10 -0400 X-Greylist: delayed 313 seconds by postgrey-1.27 at vger.kernel.org; Thu, 06 Oct 2016 22:07:09 EDT 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 ACDCD129C0E16; Fri, 7 Oct 2016 10:01:44 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1475805704; bh=DooHkcPQUbozzCthfOmn3hPd8DZO2DU+LIIVhtbJ81k=; h=From:To:Cc:Subject:Date; b=olk1SjtLM8l45VQekypczukF8sd6vkpNWrwGirDySNTZZ1aSjHwkH4gWu/jSMkvx8 mrFZPqzSi0MElz7iNJyMEAJgk6sjk1ger9Zniv70HMym/3woF7DdeWTLYQNost2sAA SfhSJUntLHJkSFMHQbhfWkexmC3ubSPTVKO7MWB4= From: robbieko To: linux-btrfs@vger.kernel.org Cc: Robbie Ko Subject: [PATCH] Btrfs: fix leak subvol subv_writers conter Date: Fri, 7 Oct 2016 10:01:29 +0800 Message-Id: <1475805689-9989-1-git-send-email-robbieko@synology.com> X-Mailer: git-send-email 1.9.1 X-MailScanner-ID: ACDCD129C0E16.A71C9 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 In run_delalloc_nocow, maybe not release subv_writers conter, will lead to create snapshot hang. Signed-off-by: Robbie Ko --- fs/btrfs/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e6811c4..9722554 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1386,11 +1386,17 @@ next_slot: * this ensure that csum for a given extent are * either valid or do not exist. */ - if (csum_exist_in_range(root, disk_bytenr, num_bytes)) + if (csum_exist_in_range(root, disk_bytenr, num_bytes)) { + if (!nolock) + btrfs_end_write_no_snapshoting(root); goto out_check; + } if (!btrfs_inc_nocow_writers(root->fs_info, - disk_bytenr)) + disk_bytenr)) { + if (!nolock) + btrfs_end_write_no_snapshoting(root); goto out_check; + } nocow = 1; } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) { extent_end = found_key.offset +