Whamcloud - gitweb
LU-1118 llite: Invoke file_update_time in page_mkwrite
[fs/lustre-release.git] / lustre / llite / llite_mmap.c
index 364a4a1..7d7177c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #define DEBUG_SUBSYSTEM S_LLITE
 
 #include "llite_internal.h"
-#include <linux/lustre_compat25.h>
+#include <lustre_compat.h>
 
 static const struct vm_operations_struct ll_file_vm_ops;
 
-void policy_from_vma(ldlm_policy_data_t *policy,
-                            struct vm_area_struct *vma, unsigned long addr,
-                            size_t count)
+void policy_from_vma(union ldlm_policy_data *policy, struct vm_area_struct *vma,
+                    unsigned long addr, size_t count)
 {
-        policy->l_extent.start = ((addr - vma->vm_start) & CFS_PAGE_MASK) +
+       policy->l_extent.start = ((addr - vma->vm_start) & PAGE_MASK) +
                                 (vma->vm_pgoff << PAGE_CACHE_SHIFT);
-        policy->l_extent.end = (policy->l_extent.start + count - 1) |
-                               ~CFS_PAGE_MASK;
+       policy->l_extent.end = (policy->l_extent.start + count - 1) |
+                              ~PAGE_MASK;
 }
 
 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
@@ -104,7 +103,7 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
                 unsigned long *ra_flags)
 {
        struct file            *file = vma->vm_file;
-       struct inode           *inode = file->f_dentry->d_inode;
+       struct inode           *inode = file->f_path.dentry->d_inode;
        struct cl_io           *io;
        struct cl_fault_io     *fio;
        struct lu_env          *env;
@@ -128,7 +127,8 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
 
         *env_ret = env;
 
-        io = ccc_env_thread_io(env);
+restart:
+       io = vvp_env_thread_io(env);
         io->ci_obj = ll_i2info(inode)->lli_clob;
         LASSERT(io->ci_obj != NULL);
 
@@ -151,23 +151,26 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
 
        rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
        if (rc == 0) {
-               struct ccc_io *cio = ccc_env_io(env);
+               struct vvp_io *vio = vvp_env_io(env);
                struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
 
-               LASSERT(cio->cui_cl.cis_io == io);
+               LASSERT(vio->vui_cl.cis_io == io);
 
                /* mmap lock must be MANDATORY it has to cache
                 * pages. */
                io->ci_lockreq = CILR_MANDATORY;
-               cio->cui_fd = fd;
+               vio->vui_fd = fd;
        } else {
                LASSERT(rc < 0);
                cl_io_fini(env, io);
+               if (io->ci_need_restart)
+                       goto restart;
+
                cl_env_nested_put(nest, env);
                io = ERR_PTR(rc);
        }
 
-       return io;
+       RETURN(io);
 }
 
 /* Sharing code of page_mkwrite method for rhel5 and rhel6 */
@@ -206,7 +209,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
        /* we grab lli_trunc_sem to exclude truncate case.
         * Otherwise, we could add dirty pages into osc cache
         * while truncate is on-going. */
-       inode = ccc_object_inode(io->ci_obj);
+       inode = vvp_object_inode(io->ci_obj);
        lli = ll_i2info(inode);
        down_read(&lli->lli_trunc_sem);
 
@@ -217,9 +220,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
        cfs_restore_sigs(set);
 
         if (result == 0) {
-               struct inode *inode = vma->vm_file->f_dentry->d_inode;
-               struct ll_inode_info *lli = ll_i2info(inode);
-
                 lock_page(vmpage);
                 if (vmpage->mapping == NULL) {
                         unlock_page(vmpage);
@@ -246,11 +246,8 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
                         result = -EAGAIN;
                 }
 
-               if (result == 0) {
-                       spin_lock(&lli->lli_lock);
-                       lli->lli_flags |= LLIF_DATA_MODIFIED;
-                       spin_unlock(&lli->lli_lock);
-               }
+               if (result == 0)
+                       ll_file_set_flag(lli, LLIF_DATA_MODIFIED);
         }
         EXIT;
 
