From patchwork Wed Nov 12 07:55:59 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshiyuki Okajima X-Patchwork-Id: 8326 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.176.167]) by ozlabs.org (Postfix) with ESMTP id C3FE5DDD04 for ; Wed, 12 Nov 2008 19:05:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751078AbYKLIFb (ORCPT ); Wed, 12 Nov 2008 03:05:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751104AbYKLIFb (ORCPT ); Wed, 12 Nov 2008 03:05:31 -0500 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:51098 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbYKLIFa (ORCPT ); Wed, 12 Nov 2008 03:05:30 -0500 Received: from m6.gw.fujitsu.co.jp ([10.0.50.76]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id mAC85SOD029799 (envelope-from toshi.okajima@jp.fujitsu.com); Wed, 12 Nov 2008 17:05:29 +0900 Received: from smail (m6 [127.0.0.1]) by outgoing.m6.gw.fujitsu.co.jp (Postfix) with ESMTP id C59F145DE4C; Wed, 12 Nov 2008 17:05:28 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (s6.gw.fujitsu.co.jp [10.0.50.96]) by m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 93DAC45DE3E; Wed, 12 Nov 2008 17:05:28 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 7DA221DB803B; Wed, 12 Nov 2008 17:05:28 +0900 (JST) Received: from m108.s.css.fujitsu.com (m108.s.css.fujitsu.com [10.249.87.108]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 369CD1DB8038; Wed, 12 Nov 2008 17:05:28 +0900 (JST) Received: from m108.css.fujitsu.com (m108 [127.0.0.1]) by m108.s.css.fujitsu.com (Postfix) with ESMTP id 0711D428052; Wed, 12 Nov 2008 17:05:28 +0900 (JST) Received: from stratos.soft.fujitsu.com (stratos.soft.fujitsu.com [10.124.101.114]) by m108.s.css.fujitsu.com (Postfix) with SMTP id 6370B428059; Wed, 12 Nov 2008 17:05:27 +0900 (JST) Date: Wed, 12 Nov 2008 16:55:59 +0900 From: Toshiyuki Okajima To: akpm@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, sct@redhat.com, adilger@sun.com Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 3/3][RFC] ext4: release block-device-mapping buffer_heads which have the filesystem private data for avoiding oom-killer Message-Id: <20081112165559.c6664449.toshi.okajima@jp.fujitsu.com> In-Reply-To: <4913B35A.8080203@jp.fujitsu.com> References: <20081017.223716.147444348.00960188@stratos.soft.fujitsu.com> <20081020160249.ff41f762.akpm@linux-foundation.org> <20081023174101.85b59177.toshi.okajima@jp.fujitsu.com> <20081027142657.2120aa3f.akpm@linux-foundation.org> <49067D03.6080609@jp.fujitsu.com> <20081105131140.7689f048.toshi.okajima@jp.fujitsu.com> <20081105135349.GA22998@mit.edu> <4913B35A.8080203@jp.fujitsu.com> Organization: Fujitsu co.,ltd. X-Mailer: Sylpheed 2.5.0rc2 (GTK+ 2.12.12; i386-redhat-linux-gnu) Mime-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org [PATCH 3/3] ext4: release block-device-mapping buffer_heads which have the filesystem private data for avoiding oom-killer Implement releasepage() of a client of a block device to release its private data (journal_heads) and the page. The client is an ext4 filesystem. This function is called from releasepage() of the block-device mapping, blkdev_releasepage(). Signed-off-by: Toshiyuki Okajima --- fs/ext4/ext4.h | 2 ++ fs/ext4/inode.c | 22 ++++++++++++++++++++++ fs/ext4/super.c | 4 ++++ 3 files changed, 28 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -Nurp linux-2.6.28-rc4.orig/fs/ext4/ext4.h linux-2.6.28-rc4/fs/ext4/ext4.h --- linux-2.6.28-rc4.orig/fs/ext4/ext4.h 2008-11-10 09:36:15.000000000 +0900 +++ linux-2.6.28-rc4/fs/ext4/ext4.h 2008-11-12 10:44:25.000000000 +0900 @@ -1095,6 +1095,8 @@ extern int ext4_chunk_trans_blocks(struc extern int ext4_block_truncate_page(handle_t *handle, struct address_space *mapping, loff_t from); extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page); +extern int ext4_release_metadata(void *client, struct page *page, + gfp_t wait); /* ioctl.c */ extern long ext4_ioctl(struct file *, unsigned int, unsigned long); diff -Nurp linux-2.6.28-rc4.orig/fs/ext4/inode.c linux-2.6.28-rc4/fs/ext4/inode.c --- linux-2.6.28-rc4.orig/fs/ext4/inode.c 2008-11-10 09:36:15.000000000 +0900 +++ linux-2.6.28-rc4/fs/ext4/inode.c 2008-11-12 10:42:55.000000000 +0900 @@ -3002,6 +3002,28 @@ static int ext4_releasepage(struct page } /* + * ext4_release_metadata: try to release own page. + * The mapping of this page is block device's. Therefore try_to_free_buffers() + * cannot release it. As a result, a function which releases own page is + * required. + */ +int ext4_release_metadata(void *client, struct page *page, gfp_t wait) +{ + struct super_block *sb = (struct super_block*)client; + journal_t *journal; + + WARN_ON(PageChecked(page)); + if (!page_has_buffers(page)) + return 0; + BUG_ON(EXT4_SB(sb) == NULL); + journal = EXT4_SB(sb)->s_journal; + if (journal != NULL) + return jbd2_journal_try_to_free_buffers(journal, page, wait); + else + return try_to_free_buffers(page); +} + +/* * If the O_DIRECT write will extend the file then add this inode to the * orphan list. So recovery will truncate it back to the original size * if the machine crashes during the write. diff -Nurp linux-2.6.28-rc4.orig/fs/ext4/super.c linux-2.6.28-rc4/fs/ext4/super.c --- linux-2.6.28-rc4.orig/fs/ext4/super.c 2008-11-10 09:36:15.000000000 +0900 +++ linux-2.6.28-rc4/fs/ext4/super.c 2008-11-12 12:04:58.000000000 +0900 @@ -3543,6 +3543,8 @@ static struct file_system_type ext4_fs_t .name = "ext4", .get_sb = ext4_get_sb, .kill_sb = kill_block_super, + .release_metadata + = ext4_release_metadata, .fs_flags = FS_REQUIRES_DEV, }; @@ -3562,6 +3564,8 @@ static struct file_system_type ext4dev_f .name = "ext4dev", .get_sb = ext4dev_get_sb, .kill_sb = kill_block_super, + .release_metadata + = ext4_release_metadata, .fs_flags = FS_REQUIRES_DEV, }; MODULE_ALIAS("ext4dev");