From patchwork Fri Apr 8 14:38:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 694731 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p38EgDfR020932 for ; Fri, 8 Apr 2011 14:42:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756022Ab1DHOmH (ORCPT ); Fri, 8 Apr 2011 10:42:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61985 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755385Ab1DHOmG (ORCPT ); Fri, 8 Apr 2011 10:42:06 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p38Eg2em020734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Apr 2011 10:42:02 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p38Eg1pC025373; Fri, 8 Apr 2011 10:42:01 -0400 Received: from localhost.localdomain (vpn-10-195.rdu.redhat.com [10.11.10.195]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p38EfxCk027356; Fri, 8 Apr 2011 10:42:00 -0400 Message-ID: <4D9F1DE4.7040306@redhat.com> Date: Fri, 08 Apr 2011 10:38:28 -0400 From: Josef Bacik User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-1.fc15 Thunderbird/3.1.9 MIME-Version: 1.0 To: cpwu@tnsoft.com.cn CC: ceph-devel , "linux-btrfs@vger.kernel.org" Subject: Re: 2.6.39-rc1: btrfs "WARNING: at fs/btrfs/inode.c:2177" References: <1302169286.1922.19.camel@cephhost> <4D9DE43F.3000809@redhat.com> <1302242000.2014.14.camel@cephhost> In-Reply-To: <1302242000.2014.14.camel@cephhost> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 14:42:13 +0000 (UTC) On 04/08/2011 01:53 AM, Jeff Wu wrote: > > Hi , > I applied the patch to 2.6.39-rc1,took the following steps to compile > it:make&& make modules_install&& make install&& mkinitramfs > but , it seam that it don't run to "WARN_ON(block_rsv == > root->orphan_block_rsv);" > > i attached the codes and logs at the below: > Bummer ok so here's a much bigger debug patch, remove the previous one I sent you and apply this one instead and run with it. As soon as you get a warning stop iozone because this debug patch will create _a lot_ of debug output, and I don't want to have to sift through all of it. Just send me your logs after running this patch so I can try and piece together what's going on. Thanks, Josef diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d00a07..c0d8c1d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -766,6 +766,7 @@ struct btrfs_block_rsv { unsigned int durable:1; unsigned int refill_used:1; unsigned int full:1; + unsigned int orphan:1; }; /* diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f619c3c..5ebcda8 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3429,6 +3429,9 @@ static int reserve_metadata_bytes(struct btrfs_trans_handle *trans, bool reserved = false; bool committed = false; + if (block_rsv->orphan) + printk(KERN_ERR "resrving metadata bytes for orphan rsv %llu\n", + orig_bytes); again: ret = -ENOSPC; if (reserved) @@ -3556,6 +3559,9 @@ static struct btrfs_block_rsv *get_block_rsv(struct btrfs_trans_handle *trans, if (!block_rsv) block_rsv = &root->fs_info->empty_block_rsv; + if (block_rsv->orphan) + printk(KERN_ERR "got orphan block rsv\n"); + return block_rsv; } @@ -3563,6 +3569,9 @@ static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, u64 num_bytes) { int ret = -ENOSPC; + if (block_rsv->orphan) + printk(KERN_ERR "using %llu bytes from orphan\n", + num_bytes); spin_lock(&block_rsv->lock); if (block_rsv->reserved >= num_bytes) { block_rsv->reserved -= num_bytes; @@ -3577,6 +3586,9 @@ static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, static void block_rsv_add_bytes(struct btrfs_block_rsv *block_rsv, u64 num_bytes, int update_size) { + if (block_rsv->orphan) + printk(KERN_ERR "adding %llu bytes, update_size=%d\n", + num_bytes, update_size); spin_lock(&block_rsv->lock); block_rsv->reserved += num_bytes; if (update_size) @@ -3592,6 +3604,10 @@ void block_rsv_release_bytes(struct btrfs_block_rsv *block_rsv, struct btrfs_space_info *space_info = block_rsv->space_info; spin_lock(&block_rsv->lock); + if (block_rsv->orphan) + printk(KERN_ERR "releasing %llu bytes from orhan, size=%llu, " + "reserved=%llu\n", num_bytes, block_rsv->size, + block_rsv->reserved); if (num_bytes == (u64)-1) num_bytes = block_rsv->size; block_rsv->size -= num_bytes; @@ -3668,6 +3684,9 @@ struct btrfs_block_rsv *btrfs_alloc_block_rsv(struct btrfs_root *root) void btrfs_free_block_rsv(struct btrfs_root *root, struct btrfs_block_rsv *rsv) { + if (rsv->orphan) + printk(KERN_ERR "freeing orphan rsv\n"); + if (rsv && atomic_dec_and_test(&rsv->usage)) { btrfs_block_rsv_release(root, rsv, (u64)-1); if (!rsv->durable) @@ -3696,6 +3715,10 @@ int btrfs_block_rsv_add(struct btrfs_trans_handle *trans, { int ret; + if (block_rsv->orphan) + printk(KERN_ERR "adding %llu bytes to orphan\n", + num_bytes); + if (num_bytes == 0) return 0; @@ -3720,6 +3743,10 @@ int btrfs_block_rsv_check(struct btrfs_trans_handle *trans, if (!block_rsv) return 0; + if (block_rsv->orphan) + printk(KERN_ERR "checking orphan reserve for %llu bytes, " + "%d min factor\n", min_reserved, min_factor); + spin_lock(&block_rsv->lock); if (min_factor > 0) num_bytes = div_factor(block_rsv->size, min_factor); @@ -3964,6 +3991,7 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans, * transaction and use space it freed. */ u64 num_bytes = calc_trans_metadata_size(root, 4); + printk(KERN_ERR "reserving %llu bytes for orphan\n", num_bytes); return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes); } @@ -3971,6 +3999,7 @@ void btrfs_orphan_release_metadata(struct inode *inode) { struct btrfs_root *root = BTRFS_I(inode)->root; u64 num_bytes = calc_trans_metadata_size(root, 4); + printk(KERN_ERR "first release of %llu bytes from orphan\n", num_bytes); btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes); } @@ -5697,6 +5726,8 @@ use_block_rsv(struct btrfs_trans_handle *trans, block_rsv = get_block_rsv(trans, root); + if (block_rsv->orphan) + printk(KERN_ERR "Using orphan block rsv for tree allocation\n"); if (block_rsv->size == 0) { ret = reserve_metadata_bytes(trans, root, block_rsv, blocksize, 0); @@ -5739,6 +5770,8 @@ use_block_rsv(struct btrfs_trans_handle *trans, static void unuse_block_rsv(struct btrfs_block_rsv *block_rsv, u32 blocksize) { + if (block_rsv->orphan) + printk(KERN_ERR "unusing orphan block rsv\n"); block_rsv_add_bytes(block_rsv, blocksize, 0); block_rsv_release_bytes(block_rsv, NULL, 0); } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 032e8fb..58b1361 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2176,7 +2176,11 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, } if (root->orphan_block_rsv) { - WARN_ON(root->orphan_block_rsv->size > 0); + if (root->orphan_block_rsv->size > 0) { + printk(KERN_ERR "orphan rsv still has %llu bytes\n", + root->orphan_block_rsv->size); + WARN_ON(1); + } btrfs_free_block_rsv(root, root->orphan_block_rsv); root->orphan_block_rsv = NULL; } @@ -2205,6 +2209,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) spin_lock(&root->orphan_lock); if (!root->orphan_block_rsv) { root->orphan_block_rsv = block_rsv; + block_rsv->orphan = 1; } else if (block_rsv) { btrfs_free_block_rsv(root, block_rsv); block_rsv = NULL;