@@ -315,9 +312,9 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
                vio = vvp_env_io(env);
                vio->u.fault.ft_vma       = vma;
                vio->u.fault.ft_vmpage    = NULL;
-               vio->u.fault.fault.ft_vmf = vmf;
-               vio->u.fault.fault.ft_flags = 0;
-               vio->u.fault.fault.ft_flags_valid = 0;
+               vio->u.fault.ft_vmf = vmf;
+               vio->u.fault.ft_flags = 0;
+               vio->u.fault.ft_flags_valid = 0;
 
                /* May call ll_readpage() */
                ll_cl_add(vma->vm_file, env, io);
@@ -328,8 +325,8 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
 
                /* ft_flags are only valid if we reached
                 * the call to filemap_fault */
-               if (vio->u.fault.fault.ft_flags_valid)
-                       fault_ret = vio->u.fault.fault.ft_flags;
+               if (vio->u.fault.ft_flags_valid)
+                       fault_ret = vio->u.fault.ft_flags;
 
                vmpage = vio->u.fault.ft_vmpage;
                if (result != 0 && vmpage != NULL) {
@@ -397,15 +394,18 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
         bool retry;
         int result;
 
+       file_update_time(vma->vm_file);
         do {
                 retry = false;
                 result = ll_page_mkwrite0(vma, vmf->page, &retry);
 
                 if (!printed && ++count > 16) {
+                       const struct dentry *de = vma->vm_file->f_path.dentry;
+
                        CWARN("app(%s): the page %lu of file "DFID" is under"
                              " heavy contention\n",
                              current->comm, vmf->pgoff,
-                             PFID(ll_inode2fid(vma->vm_file->f_dentry->d_inode)));
+                             PFID(ll_inode2fid(de->d_inode)));
                         printed = true;
                 }
         } while (retry);
@@ -435,17 +435,17 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 
 /**
  *  To avoid cancel the locks covering mmapped region for lock cache pressure,
- *  we track the mapped vma count in ccc_object::cob_mmap_cnt.
+ *  we track the mapped vma count in vvp_object::vob_mmap_cnt.
  */
 static void ll_vm_open(struct vm_area_struct * vma)
 {
-       struct inode *inode    = vma->vm_file->f_dentry->d_inode;
-       struct ccc_object *vob = cl_inode2ccc(inode);
+       struct inode *inode    = vma->vm_file->f_path.dentry->d_inode;
+       struct vvp_object *vob = cl_inode2vvp(inode);
 
        ENTRY;
        LASSERT(vma->vm_file);
-       LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0);
-       atomic_inc(&vob->cob_mmap_cnt);
+       LASSERT(atomic_read(&vob->vob_mmap_cnt) >= 0);
+       atomic_inc(&vob->vob_mmap_cnt);
        EXIT;
 }
 
@@ -454,13 +454,13 @@ static void ll_vm_open(struct vm_area_struct * vma)
  */
 static void ll_vm_close(struct vm_area_struct *vma)
 {
-       struct inode      *inode = vma->vm_file->f_dentry->d_inode;
-       struct ccc_object *vob   = cl_inode2ccc(inode);
+       struct inode      *inode = vma->vm_file->f_path.dentry->d_inode;
+       struct vvp_object *vob   = cl_inode2vvp(inode);
 
        ENTRY;
        LASSERT(vma->vm_file);
-       atomic_dec(&vob->cob_mmap_cnt);
-       LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0);
+       atomic_dec(&vob->vob_mmap_cnt);
+       LASSERT(atomic_read(&vob->vob_mmap_cnt) >= 0);
        EXIT;
 }
 
@@ -490,7 +490,7 @@ static const struct vm_operations_struct ll_file_vm_ops = {
 
 int ll_file_mmap(struct file *file, struct vm_area_struct * vma)
 {
-        struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
         int rc;
         ENTRY;