From patchwork Tue Jan 26 15:32:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 43707 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 67D53B7E16 for ; Wed, 27 Jan 2010 02:32:20 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107Ab0AZPcS (ORCPT ); Tue, 26 Jan 2010 10:32:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752595Ab0AZPcS (ORCPT ); Tue, 26 Jan 2010 10:32:18 -0500 Received: from cantor.suse.de ([195.135.220.2]:43335 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107Ab0AZPcS (ORCPT ); Tue, 26 Jan 2010 10:32:18 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 1EC3494A1C; Tue, 26 Jan 2010 16:32:16 +0100 (CET) Received: by quack.suse.cz (Postfix, from userid 10005) id CCCD12B1755; Tue, 26 Jan 2010 16:32:22 +0100 (CET) Date: Tue, 26 Jan 2010 16:32:22 +0100 From: Jan Kara To: Wu Fengguang Cc: Jan Kara , "linux-ext4@vger.kernel.org" , tytso@mit.edu Subject: Re: ext4_da_block_invalidatepages() question Message-ID: <20100126153222.GI3187@quack.suse.cz> References: <20100126133608.GC25407@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100126133608.GC25407@localhost> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi, On Tue 26-01-10 21:36:08, Wu Fengguang wrote: > I noticed that ext4_da_block_invalidatepages() does pagevec_lookup() > without pagevec_release()/put_page(). Is that OK? Yes, the function looks buggy. Luckily, it is called only in case we are not able to allocate space for delay-allocated data which is a bug on its own. So people should never hit it. Attached patch should fix the issue. Ted, will you merge it please? Thanks. Honza From 47085f1ac03eaca9e4d7a5f8f1e40e87d3879512 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 26 Jan 2010 16:15:19 +0100 Subject: [PATCH] ext4: Release page references acquired in ext4_da_block_invalidatepages We forget to release page references we acquire in ext4_da_block_invalidatepages. Luckily, this function gets called only if we are not able to allocate blocks for delay-allocated data so that function should better never be called. Also cleanup handling of index variable. Reported-by: Wu Fengguang Signed-off-by: Jan Kara --- fs/ext4/inode.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c818972..1680007 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2127,17 +2127,16 @@ static void ext4_da_block_invalidatepages(struct mpage_da_data *mpd, break; for (i = 0; i < nr_pages; i++) { struct page *page = pvec.pages[i]; - index = page->index; - if (index > end) + if (page->index > end) break; - index++; - BUG_ON(!PageLocked(page)); BUG_ON(PageWriteback(page)); block_invalidatepage(page, 0); ClearPageUptodate(page); unlock_page(page); } + index = pvec.pages[nr_pages - 1]->index + 1; + pagevec_release(&pvec); } return; } -- 1.6.4.2