From patchwork Mon Aug 29 20:29:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 1110532 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7TKPuGv026486 for ; Mon, 29 Aug 2011 20:25:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755041Ab1H2UZx (ORCPT ); Mon, 29 Aug 2011 16:25:53 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:54302 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755023Ab1H2UZx (ORCPT ); Mon, 29 Aug 2011 16:25:53 -0400 Received: from sf.home (unknown [178.125.143.129]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id 65F3B1B40A1; Mon, 29 Aug 2011 20:25:52 +0000 (UTC) Received: by sf.home (Postfix, from userid 1000) id F1C167A346C; Mon, 29 Aug 2011 23:29:06 +0300 (EEST) From: slyich@gmail.com To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Sergei Trofimovich Subject: [PATCH] btrfs: btrfs_print_leaf: don't OOps on NULL extent_buffer parameter Date: Mon, 29 Aug 2011 23:29:02 +0300 Message-Id: <1314649742-10677-1-git-send-email-slyich@gmail.com> X-Mailer: git-send-email 1.7.3.4 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]); Mon, 29 Aug 2011 20:26:00 +0000 (UTC) From: Sergei Trofimovich btrfs_print_leaf() is usually called in emergency situations. Don't die on SIGSEGV in such situations. Skip gracefully instead: > [ 18.680000] parent transid verify failed on 227736236032 wanted 132659 found 123593 > [ 22.410000] btrfs: btrfs_print_leaf got NULL extent buffer. Skip printing. > [ 22.410000] ------------[ cut here ]------------ > [ 22.410000] WARNING: at linux-2.6/fs/btrfs/extent-tree.c:4482 __btrfs_free_extent+0x650/0x7e0() > [ 22.410000] Call Trace: > [ 22.410000] 6f569a98: [<600314a2>] warn_slowpath_common+0x62/0x90 ... > [ 22.410000] btrfs unable to find ref byte nr 39186432 parent 0 root 5 owner 0 offset 0 Instead of OOPsing in btrfs_print_leaf in get a little deeper and print useful info. Signed-off-by: Sergei Trofimovich --- fs/btrfs/print-tree.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c index fb2605d..7089603 100644 --- a/fs/btrfs/print-tree.c +++ b/fs/btrfs/print-tree.c @@ -159,7 +159,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) { int i; u32 type; - u32 nr = btrfs_header_nritems(l); + u32 nr; struct btrfs_item *item; struct btrfs_root_item *ri; struct btrfs_dir_item *di; @@ -172,6 +172,13 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) struct btrfs_key key; struct btrfs_key found_key; + if (!l) { + printk(KERN_ERR "btrfs: btrfs_print_leaf got NULL extent buffer. Skip printing.\n"); + return; + } + + nr = btrfs_header_nritems(l); + printk(KERN_INFO "leaf %llu total ptrs %d free space %d\n", (unsigned long long)btrfs_header_bytenr(l), nr, btrfs_leaf_free_space(root, l));