From patchwork Wed Aug 12 15:15:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 7002791 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06903C05AC for ; Wed, 12 Aug 2015 15:16:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 125FE2061B for ; Wed, 12 Aug 2015 15:16:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DC652054A for ; Wed, 12 Aug 2015 15:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754700AbbHLPQZ (ORCPT ); Wed, 12 Aug 2015 11:16:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:48786 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754558AbbHLPQY (ORCPT ); Wed, 12 Aug 2015 11:16:24 -0400 Received: from pps.filterd (m0004003 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t7CFDvUS030788; Wed, 12 Aug 2015 08:16:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=message-id : date : from : mime-version : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=i8DRNhGv5AHXUDTjAM2Op1i5iDCnMvS9CZDXFmd5YcU=; b=SOdwRz7hRnbnftOCmapZoLJBe7dsqM+6LW2Ie2+Tncckiq8zDwEl0aaXINU/caQhUkqC 0I/j03l3+b6RjwDTMkQgU9ids7S81PIxPlSETC12lkgSaXPhsxfYBh7ou9XgHrxoV0jz OD4ZSpPezAqZyFnrpzcDVpUIGZTApBeYc6w= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1w87ju8a7n-16 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 12 Aug 2015 08:16:15 -0700 Received: from localhost.localdomain (192.168.52.123) by mail.TheFacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 12 Aug 2015 08:15:43 -0700 Message-ID: <55CB631B.2080404@fb.com> Date: Wed, 12 Aug 2015 11:15:39 -0400 From: Josef Bacik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Marc MERLIN CC: , , Subject: Re: kernel BUG at fs/btrfs/extent-tree.c:8113! (4.1.3 kernel) References: <20150706212156.GY17274@merlins.org> <20150710134348.GB15535@suse.cz> <20150712010229.GA5284@merlins.org> <20150723115558.GQ6306@suse.cz> <20150724162446.GH30815@merlins.org> <20150803035130.GL24824@merlins.org> <20150811050758.GF29259@merlins.org> <55CA177D.1050004@fb.com> <20150812144749.GY24824@merlins.org> In-Reply-To: <20150812144749.GY24824@merlins.org> X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-08-12_09:2015-08-12, 2015-08-12, 1970-01-01 signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/12/2015 10:47 AM, Marc MERLIN wrote: > On Tue, Aug 11, 2015 at 11:40:45AM -0400, Josef Bacik wrote: >> From a48cf7a9ae44a17d927df5542c8b0be287aee9ed Mon Sep 17 00:00:00 2001 >> From: Josef Bacik >> Date: Tue, 11 Aug 2015 11:39:37 -0400 >> Subject: [PATCH] Btrfs: kill BUG_ON() in btrfs_lookup_extent_info() >> >> Replace it with an ASSERT(0) for the developers and an error for not the >> developers. > > Thanks. We knocked one down and now another BUG has been triggered :) > > if (unlikely(wc->refs[level - 1] == 0)) { > btrfs_err(root->fs_info, "Missing references."); > BUG(); > } > This is why you got your own branch, it's never just one. Here's the next bit From 07214b5294d2772682aba893de15ef8020994598 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 12 Aug 2015 11:06:42 -0400 Subject: [PATCH] Btrfs: don't BUG() during drop snapshot Really there's lots of things that can go wrong here, kill all the BUG_ON()'s and replace the logic ones with ASSERT()'s and return EIO instead. Also fix the leak of next in one of the error conditions while we're at it. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) @@ -8253,7 +8256,13 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, } level--; - BUG_ON(level != btrfs_header_level(next)); + ASSERT(level == btrfs_header_level(next)); + if (level != btrfs_header_level(next)) { + printk(KERN_ERR "Mismatched level\n"); + btrfs_tree_unlock(next); + free_extent_buffer(next); + return -EIO; + } path->nodes[level] = next; path->slots[level] = 0; path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING; @@ -8268,8 +8277,14 @@ skip: if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) { parent = path->nodes[level]->start; } else { - BUG_ON(root->root_key.objectid != + ASSERT(root->root_key.objectid == btrfs_header_owner(path->nodes[level])); + if (root->root_key.objectid != + btrfs_header_owner(path->nodes[level])) { + printk(KERN_ERR "Mismatched block owner\n"); + btrfs_tree_unlock(next); + free_extent_buffer(next); + } parent = 0; } @@ -8285,7 +8300,11 @@ skip: } ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent, root->root_key.objectid, level - 1, 0, 0); - BUG_ON(ret); /* -ENOMEM */ + if (ret) { + btrfs_tree_unlock(next); + free_extent_buffer(next); + return ret; + } } btrfs_tree_unlock(next); free_extent_buffer(next); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f7fb120..6671faf 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -8196,12 +8196,15 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, &wc->flags[level - 1]); if (ret < 0) { btrfs_tree_unlock(next); + free_extent_buffer(next); return ret; } if (unlikely(wc->refs[level - 1] == 0)) { btrfs_err(root->fs_info, "Missing references."); - BUG(); + btrfs_tree_unlock(next); + free_extent_buffer(next); + return -EIO; } *lookup_info = 0;