* \param env - corespondent lu_env to processing
* \param vma - virtual memory area addressed to page fault
* \param index - page index corespondent to fault.
- * \parm ra_flags - vma readahead flags.
*
* \return error codes from cl_io_init.
*/
static struct cl_io *
-ll_fault_io_init(struct lu_env *env, struct vm_area_struct *vma,
- pgoff_t index, unsigned long *ra_flags)
+ll_fault_io_init(struct lu_env *env, struct vm_area_struct *vma, pgoff_t index)
{
struct file *file = vma->vm_file;
struct inode *inode = file_inode(file);
int rc;
ENTRY;
- if (ll_file_nolock(file))
- RETURN(ERR_PTR(-EOPNOTSUPP));
+ if (ll_file_nolock(file))
+ RETURN(ERR_PTR(-EOPNOTSUPP));
restart:
io = vvp_env_thread_io(env);
- io->ci_obj = ll_i2info(inode)->lli_clob;
- LASSERT(io->ci_obj != NULL);
-
- fio = &io->u.ci_fault;
- fio->ft_index = index;
- fio->ft_executable = vma->vm_flags&VM_EXEC;
-
- /*
- * disable VM_SEQ_READ and use VM_RAND_READ to make sure that
- * the kernel will not read other pages not covered by ldlm in
- * filemap_nopage. we do our readahead in ll_readpage.
- */
- if (ra_flags != NULL)
- *ra_flags = vma->vm_flags & (VM_RAND_READ|VM_SEQ_READ);
- vma->vm_flags &= ~VM_SEQ_READ;
- vma->vm_flags |= VM_RAND_READ;
-
- CDEBUG(D_MMAP, "vm_flags: %lx (%lu %d)\n", vma->vm_flags,
- fio->ft_index, fio->ft_executable);
+ io->ci_obj = ll_i2info(inode)->lli_clob;
+ LASSERT(io->ci_obj != NULL);
+
+ fio = &io->u.ci_fault;
+ fio->ft_index = index;
+ fio->ft_executable = vma->vm_flags & VM_EXEC;
+
+ CDEBUG(D_MMAP,
+ DFID": vma=%p start=%#lx end=%#lx vm_flags=%#lx idx=%lu\n",
+ PFID(&ll_i2info(inode)->lli_fid), vma, vma->vm_start,
+ vma->vm_end, vma->vm_flags, fio->ft_index);
+
+ if (vma->vm_flags & VM_SEQ_READ)
+ io->ci_seq_read = 1;
+ else if (vma->vm_flags & VM_RAND_READ)
+ io->ci_rand_read = 1;
rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
if (rc == 0) {
struct vvp_io *vio = vvp_env_io(env);
- struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ struct ll_file_data *fd = file->private_data;
LASSERT(vio->vui_cl.cis_io == io);
struct vvp_io *vio;
int result;
__u16 refcheck;
- sigset_t set;
+ sigset_t old, new;
struct inode *inode = NULL;
struct ll_inode_info *lli;
ENTRY;
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = ll_fault_io_init(env, vma, vmpage->index, NULL);
+ io = ll_fault_io_init(env, vma, vmpage->index);
if (IS_ERR(io))
GOTO(out, result = PTR_ERR(io));
vio->u.fault.ft_vma = vma;
vio->u.fault.ft_vmpage = vmpage;
- set = cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM));
+ siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+ sigprocmask(SIG_BLOCK, &new, &old);
inode = vvp_object_inode(io->ci_obj);
lli = ll_i2info(inode);
result = cl_io_loop(env, io);
- cfs_restore_sigs(set);
+ sigprocmask(SIG_SETMASK, &old, NULL);
if (result == 0) {
lock_page(vmpage);
struct cl_io *io;
struct vvp_io *vio = NULL;
struct page *vmpage;
- unsigned long ra_flags;
int result = 0;
int fault_ret = 0;
__u16 refcheck;
if (ll_sbi_has_fast_read(ll_i2sbi(file_inode(vma->vm_file)))) {
/* do fast fault */
+ bool has_retry = vmf->flags & FAULT_FLAG_RETRY_NOWAIT;
+
+ /* To avoid loops, instruct downstream to not drop mmap_sem */
+ vmf->flags |= FAULT_FLAG_RETRY_NOWAIT;
ll_cl_add(vma->vm_file, env, NULL, LCC_MMAP);
fault_ret = ll_filemap_fault(vma, vmf);
ll_cl_remove(vma->vm_file, env);
+ if (!has_retry)
+ vmf->flags &= ~FAULT_FLAG_RETRY_NOWAIT;
/* - If there is no error, then the page was found in cache and
* uptodate;
* - If VM_FAULT_RETRY is set, the page existed but failed to
- * lock. It will return to kernel and retry;
+ * lock. We will try slow path to avoid loops.
* - Otherwise, it should try normal fault under DLM lock. */
- if ((fault_ret & VM_FAULT_RETRY) ||
+ if (!(fault_ret & VM_FAULT_RETRY) &&
!(fault_ret & VM_FAULT_ERROR))
GOTO(out, result = 0);
fault_ret = 0;
}
- io = ll_fault_io_init(env, vma, vmf->pgoff, &ra_flags);
+ io = ll_fault_io_init(env, vma, vmf->pgoff);
if (IS_ERR(io))
GOTO(out, result = PTR_ERR(io));
}
cl_io_fini(env, io);
- vma->vm_flags |= ra_flags;
-
out:
cl_env_put(env, &refcheck);
if (result != 0 && !(fault_ret & VM_FAULT_RETRY))
bool cached;
vm_fault_t result;
ktime_t kstart = ktime_get();
- sigset_t set;
+ sigset_t old, new;
result = pcc_fault(vma, vmf, &cached);
if (cached)
goto out;
+ CDEBUG(D_MMAP, DFID": vma=%p start=%#lx end=%#lx vm_flags=%#lx\n",
+ PFID(&ll_i2info(file_inode(vma->vm_file))->lli_fid),
+ vma, vma->vm_start, vma->vm_end, vma->vm_flags);
+
/* Only SIGKILL and SIGTERM is allowed for fault/nopage/mkwrite
* so that it can be killed by admin but not cause segfault by
- * other signals. */
- set = cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM));
+ * other signals.
+ */
+ siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+ sigprocmask(SIG_BLOCK, &new, &old);
/* make sure offset is not a negative number */
if (vmf->pgoff > (MAX_LFS_FILESIZE >> PAGE_SHIFT))
return VM_FAULT_SIGBUS;
+
restart:
result = ll_fault0(vma, vmf);
if (vmf->page &&
!(result & (VM_FAULT_RETRY | VM_FAULT_ERROR | VM_FAULT_LOCKED))) {
- struct page *vmpage = vmf->page;
+ struct page *vmpage = vmf->page;
- /* check if this page has been truncated */
- lock_page(vmpage);
- if (unlikely(vmpage->mapping == NULL)) { /* unlucky */
- unlock_page(vmpage);
+ /* check if this page has been truncated */
+ lock_page(vmpage);
+ if (unlikely(vmpage->mapping == NULL)) { /* unlucky */
+ unlock_page(vmpage);
put_page(vmpage);
- vmf->page = NULL;
+ vmf->page = NULL;
- if (!printed && ++count > 16) {
- CWARN("the page is under heavy contention,"
- "maybe your app(%s) needs revising :-)\n",
- current->comm);
- printed = true;
- }
+ if (!printed && ++count > 16) {
+ CWARN("the page is under heavy contention, maybe your app(%s) needs revising :-)\n",
+ current->comm);
+ printed = true;
+ }
- goto restart;
- }
+ goto restart;
+ }
- result |= VM_FAULT_LOCKED;
- }
- cfs_restore_sigs(set);
+ result |= VM_FAULT_LOCKED;
+ }
+ sigprocmask(SIG_SETMASK, &old, NULL);
out:
if (vmf->page && result == VM_FAULT_LOCKED) {
ll_rw_stats_tally(ll_i2sbi(file_inode(vma->vm_file)),
- current->pid, LUSTRE_FPRIVATE(vma->vm_file),
+ current->pid, vma->vm_file->private_data,
cl_offset(NULL, vmf->page->index), PAGE_SIZE,
READ);
ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)),
if (!printed && ++count > 16) {
const struct dentry *de = file_dentry(vma->vm_file);
- CWARN("app(%s): the page %lu of file "DFID" is under"
- " heavy contention\n",
+ CWARN("app(%s): the page %lu of file "DFID" is under heavy contention\n",
current->comm, vmf->pgoff,
PFID(ll_inode2fid(de->d_inode)));
- printed = true;
- }
- } while (retry);
-
- switch(result) {
- case 0:
- LASSERT(PageLocked(vmf->page));
- result = VM_FAULT_LOCKED;
- break;
- case -ENODATA:
- case -EFAULT:
- result = VM_FAULT_NOPAGE;
- break;
- case -ENOMEM:
- result = VM_FAULT_OOM;
- break;
- case -EAGAIN:
- result = VM_FAULT_RETRY;
- break;
- default:
- result = VM_FAULT_SIGBUS;
- break;
- }
+ printed = true;
+ }
+ } while (retry);
+
+ switch (result) {
+ case 0:
+ LASSERT(PageLocked(vmf->page));
+ result = VM_FAULT_LOCKED;
+ break;
+ case -ENODATA:
+ case -EFAULT:
+ result = VM_FAULT_NOPAGE;
+ break;
+ case -ENOMEM:
+ result = VM_FAULT_OOM;
+ break;
+ case -EAGAIN:
+ result = VM_FAULT_RETRY;
+ break;
+ default:
+ result = VM_FAULT_SIGBUS;
+ break;
+ }
out:
if (result == VM_FAULT_LOCKED) {
ll_rw_stats_tally(ll_i2sbi(file_inode(vma->vm_file)),
- current->pid, LUSTRE_FPRIVATE(vma->vm_file),
+ current->pid, vma->vm_file->private_data,
cl_offset(NULL, vmf->page->index), PAGE_SIZE,
WRITE);
ll_stats_ops_tally(ll_i2sbi(file_inode(vma->vm_file)),
if (mapping_mapped(mapping)) {
rc = 0;
unmap_mapping_range(mapping, first + PAGE_SIZE - 1,
- last - first + 1, 1);
+ last - first + 1, 0);
}
RETURN(rc);
int rc;
ENTRY;
+ CDEBUG(D_VFSTRACE | D_MMAP,
+ "VFS_Op: fid="DFID" vma=%p start=%#lx end=%#lx vm_flags=%#lx\n",
+ PFID(&ll_i2info(inode)->lli_fid),
+ vma, vma->vm_start, vma->vm_end, vma->vm_flags);
if (ll_file_nolock(file))
RETURN(-EOPNOTSUPP);