From patchwork Tue Jun 25 15:52:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 2777761 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 75C749F3A0 for ; Tue, 25 Jun 2013 15:53:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B1912029B for ; Tue, 25 Jun 2013 15:52:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 163EA20291 for ; Tue, 25 Jun 2013 15:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969Ab3FYPwy (ORCPT ); Tue, 25 Jun 2013 11:52:54 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:48332 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751146Ab3FYPwy (ORCPT ); Tue, 25 Jun 2013 11:52:54 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5PFqn3B014614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 25 Jun 2013 15:52:50 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5PFqlmU002741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Jun 2013 15:52:48 GMT Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5PFqlH3009029; Tue, 25 Jun 2013 15:52:47 GMT Received: from localhost.localdomain (/10.191.5.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 25 Jun 2013 08:52:47 -0700 Date: Tue, 25 Jun 2013 23:52:35 +0800 From: Liu Bo To: Clemens Eisserer Cc: linux-btrfs@vger.kernel.org, Jon Nelson , Chris Mason Subject: Re: hang on 3.9, 3.10-rc5 Message-ID: <20130625155234.GA11866@localhost.localdomain> Reply-To: bo.li.liu@oracle.com References: <20130618163706.GC19183@localhost.localdomain> <20130621011137.4477.1347@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Fri, Jun 21, 2013 at 08:42:55AM +0200, Clemens Eisserer wrote: > Hi Jon, > > > Is this what you are looking for? > > After this, the CPU gets "stuck" and I have to reboot. > > This issue has already been reported: > https://bugzilla.kernel.org/show_bug.cgi?id=59451 Hi, Could you please try this patch? (at least it addresses my ulist_add_merge crash :)) thanks, liubo --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c index 7b417e2..69a9c32 100644 --- a/fs/btrfs/ulist.c +++ b/fs/btrfs/ulist.c @@ -73,7 +73,6 @@ void ulist_fini(struct ulist *ulist) if (ulist->nodes_alloced > ULIST_SIZE) kfree(ulist->nodes); ulist->nodes_alloced = 0; /* in case ulist_fini is called twice */ - ulist->root = RB_ROOT; } EXPORT_SYMBOL(ulist_fini); @@ -205,6 +204,7 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux, u64 new_alloced = ulist->nodes_alloced + 128; struct ulist_node *new_nodes; void *old = NULL; + int i; /* * if nodes_alloced == ULIST_SIZE no memory has been allocated @@ -222,6 +222,17 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux, memcpy(new_nodes, ulist->int_nodes, sizeof(ulist->int_nodes)); + /* + * krealloc actually uses memcpy, which does not copy rb_node + * pointers, so we have to do it ourselves. Otherwise we may + * be bitten by crashes. + */ + for (i = 0; i < ulist->nnodes; i++) { + rb_erase(&ulist->nodes[i].rb_node, &ulist->root); + ret = ulist_rbtree_insert(ulist, &new_nodes[i]); + BUG_ON(ret); + } + ulist->nodes = new_nodes; ulist->nodes_alloced = new_alloced; }