* \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) {
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));
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;
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))
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.
/* 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 &&
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);
*/
static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
struct ll_readahead_state *ras, pgoff_t index,
- enum ras_update_flags flags)
+ enum ras_update_flags flags, struct cl_io *io)
{
struct ll_ra_info *ra = &sbi->ll_ra_info;
bool hit = flags & LL_RAS_HIT;
if (ras->ras_no_miss_check)
GOTO(out_unlock, 0);
+ if (io && io->ci_rand_read)
+ GOTO(out_unlock, 0);
+
+ if (io && io->ci_seq_read) {
+ if (!hit) {
+ /* to avoid many small read RPC here */
+ ras->ras_window_pages = sbi->ll_ra_info.ra_range_pages;
+ ll_ra_stats_inc_sbi(sbi, RA_STAT_MMAP_RANGE_READ);
+ }
+ goto skip;
+ }
+
if (flags & LL_RAS_MMAP) {
unsigned long ra_pages;
flags |= LL_RAS_HIT;
if (!vio->vui_ra_valid)
flags |= LL_RAS_MMAP;
- ras_update(sbi, inode, ras, vvp_index(vpg), flags);
+ ras_update(sbi, inode, ras, vvp_index(vpg), flags, io);
}
cl_2queue_init(queue);
io_start_index = cl_index(io->ci_obj, io->u.ci_rw.crw_pos);
io_end_index = cl_index(io->ci_obj, io->u.ci_rw.crw_pos +
io->u.ci_rw.crw_count - 1);
- if (ll_readahead_enabled(sbi) && ras) {
+ if (ll_readahead_enabled(sbi) && ras && !io->ci_rand_read) {
pgoff_t skip_index = 0;
if (ras->ras_next_readahead_idx < vvp_index(vpg))
/* For fast read, it updates read ahead state only
* if the page is hit in cache because non cache page
* case will be handled by slow read later. */
- ras_update(sbi, inode, ras, vvp_index(vpg), flags);
+ ras_update(sbi, inode, ras, vvp_index(vpg), flags, io);
/* avoid duplicate ras_update() call */
vpg->vpg_ra_updated = 1;