Whamcloud - gitweb
LU-16160 revert: "llite: clear stale page's uptodate bit"
[fs/lustre-release.git] / lustre / llite / vvp_io.c
index 3c500a5..f1cb18d 100644 (file)
@@ -1391,37 +1391,10 @@ static void vvp_io_rw_end(const struct lu_env *env,
        trunc_sem_up_read(&lli->lli_trunc_sem);
 }
 
-static void detach_and_deref_page(struct cl_page *clp, struct page *vmpage)
-{
-       if (!clp->cp_defer_detach)
-               return;
-
-       /**
-        * cl_page_delete0() took a vmpage reference, but not unlink the vmpage
-        * from its cl_page.
-        */
-       clp->cp_defer_detach = 0;
-       ClearPagePrivate(vmpage);
-       vmpage->private = 0;
-
-       put_page(vmpage);
-       refcount_dec(&clp->cp_ref);
-}
-
-static int vvp_io_kernel_fault(const struct lu_env *env,
-                              struct vvp_fault_io *cfio)
+static int vvp_io_kernel_fault(struct vvp_fault_io *cfio)
 {
        struct vm_fault *vmf = cfio->ft_vmf;
-       struct file *vmff = cfio->ft_vma->vm_file;
-       struct address_space *mapping = vmff->f_mapping;
-       struct inode *inode = mapping->host;
-       struct page *vmpage = NULL;
-       struct cl_page *clp = NULL;
-       int rc = 0;
-       ENTRY;
 
-       ll_inode_size_lock(inode);
-retry:
        cfio->ft_flags = ll_filemap_fault(cfio->ft_vma, vmf);
        cfio->ft_flags_valid = 1;
 
@@ -1436,100 +1409,25 @@ retry:
 
                cfio->ft_vmpage = vmf->page;
 
-               /**
-                * ll_filemap_fault()->ll_readpage() could get an extra cl_page
-                * reference. So we have to get the cl_page's to check its
-                * cp_fault_ref and drop the reference later.
-                */
-               clp = cl_vmpage_page(vmf->page, NULL);
-
-               GOTO(unlock, rc = 0);
-       }
-
-       /* filemap_fault() fails, vmpage is not locked */
-       if (clp == NULL) {
-               vmpage = find_get_page(mapping, vmf->pgoff);
-               if (vmpage) {
-                       lock_page(vmpage);
-                       clp = cl_vmpage_page(vmpage, NULL);
-                       unlock_page(vmpage);
-               }
+               return 0;
        }
 
        if (cfio->ft_flags & VM_FAULT_SIGBUS) {
-               pgoff_t max_idx;
-
-               /**
-                * ll_filemap_fault()->ll_readpage() could fill vmpage
-                * correctly, and unlock the vmpage, while memory pressure or
-                * truncate could detach cl_page from vmpage, and kernel
-                * filemap_fault() will wait_on_page_locked(vmpage) and find
-                * out that the vmpage has been cleared its uptodate bit,
-                * so it returns VM_FAULT_SIGBUS.
-                *
-                * In this case, we'd retry the filemap_fault()->ll_readpage()
-                * to rebuild the cl_page and fill vmpage with uptodated data.
-                */
-               if (likely(vmpage)) {
-                       bool need_retry = false;
-
-                       if (clp) {
-                               if (clp->cp_defer_detach) {
-                                       detach_and_deref_page(clp, vmpage);
-                                       /**
-                                        * check i_size to make sure it's not
-                                        * over EOF, we don't want to call
-                                        * filemap_fault() repeatedly since it
-                                        * returns VM_FAULT_SIGBUS without even
-                                        * trying if vmf->pgoff is over EOF.
-                                        */
-                                       max_idx = DIV_ROUND_UP(
-                                               i_size_read(inode), PAGE_SIZE);
-                                       if (vmf->pgoff < max_idx)
-                                               need_retry = true;
-                               }
-                               if (clp->cp_fault_ref) {
-                                       clp->cp_fault_ref = 0;
-                                       /* ref not released in ll_readpage() */
-                                       cl_page_put(env, clp);
-                               }
-                               if (need_retry)
-                                       goto retry;
-                       }
-               }
-
                CDEBUG(D_PAGE, "got addr %p - SIGBUS\n", get_vmf_address(vmf));
-               GOTO(unlock, rc = -EFAULT);
+               return -EFAULT;
        }
 
        if (cfio->ft_flags & VM_FAULT_OOM) {
                CDEBUG(D_PAGE, "got addr %p - OOM\n", get_vmf_address(vmf));
-               GOTO(unlock, rc = -ENOMEM);
+               return -ENOMEM;
        }
 
        if (cfio->ft_flags & VM_FAULT_RETRY)
-               GOTO(unlock, rc = -EAGAIN);
+               return -EAGAIN;
 
        CERROR("unknown error in page fault %d\n", cfio->ft_flags);
-       rc = -EINVAL;
-unlock:
-       ll_inode_size_unlock(inode);
-       if (clp) {
-               if (clp->cp_defer_detach && vmpage)
-                       detach_and_deref_page(clp, vmpage);
-
-               /* additional cl_page ref has been taken in ll_readpage() */
-               if (clp->cp_fault_ref) {
-                       clp->cp_fault_ref = 0;
-                       /* ref not released in ll_readpage() */
-                       cl_page_put(env, clp);
-               }
-               /* ref taken in this function */
-               cl_page_put(env, clp);
-       }
-       if (vmpage)
-               put_page(vmpage);
-       return rc;
+
+       return -EINVAL;
 }
 
 static void mkwrite_commit_callback(const struct lu_env *env, struct cl_io *io,
@@ -1570,7 +1468,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
                LASSERT(cfio->ft_vmpage != NULL);
                lock_page(cfio->ft_vmpage);
        } else {
-               result = vvp_io_kernel_fault(env, cfio);
+               result = vvp_io_kernel_fault(cfio);
                if (result != 0)
                        RETURN(result);
        }