Whamcloud - gitweb
LU-988 clio: use OSC object's m/a/ctime when build write RPC
[fs/lustre-release.git] / lustre / lclient / lcommon_cl.c
index 05c348d..19cb4aa 100644 (file)
@@ -457,6 +457,22 @@ int ccc_conf_set(const struct lu_env *env, struct cl_object *obj,
         return 0;
 }
 
+static void ccc_object_size_lock(struct cl_object *obj)
+{
+       struct inode *inode = ccc_object_inode(obj);
+
+       cl_isize_lock(inode);
+       cl_object_attr_lock(obj);
+}
+
+static void ccc_object_size_unlock(struct cl_object *obj)
+{
+       struct inode *inode = ccc_object_inode(obj);
+
+       cl_object_attr_unlock(obj);
+       cl_isize_unlock(inode);
+}
+
 /*****************************************************************************
  *
  * Page operations.
@@ -684,8 +700,7 @@ void ccc_lock_state(const struct lu_env *env,
                  * cancel the result of the truncate.  Getting the
                  * ll_inode_size_lock() after the enqueue maintains the DLM
                  * -> ll_inode_size_lock() acquiring order. */
-                cl_isize_lock(inode, 0);
-                cl_object_attr_lock(obj);
+               ccc_object_size_lock(obj);
                 rc = cl_object_attr_get(env, obj, attr);
                 if (rc == 0) {
                         if (lock->cll_descr.cld_start == 0 &&
@@ -702,10 +717,9 @@ void ccc_lock_state(const struct lu_env *env,
                 } else {
                         CL_LOCK_DEBUG(D_INFO, env, lock, "attr_get: %d\n", rc);
                 }
-                cl_object_attr_unlock(obj);
-                cl_isize_unlock(inode, 0);
-        }
-        EXIT;
+               ccc_object_size_unlock(obj);
+       }
+       EXIT;
 }
 
 /*****************************************************************************
@@ -825,22 +839,6 @@ void ccc_io_advance(const struct lu_env *env,
         }
 }
 
-static void ccc_object_size_lock(struct cl_object *obj)
-{
-        struct inode *inode = ccc_object_inode(obj);
-
-        cl_isize_lock(inode, 0);
-        cl_object_attr_lock(obj);
-}
-
-static void ccc_object_size_unlock(struct cl_object *obj)
-{
-        struct inode *inode = ccc_object_inode(obj);
-
-        cl_object_attr_unlock(obj);
-        cl_isize_unlock(inode, 0);
-}
-
 /**
  * Helper function that if necessary adjusts file size (inode->i_size), when
  * position at the offset \a pos is accessed. File size can be arbitrary stale
@@ -978,28 +976,26 @@ void ccc_req_attr_set(const struct lu_env *env,
         struct obdo  *oa;
         obd_flag      valid_flags;
 
-        oa = attr->cra_oa;
-        inode = ccc_object_inode(obj);
-        valid_flags = OBD_MD_FLTYPE|OBD_MD_FLATIME;
-
-        if (flags != (obd_valid)~0ULL)
-                valid_flags |= OBD_MD_FLMTIME|OBD_MD_FLCTIME|OBD_MD_FLATIME;
-        else {
-                LASSERT(attr->cra_capa == NULL);
-                attr->cra_capa = cl_capa_lookup(inode,
-                                                slice->crs_req->crq_type);
-        }
-
-        if (slice->crs_req->crq_type == CRT_WRITE) {
-                if (flags & OBD_MD_FLEPOCH) {
-                        oa->o_valid |= OBD_MD_FLEPOCH;
-                        oa->o_ioepoch = cl_i2info(inode)->lli_ioepoch;
-                        valid_flags |= OBD_MD_FLMTIME|OBD_MD_FLCTIME|
-                                OBD_MD_FLUID|OBD_MD_FLGID;
-                }
-        }
-        obdo_from_inode(oa, inode, valid_flags & flags);
-        obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid);
+       oa = attr->cra_oa;
+       inode = ccc_object_inode(obj);
+       valid_flags = OBD_MD_FLTYPE;
+
+       if ((flags & OBD_MD_FLOSSCAPA) != 0) {
+               LASSERT(attr->cra_capa == NULL);
+               attr->cra_capa = cl_capa_lookup(inode,
+                                               slice->crs_req->crq_type);
+       }
+
+       if (slice->crs_req->crq_type == CRT_WRITE) {
+               if (flags & OBD_MD_FLEPOCH) {
+                       oa->o_valid |= OBD_MD_FLEPOCH;
+                       oa->o_ioepoch = cl_i2info(inode)->lli_ioepoch;
+                       valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME |
+                                      OBD_MD_FLUID | OBD_MD_FLGID;
+               }
+       }
+       obdo_from_inode(oa, inode, valid_flags & flags);
+       obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid);
 #ifdef __KERNEL__
        memcpy(attr->cra_jobid, cl_i2info(inode)->lli_jobid,
               JOBSTATS_JOBID_SIZE);
@@ -1336,3 +1332,13 @@ __u32 cl_fid_build_gen(const struct lu_fid *fid)
         gen = (fid_flatten(fid) >> 32);
         RETURN(gen);
 }
+
+struct lov_stripe_md *ccc_inode_lsm_get(struct inode *inode)
+{
+       return lov_lsm_get(cl_i2info(inode)->lli_clob);
+}
+
+void inline ccc_inode_lsm_put(struct inode *inode, struct lov_stripe_md *lsm)
+{
+       lov_lsm_put(cl_i2info(inode)->lli_clob, lsm);
+}