Whamcloud - gitweb
LU-1118 llite: Invoke file_update_time in page_mkwrite
[fs/lustre-release.git] / lustre / llite / llite_mmap.c
index 41faa95..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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 static const struct vm_operations_struct ll_file_vm_ops;
 
 
 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) & PAGE_MASK) +
                                 (vma->vm_pgoff << PAGE_CACHE_SHIFT);
 {
        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) |
+       policy->l_extent.end = (policy->l_extent.start + count - 1) |
                               ~PAGE_MASK;
 }
 
                               ~PAGE_MASK;
 }
 
@@ -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;
                 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;
        struct cl_io           *io;
        struct cl_fault_io     *fio;
        struct lu_env          *env;
@@ -128,6 +127,7 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
 
         *env_ret = env;
 
 
         *env_ret = env;
 
+restart:
        io = vvp_env_thread_io(env);
         io->ci_obj = ll_i2info(inode)->lli_clob;
         LASSERT(io->ci_obj != NULL);
        io = vvp_env_thread_io(env);
         io->ci_obj = ll_i2info(inode)->lli_clob;
         LASSERT(io->ci_obj != NULL);
@@ -163,11 +163,14 @@ ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
        } else {
                LASSERT(rc < 0);
                cl_io_fini(env, io);
        } 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);
        }
 
                cl_env_nested_put(nest, env);
                io = ERR_PTR(rc);
        }
 
-       return io;
+       RETURN(io);
 }
 
 /* Sharing code of page_mkwrite method for rhel5 and rhel6 */
 }
 
 /* Sharing code of page_mkwrite method for rhel5 and rhel6 */
@@ -217,9 +220,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
        cfs_restore_sigs(set);
 
         if (result == 0) {
        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);
                 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;
                 }
 
                         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;
 
         }
         EXIT;
 
@@ -397,15 +394,18 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
         bool retry;
         int result;
 
         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) {
         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,
                        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);
                         printed = true;
                 }
         } while (retry);
@@ -439,7 +439,7 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  */
 static void ll_vm_open(struct vm_area_struct * vma)
 {
  */
 static void ll_vm_open(struct vm_area_struct * vma)
 {
-       struct inode *inode    = vma->vm_file->f_dentry->d_inode;
+       struct inode *inode    = vma->vm_file->f_path.dentry->d_inode;
        struct vvp_object *vob = cl_inode2vvp(inode);
 
        ENTRY;
        struct vvp_object *vob = cl_inode2vvp(inode);
 
        ENTRY;
@@ -454,7 +454,7 @@ static void ll_vm_open(struct vm_area_struct * vma)
  */
 static void ll_vm_close(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 inode      *inode = vma->vm_file->f_path.dentry->d_inode;
        struct vvp_object *vob   = cl_inode2vvp(inode);
 
        ENTRY;
        struct vvp_object *vob   = cl_inode2vvp(inode);
 
        ENTRY;
@@ -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)
 {
 
 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;
 
         int rc;
         ENTRY;