From patchwork Tue Apr 5 21:57:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 688941 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 p35M5MrA021953 for ; Tue, 5 Apr 2011 22:05:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751921Ab1DEWFT (ORCPT ); Tue, 5 Apr 2011 18:05:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883Ab1DEWFS (ORCPT ); Tue, 5 Apr 2011 18:05:18 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p35M5FnG009240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Apr 2011 18:05:15 -0400 Received: from dhcp231-156.rdu.redhat.com (dhcp231-156.rdu.redhat.com [10.11.231.156]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p35M5Ehx009543; Tue, 5 Apr 2011 18:05:14 -0400 Date: Tue, 5 Apr 2011 17:57:53 -0400 From: Josef Bacik To: Johannes Hirte Cc: Josef Bacik , linux-btrfs@vger.kernel.org Subject: Re: BUG: unable to handle kernel NULL pointer dereference at (null) Message-ID: <20110405215752.GE484@dhcp231-156.rdu.redhat.com> References: <201104051938.14319.johannes.hirte@fem.tu-ilmenau.de> <201104052308.53816.johannes.hirte@fem.tu-ilmenau.de> <20110405211227.GD484@dhcp231-156.rdu.redhat.com> <201104060000.11403.johannes.hirte@fem.tu-ilmenau.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201104060000.11403.johannes.hirte@fem.tu-ilmenau.de> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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]); Tue, 05 Apr 2011 22:05:24 +0000 (UTC) > > Now it hit Man I cannot catch a break. I hope this is the last one. Thanks, Josef --- fs/btrfs/free-space-cache.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 74bc432..b8052be 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -522,6 +522,7 @@ int btrfs_write_out_cache(struct btrfs_root *root, int bitmaps = 0; int ret = 0; bool next_page = false; + bool out_of_space = false; root = root->fs_info->tree_root; @@ -629,6 +630,11 @@ int btrfs_write_out_cache(struct btrfs_root *root, offset = start_offset; } + if (index > last_index) { + out_of_space = true; + break; + } + page = find_get_page(inode->i_mapping, index); addr = kmap(page); @@ -732,6 +738,10 @@ int btrfs_write_out_cache(struct btrfs_root *root, struct btrfs_free_space *entry = list_entry(pos, struct btrfs_free_space, list); + if (index > last_index) { + out_of_space = true; + break; + } page = find_get_page(inode->i_mapping, index); addr = kmap(page); @@ -754,6 +764,28 @@ int btrfs_write_out_cache(struct btrfs_root *root, index++; } + if (out_of_space) { + page = find_get_page(inode->i_mapping, 0); + + /* + * Have to do the normal stuff in case writeback gets started on + * this page before we invalidate it. + */ + ClearPageChecked(page); + set_page_extent_mapped(page); + SetPageUptodate(page); + set_page_dirty(page); + unlock_page(page); + page_cache_release(page); + page_cache_release(page); + + ret = 0; + unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0, + i_size_read(inode) - 1, &cached_state, + GFP_NOFS); + goto out_free; + } + /* Zero out the rest of the pages just to make sure */ while (index <= last_index) { void *addr;