* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
vma->vm_file->f_dentry->d_inode->i_ino, \
vma->vm_file->f_dentry->d_iname, ## arg); \
-struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
- int *type);
-
static struct vm_operations_struct ll_file_vm_ops;
void policy_from_vma(ldlm_policy_data_t *policy,
LASSERT(io->ci_obj != NULL);
fio = &io->u.ci_fault;
- fio->ft_index = vma->vm_pgoff + index;
+ fio->ft_index = index;
fio->ft_writable = (vma->vm_flags&writable) == writable;
fio->ft_executable = vma->vm_flags&VM_EXEC;
vma->vm_flags &= ~VM_SEQ_READ;
vma->vm_flags |= VM_RAND_READ;
- CDEBUG(D_INFO, "vm_flags: %lx (%lu %i %i)\n", vma->vm_flags,
+ CDEBUG(D_INFO, "vm_flags: %lx (%lu %d %d)\n", vma->vm_flags,
fio->ft_index, fio->ft_writable, fio->ft_executable);
if (cl_io_init(env, io, CIT_FAULT, io->ci_obj) == 0) {
struct lu_env *env;
struct cl_env_nest nest;
struct cl_io *io;
- struct page *page = NOPAGE_SIGBUS;
- struct vvp_io *vio = NULL;
+ struct page *page;
+ struct vvp_io *vio;
unsigned long ra_flags;
pgoff_t pg_offset;
int result;
ENTRY;
- pg_offset = (address - vma->vm_start) >> PAGE_SHIFT;
+ pg_offset = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
result = ll_fault_io_init(vma, &env, &nest, pg_offset, &ra_flags);
if (env == NULL)
return NOPAGE_SIGBUS;
goto out_err;
vio = vvp_env_io(env);
-
vio->u.fault.ft_vma = vma;
+ vio->u.fault.ft_vmpage = NULL;
vio->u.fault.nopage.ft_address = address;
vio->u.fault.nopage.ft_type = type;
result = cl_io_loop(env, io);
-out_err:
- if (result == 0) {
- LASSERT(io->u.ci_fault.ft_page != NULL);
- page = vio->u.fault.ft_vmpage;
- } else {
- if (result == -ENOMEM)
- page = NOPAGE_OOM;
+ page = vio->u.fault.ft_vmpage;
+ if (page != NULL) {
+ LASSERT(PageLocked(page));
+ unlock_page(page);
+
+ if (result != 0)
+ page_cache_release(page);
}
+ LASSERT(ergo(result == 0, io->u.ci_fault.ft_page != NULL));
+out_err:
+ if (result != 0)
+ page = result == -ENOMEM ? NOPAGE_OOM : NOPAGE_SIGBUS;
+
vma->vm_flags &= ~VM_RAND_READ;
vma->vm_flags |= ra_flags;
{
struct lu_env *env;
struct cl_io *io;
- struct vvp_io *vio = NULL;
+ struct vvp_io *vio;
unsigned long ra_flags;
struct cl_env_nest nest;
int result;
goto out_err;
vio = vvp_env_io(env);
-
vio->u.fault.ft_vma = vma;
+ vio->u.fault.ft_vmpage = NULL;
vio->u.fault.fault.ft_vmf = vmf;
result = cl_io_loop(env, io);
- fault_ret = vio->u.fault.fault.ft_flags;
+ if (unlikely(result != 0 && vio->u.fault.ft_vmpage != NULL)) {
+ struct page *vmpage = vio->u.fault.ft_vmpage;
+
+ LASSERT((vio->u.fault.fault.ft_flags & VM_FAULT_LOCKED) &&
+ PageLocked(vmpage));
+ unlock_page(vmpage);
+ page_cache_release(vmpage);
+ vmf->page = NULL;
+ }
+ fault_ret = vio->u.fault.fault.ft_flags;
out_err:
if (result != 0)
fault_ret |= VM_FAULT_ERROR;
ENTRY;
LASSERT(vma->vm_file);
- LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0);
- atomic_inc(&vob->cob_mmap_cnt);
+ LASSERT(cfs_atomic_read(&vob->cob_mmap_cnt) >= 0);
+ cfs_atomic_inc(&vob->cob_mmap_cnt);
EXIT;
}
ENTRY;
LASSERT(vma->vm_file);
- atomic_dec(&vob->cob_mmap_cnt);
- LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0);
+ cfs_atomic_dec(&vob->cob_mmap_cnt);
+ LASSERT(cfs_atomic_read(&vob->cob_mmap_cnt) >= 0);
EXIT;
}