Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757896AbXJOWmk (ORCPT ); Mon, 15 Oct 2007 18:42:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753849AbXJOWmc (ORCPT ); Mon, 15 Oct 2007 18:42:32 -0400 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:55516 "EHLO ebiederm.dsl.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbXJOWmb (ORCPT ); Mon, 15 Oct 2007 18:42:31 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Andrew Morton Cc: Nick Piggin , Christian Borntraeger , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Martin Schwidefsky , "Theodore Ts'o" Subject: [PATCH] rd: Mark ramdisk buffers heads dirty References: <200710151028.34407.borntraeger@de.ibm.com> <200710160006.19735.nickpiggin@yahoo.com.au> <200710151105.57442.borntraeger@de.ibm.com> <200710160038.03524.nickpiggin@yahoo.com.au> Date: Mon, 15 Oct 2007 16:42:06 -0600 In-Reply-To: (Eric W. Biederman's message of "Mon, 15 Oct 2007 16:40:42 -0600") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1795 Lines: 54 I have not observed this case but it is possible to get a dirty page cache with clean buffer heads if we get a clean ramdisk page with buffer heads generated by a filesystem calling __getblk and then write to that page from user space through the block device. Then we just need to hit the proper window and try_to_free_buffers() will mark that page clean and eventually drop it. Ouch! To fix this use the generic __set_page_dirty_buffers in the ramdisk code so that when we mark a page dirty we also mark it's buffer heads dirty. Signed-off-by: Eric W. Biederman --- drivers/block/rd.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/drivers/block/rd.c b/drivers/block/rd.c index 701ea77..84163da 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c @@ -178,23 +178,12 @@ static int ramdisk_writepages(struct address_space *mapping, return 0; } -/* - * ramdisk blockdev pages have their own ->set_page_dirty() because we don't - * want them to contribute to dirty memory accounting. - */ -static int ramdisk_set_page_dirty(struct page *page) -{ - if (!TestSetPageDirty(page)) - return 1; - return 0; -} - static const struct address_space_operations ramdisk_aops = { .readpage = ramdisk_readpage, .prepare_write = ramdisk_prepare_write, .commit_write = ramdisk_commit_write, .writepage = ramdisk_writepage, - .set_page_dirty = ramdisk_set_page_dirty, + .set_page_dirty = __set_page_dirty_buffers, .writepages = ramdisk_writepages, }; -- 1.5.3.rc6.17.g1911 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/