X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fllite_mmap.c;h=f17a90d74b62b5d1185ddd081b4500a1f5d36bc1;hb=e924e9d5c12ca2be8d2b4809ae797bf3687651af;hp=b1c5620fed06e1f33c597cc2317035b57d8a7e9d;hpb=26eb27ce838c6d9281c1a8a73429e6ee836da997;p=fs%2Flustre-release.git diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index b1c5620..f17a90d 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -1,22 +1,37 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. + * GPL HEADER START * - * This file is part of Lustre, http://www.lustre.org. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #ifndef AUTOCONF_INCLUDED @@ -36,9 +51,6 @@ #include #include #include -#ifdef HAVE_SEGMENT_H -# include -#endif #include #include #include @@ -293,6 +305,11 @@ static struct vm_area_struct * our_vma(unsigned long addr, size_t count) RETURN(ret); } +int ll_region_mapped(unsigned long addr, size_t count) +{ + return !!our_vma(addr, count); +} + int lt_get_mmap_locks(struct ll_lock_tree *tree, unsigned long addr, size_t count) { @@ -331,20 +348,16 @@ int lt_get_mmap_locks(struct ll_lock_tree *tree, RETURN(0); } -/* FIXME: there is a pagefault race goes as follow (only 2.4): - * 1. A user process on node A accesses a portion of a mapped file, - * resulting in a page fault. The pagefault handler invokes the - * ll_nopage function, which reads the page into memory. - * 2. A user process on node B writes to the same portion of the file - * (either via mmap or write()), that cause node A to cancel the - * lock and truncate the page. - * 3. Node A then executes the rest of do_no_page(), entering the - * now-invalid page into the PTEs. +/** + * Page fault handler. * - * Make the whole do_no_page as a hook to cover both the page cache - * and page mapping installing with dlm lock would eliminate this race. + * \param vma - is virtiual area struct related to page fault + * \param address - address when hit fault + * \param type - of fault * - * In 2.6, the truncate_count of address_space can cover this race. + * \return allocated and filled page for address + * \retval NOPAGE_SIGBUS if page not exist on this address + * \retval NOPAGE_OOM not have memory for allocate new page */ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address, int *type) @@ -369,6 +382,8 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address, RETURN(NULL); } + ll_clear_file_contended(inode); + /* start and end the lock on the first and last bytes in the page */ policy_from_vma(&policy, vma, address, CFS_PAGE_SIZE); @@ -380,7 +395,7 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address, lsm = lli->lli_smd; rc = ll_extent_lock(fd, inode, lsm, mode, &policy, - &lockh, LDLM_FL_CBPENDING | LDLM_FL_NO_LRU); + &lockh, LDLM_FL_CBPENDING); if (rc != 0) RETURN(NULL); @@ -443,8 +458,13 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address, vma->vm_flags |= VM_RAND_READ; page = filemap_nopage(vma, address, type); - LL_CDEBUG_PAGE(D_PAGE, page, "got addr %lu type %lx\n", address, - (long)type); + if (page != NOPAGE_SIGBUS && page != NOPAGE_OOM) + LL_CDEBUG_PAGE(D_PAGE, page, "got addr %lu type %lx\n", address, + (long)type); + else + CDEBUG(D_PAGE, "got addr %lu type %lx - SIGBUS\n", address, + (long)type); + vma->vm_flags &= ~VM_RAND_READ; vma->vm_flags |= (rand_read | seq_read); @@ -471,21 +491,7 @@ static void ll_vm_open(struct vm_area_struct * vma) LASSERT(atomic_read(&lli->lli_mmap_cnt) >= 0); atomic_inc(&lli->lli_mmap_cnt); - if (atomic_read(&lli->lli_mmap_cnt) == 1) { - struct lov_stripe_md *lsm = lli->lli_smd; - struct ll_sb_info *sbi = ll_i2sbi(inode); - int count; - spin_unlock(&lli->lli_lock); - - if (!lsm) - return; - count = obd_join_lru(sbi->ll_dt_exp, lsm, 0); - VMA_DEBUG(vma, "split %d unused locks from lru\n", count); - } else { - spin_unlock(&lli->lli_lock); - } - } static void ll_vm_close(struct vm_area_struct *vma) @@ -500,20 +506,7 @@ static void ll_vm_close(struct vm_area_struct *vma) LASSERT(atomic_read(&lli->lli_mmap_cnt) > 0); atomic_dec(&lli->lli_mmap_cnt); - if (atomic_read(&lli->lli_mmap_cnt) == 0) { - struct lov_stripe_md *lsm = lli->lli_smd; - struct ll_sb_info *sbi = ll_i2sbi(inode); - int count; - spin_unlock(&lli->lli_lock); - - if (!lsm) - return; - count = obd_join_lru(sbi->ll_dt_exp, lsm, 1); - VMA_DEBUG(vma, "join %d unused locks to lru\n", count); - } else { - spin_unlock(&lli->lli_lock); - } } #ifndef HAVE_FILEMAP_POPULATE