Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964934AbWLTL2H (ORCPT ); Wed, 20 Dec 2006 06:28:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S964976AbWLTL2H (ORCPT ); Wed, 20 Dec 2006 06:28:07 -0500 Received: from amsfep19-int.chello.nl ([62.179.120.14]:58737 "EHLO amsfep19-int.chello.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964934AbWLTL2F (ORCPT ); Wed, 20 Dec 2006 06:28:05 -0500 Subject: [PATCH] mm: fix page_mkclean_one (was: 2.6.19 file content corruption on ext3) From: Peter Zijlstra To: Arjan van de Ven Cc: Linus Torvalds , Andrei Popa , Andrew Morton , Linux Kernel Mailing List , Hugh Dickins , Florian Weimer , Marc Haber , Martin Michlmayr , Martin Schwidefsky , Heiko Carstens , Arnd Bergmann In-Reply-To: <1166607554.3365.1354.camel@laptopd505.fenrus.org> References: <1166314399.7018.6.camel@localhost> <20061217040620.91dac272.akpm@osdl.org> <1166362772.8593.2.camel@localhost> <20061217154026.219b294f.akpm@osdl.org> <1166460945.10372.84.camel@twins> <1166466272.10372.96.camel@twins> <1166468651.6983.6.camel@localhost> <1166471069.6940.4.camel@localhost> <1166571749.10372.178.camel@twins> <1166605296.10372.191.camel@twins> <1166607554.3365.1354.camel@laptopd505.fenrus.org> Content-Type: text/plain Date: Wed, 20 Dec 2006 12:26:41 +0100 Message-Id: <1166614001.10372.205.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2015 Lines: 72 fix page_mkclean_one() it had several issues: - it failed to flush the cache - it failed to flush the tlb - it failed to do s390 (s390 guys, please verify this is now correct) Also, clear in a loop to ensure SMP safeness as suggested by Arjan. Signed-off-by: Peter Zijlstra --- mm/rmap.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) Index: linux-2.6/mm/rmap.c =================================================================== --- linux-2.6.orig/mm/rmap.c +++ linux-2.6/mm/rmap.c @@ -432,7 +432,7 @@ static int page_mkclean_one(struct page { struct mm_struct *mm = vma->vm_mm; unsigned long address; - pte_t *pte, entry; + pte_t *ptep; spinlock_t *ptl; int ret = 0; @@ -440,22 +440,23 @@ static int page_mkclean_one(struct page if (address == -EFAULT) goto out; - pte = page_check_address(page, mm, address, &ptl); - if (!pte) + ptep = page_check_address(page, mm, address, &ptl); + if (!ptep) goto out; - if (!pte_dirty(*pte) && !pte_write(*pte)) - goto unlock; - - entry = ptep_get_and_clear(mm, address, pte); - entry = pte_mkclean(entry); - entry = pte_wrprotect(entry); - ptep_establish(vma, address, pte, entry); - lazy_mmu_prot_update(entry); - ret = 1; + while (pte_dirty(*ptep) || pte_write(*ptep)) { + pte_t entry = ptep_get_and_clear(mm, address, ptep); + flush_cache_page(vma, address, pte_pfn(entry)); + flush_tlb_page(vma, address); + (void)page_test_and_clear_dirty(page); /* do the s390 thing */ + entry = pte_wrprotect(entry); + entry = pte_mkclean(entry); + set_pte_at(vma, address, ptep, entry); + lazy_mmu_prot_update(entry); + ret = 1; + } -unlock: - pte_unmap_unlock(pte, ptl); + pte_unmap_unlock(ptep, ptl); out: return ret; } - 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/