Whamcloud - gitweb
LU-6215 kernel: use f_path for inode dentry
[fs/lustre-release.git] / lustre / llite / llite_mmap.c
index 085dc7e..bc41042 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, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include <lustre_lite.h>
 #include "llite_internal.h"
-#include <linux/lustre_compat25.h>
+#include <lustre_compat.h>
 
-struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
-                       int *type);
-
-static 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)
 {
-        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;
+                              ~PAGE_MASK;
 }
 
 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
@@ -102,13 +98,13 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
  * \retval EINVAL if env can't allocated
  * \return other error codes from cl_io_init.
  */
-struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
-                              struct lu_env **env_ret,
-                              struct cl_env_nest *nest,
-                              pgoff_t index, unsigned long *ra_flags)
+static struct cl_io *
+ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
+                struct cl_env_nest *nest, pgoff_t index,
+                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;
@@ -132,7 +128,7 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
 
         *env_ret = env;
 
-        io = ccc_env_thread_io(env);
+       io = vvp_env_thread_io(env);
         io->ci_obj = ll_i2info(inode)->lli_clob;
         LASSERT(io->ci_obj != NULL);
 
@@ -155,15 +151,15 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
 
        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);
@@ -210,7 +206,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);
 
@@ -221,9 +217,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);
@@ -319,11 +312,22 @@ 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.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);
 
                result = cl_io_loop(env, io);
 
-               fault_ret = vio->u.fault.fault.ft_flags;
+               ll_cl_remove(vma->vm_file, env);
+
+               /* ft_flags are only valid if we reached
+                * the call to filemap_fault */
+               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) {
                        page_cache_release(vmpage);
@@ -395,10 +399,12 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
                 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);
@@ -428,17 +434,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;
 }
 
@@ -447,24 +453,16 @@ 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;
 }
 
-/* return the user space pointer that maps to a file offset via a vma */
-static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte)
-{
-       return vma->vm_start +
-              (byte - ((__u64)vma->vm_pgoff << PAGE_CACHE_SHIFT));
-
-}
-
 /* XXX put nice comment here.  talk about __free_pte -> dirty pages and
  * nopage's reference passing to the pte */
 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last)
@@ -482,7 +480,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last)
         RETURN(rc);
 }
 
-static struct vm_operations_struct ll_file_vm_ops = {
+static const struct vm_operations_struct ll_file_vm_ops = {
        .fault                  = ll_fault,
        .page_mkwrite           = ll_page_mkwrite,
        .open                   = ll_vm_open,
@@ -491,7 +489,7 @@ static 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;