Whamcloud - gitweb
LU-5710 all: second batch of corrected typos and grammar errors
[fs/lustre-release.git] / lustre / llite / glimpse.c
index 70c3840..e0c1b71 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -52,6 +52,7 @@
 
 #include "cl_object.h"
 #include "llite_internal.h"
+#include "vvp_internal.h"
 
 static const struct cl_lock_descr whole_file = {
         .cld_start = 0,
@@ -60,7 +61,7 @@ static const struct cl_lock_descr whole_file = {
 };
 
 /*
- * Check whether file has possible unwriten pages.
+ * Check whether file has possible unwritten pages.
  *
  * \retval 1    file is mmap-ed or has dirty pages
  *         0    otherwise
@@ -68,101 +69,100 @@ static const struct cl_lock_descr whole_file = {
 blkcnt_t dirty_cnt(struct inode *inode)
 {
         blkcnt_t cnt = 0;
-        struct ccc_object *vob = cl_inode2ccc(inode);
+       struct vvp_object *vob = cl_inode2vvp(inode);
         void              *results[1];
 
         if (inode->i_mapping != NULL)
                 cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->page_tree,
                                                   results, 0, 1,
                                                   PAGECACHE_TAG_DIRTY);
-       if (cnt == 0 && atomic_read(&vob->cob_mmap_cnt) > 0)
+       if (cnt == 0 && atomic_read(&vob->vob_mmap_cnt) > 0)
                cnt = 1;
 
         return (cnt > 0) ? 1 : 0;
 }
 
 int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io,
-                    struct inode *inode, struct cl_object *clob, int agl)
+                   struct inode *inode, struct cl_object *clob, int agl)
 {
-        struct cl_inode_info *lli   = cl_i2info(inode);
+       struct ll_inode_info *lli   = ll_i2info(inode);
         const struct lu_fid  *fid   = lu_object_fid(&clob->co_lu);
         int result;
 
         ENTRY;
         result = 0;
-        if (!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)) {
-                CDEBUG(D_DLMTRACE, "Glimpsing inode "DFID"\n", PFID(fid));
-               if (lli->lli_has_smd) {
-                       struct cl_lock *lock = ccc_env_lock(env);
-                       struct cl_lock_descr *descr = &lock->cll_descr;
 
-                        /* NOTE: this looks like DLM lock request, but it may
-                         *       not be one. Due to CEF_ASYNC flag (translated
-                         *       to LDLM_FL_HAS_INTENT by osc), this is
-                         *       glimpse request, that won't revoke any
-                         *       conflicting DLM locks held. Instead,
-                         *       ll_glimpse_callback() will be called on each
-                         *       client holding a DLM lock against this file,
-                         *       and resulting size will be returned for each
-                         *       stripe. DLM lock on [0, EOF] is acquired only
-                         *       if there were no conflicting locks. If there
-                         *       were conflicting locks, enqueuing or waiting
-                         *       fails with -ENAVAIL, but valid inode
-                         *       attributes are returned anyway. */
-                        *descr = whole_file;
-                        descr->cld_obj   = clob;
-                       descr->cld_mode  = CLM_READ;
-                       descr->cld_enq_flags = CEF_ASYNC | CEF_MUST;
-                       if (agl)
-                               descr->cld_enq_flags |= CEF_AGL;
-                       /*
-                        * CEF_ASYNC is used because glimpse sub-locks cannot
-                        * deadlock (because they never conflict with other
-                        * locks) and, hence, can be enqueued out-of-order.
-                        *
-                        * CEF_MUST protects glimpse lock from conversion into
-                        * a lockless mode.
-                        */
-                       result = cl_lock_request(env, io, lock);
-                       if (result < 0)
-                               RETURN(result);
+       CDEBUG(D_DLMTRACE, "Glimpsing inode "DFID"\n", PFID(fid));
+       if (lli->lli_has_smd) {
+               struct cl_lock *lock = vvp_env_lock(env);
+               struct cl_lock_descr *descr = &lock->cll_descr;
 
-                       if (!agl) {
-                               ll_merge_attr(env, inode);
-                               if (cl_isize_read(inode) > 0 &&
-                                   inode->i_blocks == 0) {
-                                       /*
-                                        * LU-417: Add dirty pages block count
-                                        * lest i_blocks reports 0, some "cp" or
-                                        * "tar" may think it's a completely
-                                        * sparse file and skip it.
-                                        */
-                                       inode->i_blocks = dirty_cnt(inode);
-                               }
-                       }
-                       cl_lock_release(env, lock);
-               } else {
-                       CDEBUG(D_DLMTRACE, "No objects for inode\n");
+               /* NOTE: this looks like DLM lock request, but it may
+                *       not be one. Due to CEF_ASYNC flag (translated
+                *       to LDLM_FL_HAS_INTENT by osc), this is
+                *       glimpse request, that won't revoke any
+                *       conflicting DLM locks held. Instead,
+                *       ll_glimpse_callback() will be called on each
+                *       client holding a DLM lock against this file,
+                *       and resulting size will be returned for each
+                *       stripe. DLM lock on [0, EOF] is acquired only
+                *       if there were no conflicting locks. If there
+                *       were conflicting locks, enqueuing or waiting
+                *       fails with -ENAVAIL, but valid inode
+                *       attributes are returned anyway. */
+               *descr = whole_file;
+               descr->cld_obj = clob;
+               descr->cld_mode = CLM_READ;
+               descr->cld_enq_flags = CEF_ASYNC | CEF_MUST;
+               if (agl)
+                       descr->cld_enq_flags |= CEF_AGL;
+               /*
+                * CEF_ASYNC is used because glimpse sub-locks cannot
+                * deadlock (because they never conflict with other
+                * locks) and, hence, can be enqueued out-of-order.
+                *
+                * CEF_MUST protects glimpse lock from conversion into
+                * a lockless mode.
+                */
+               result = cl_lock_request(env, io, lock);
+               if (result < 0)
+                       RETURN(result);
+
+               if (!agl) {
                        ll_merge_attr(env, inode);
+                       if (i_size_read(inode) > 0 && inode->i_blocks == 0) {
+                               /*
+                                * LU-417: Add dirty pages block count
+                                * lest i_blocks reports 0, some "cp" or
+                                * "tar" may think it's a completely
+                                * sparse file and skip it.
+                                */
+                               inode->i_blocks = dirty_cnt(inode);
+                       }
                }
+
+               cl_lock_release(env, lock);
+       } else {
+               CDEBUG(D_DLMTRACE, "No objects for inode\n");
+               ll_merge_attr(env, inode);
        }
 
        RETURN(result);
 }
 
 static int cl_io_get(struct inode *inode, struct lu_env **envout,
-                     struct cl_io **ioout, int *refcheck)
+                    struct cl_io **ioout, int *refcheck)
 {
-        struct lu_env          *env;
-        struct cl_io           *io;
-        struct cl_inode_info   *lli = cl_i2info(inode);
-        struct cl_object       *clob = lli->lli_clob;
-        int result;
+       struct lu_env           *env;
+       struct cl_io            *io;
+       struct ll_inode_info    *lli = ll_i2info(inode);
+       struct cl_object        *clob = lli->lli_clob;
+       int result;
 
-        if (S_ISREG(cl_inode_mode(inode))) {
+       if (S_ISREG(inode->i_mode)) {
                 env = cl_env_get(refcheck);
                 if (!IS_ERR(env)) {
-                        io = ccc_env_thread_io(env);
+                       io = vvp_env_thread_io(env);
                         io->ci_obj = clob;
                         *envout = env;
                         *ioout  = io;
@@ -227,7 +227,7 @@ int cl_local_size(struct inode *inode)
 
         ENTRY;
 
-       if (!cl_i2info(inode)->lli_has_smd)
+       if (!ll_i2info(inode)->lli_has_smd)
                 RETURN(0);
 
         result = cl_io_get(inode, &env, &io, &refcheck);
@@ -239,7 +239,7 @@ int cl_local_size(struct inode *inode)
         if (result > 0)
                 result = io->ci_result;
        else if (result == 0) {
-               struct cl_lock *lock = ccc_env_lock(env);
+               struct cl_lock *lock = vvp_env_lock(env);
 
                lock->cll_descr = whole_file;
                lock->cll_descr.cld_enq_flags = CEF_PEEK;