From patchwork Wed Aug 21 13:44:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mitch Harder X-Patchwork-Id: 2847735 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EB5539F271 for ; Wed, 21 Aug 2013 13:45:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 249412050F for ; Wed, 21 Aug 2013 13:45:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A2FE204AC for ; Wed, 21 Aug 2013 13:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181Ab3HUNo5 (ORCPT ); Wed, 21 Aug 2013 09:44:57 -0400 Received: from mail-oa0-f42.google.com ([209.85.219.42]:54850 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949Ab3HUNo4 (ORCPT ); Wed, 21 Aug 2013 09:44:56 -0400 Received: by mail-oa0-f42.google.com with SMTP id i18so818108oag.29 for ; Wed, 21 Aug 2013 06:44:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=0i9RwqbFDrchXbxgUHtCBRM67T2MaJvhuJOTG6DJ3gY=; b=gOA5br7juGlrC6jaCZlCh3xUEUMn4V0qyP7TrJg4ySuhBxoJPvRmlCRA7rrElrAb/E u86op2I1ZpRlaoY/HkXLDTgMWj/yQY4Ur4a2RqgKLH5UAmWotQuPdKX0+05LtYoIDcqD OwC3lYXPzUrP9HT7Zkye9LTlpYK+dkLSt02q1hczRm4SgyN3V58if9PUwDw8HDbQxjB9 rye2VwKypg1e5Pov0fLSdUYAI+Ea7QJrQLQR/DMUVaY3QXX9pvz02SbY79FJlIw2FJwc rxPFKiqTg6sLLnCuHtTe0Dj2BNs85fYwt/k7HqrAZD2F8uT8vu+u+p8nEbyuRLXLzpPR afrA== X-Gm-Message-State: ALoCoQl2Ul4ya0pCSUf1x42fg0hM9NzOVM5Rr5cJ57tmPzAs0WF5kiUdi5s8iD1nrWdgi7hMfoJN MIME-Version: 1.0 X-Received: by 10.182.119.169 with SMTP id kv9mr7991034obb.66.1377092695548; Wed, 21 Aug 2013 06:44:55 -0700 (PDT) Received: by 10.60.55.106 with HTTP; Wed, 21 Aug 2013 06:44:55 -0700 (PDT) In-Reply-To: References: <20130813141542.GF2150@localhost.localdomain> Date: Wed, 21 Aug 2013 08:44:55 -0500 Message-ID: Subject: Re: Kernel BUG on Snapshot Deletion (3.11.0-rc5) From: Mitch Harder To: Josef Bacik , Stefan Behrens Cc: linux-btrfs Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Thu, Aug 15, 2013 at 12:29 PM, Mitch Harder wrote: > I'm running into a curious problem. > > In the process of making my script portable, I am breaking the ability > to replicate the error. > > I'm trying to isolate the aspect of my local script that is triggering > the error. No firm insights yet. > > > On Tue, Aug 13, 2013 at 11:03 AM, Mitch Harder > wrote: >> Let me work on making that script more portable, and hopefully quicker >> to reproduce. >> >> On Tue, Aug 13, 2013 at 9:15 AM, Josef Bacik wrote: >>> On Mon, Aug 12, 2013 at 11:06:27PM -0500, Mitch Harder wrote: >>>> I'm hitting a btrfs Kernel BUG running a snapshot stress script with >>>> linux-3.11.0-rc5. >>>> >>> >>> I can haz script? Thanks, >>> I've had a hard time assembling a portable reproducer for this issue. I discovered that my reproducer was highly dependent on a local archive of out-of-date git kernel sources. My efforts to reproduce the error with a portable set of scripts with publicly available kernel git sources weren't successful. It seems like this issue is related to a corner-case workload that is difficult to reproduce. So I've bisected the error I was seeing with my local script, and identified the following commit as triggering my issue: commit: 3c64a1aba7cfcb04f79e76f859b3d66660275d59 Btrfs: cleanup: don't check the same thing twice https://git.kernel.org/cgit/linux/kernel/git/mason/linux-btrfs.git/commit/fs/btrfs?h=for-linus&id=3c64a1aba7cfcb04 I tested a kernel which reverted this change, and also added WARN_ON lines to provide a back trace. diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index 4b86916..336d628 100644 --- a/fs/btrfs/export.c +++ b/fs/btrfs/export.c @@ -82,6 +82,12 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, goto fail; } + if (btrfs_root_refs(&root->root_item) == 0) { + WARN_ON(1); + err = -ENOENT; + goto fail; + } + key.objectid = objectid; btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); key.offset = 0; diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 94413af..4010257 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -310,6 +310,12 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, goto cleanup; } + if (btrfs_root_refs(&inode_root->root_item) == 0) { + WARN_ON(1); + ret = -ENOENT; + goto cleanup; + } + key.objectid = defrag->ino; btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); key.offset = 0; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cd46e2c..a1091f7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2302,6 +2302,12 @@ static noinline int relink_extent_backref(struct btrfs_path *path, return 0; return PTR_ERR(root); } + if (btrfs_root_refs(&root->root_item) == 0) { + srcu_read_unlock(&fs_info->subvol_srcu, index); + /* parse ENOENT to 0 */ + WARN_ON(1); + return 0; + } /* step 2: get inode */ key.objectid = backref->inum; @@ -4703,6 +4709,12 @@ static int fixup_tree_root_location(struct btrfs_root *root, goto out; } + if (btrfs_root_refs(&new_root->root_item) == 0) { + WARN_ON(1); + err = -ENOENT; + goto out; + } + *sub_root = new_root; location->objectid = btrfs_root_dirid(&new_root->root_item); location->type = BTRFS_INODE_ITEM_KEY; diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0e17a30..0f74235 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2969,6 +2969,12 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) goto out; } + if (btrfs_root_refs(&new_root->root_item) == 0) { + WARN_ON(1); + ret = -ENOENT; + goto out; + } + path = btrfs_alloc_path(); if (!path) { ret = -ENOMEM; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b267c3c..3cf4716 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -793,6 +793,11 @@ find_root: if (IS_ERR(new_root)) return ERR_CAST(new_root); + if (btrfs_root_refs(&new_root->root_item) == 0) { + WARN_ON(1); + return ERR_PTR(-ENOENT); + } + dir_id = btrfs_root_dirid(&new_root->root_item); setup_root: location.objectid = dir_id;