Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[fs/lustre-release.git] / lustre / osc / osc_object.c
index f092577..d9b2290 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * Implementation of cl_object for OSC layer.
  *
@@ -223,7 +222,9 @@ static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
                           lvb->lvb_atime, oinfo->loi_lvb.lvb_size,
                           oinfo->loi_lvb.lvb_blocks, oinfo->loi_lvb.lvb_ctime,
                           oinfo->loi_lvb.lvb_mtime, oinfo->loi_lvb.lvb_atime);
-               LASSERT(oinfo->loi_lvb.lvb_size >= oinfo->loi_kms);
+               LASSERTF(oinfo->loi_lvb.lvb_size >= oinfo->loi_kms,
+                        "lvb_size %#llx, loi_kms %#llx\n",
+                        oinfo->loi_lvb.lvb_size, oinfo->loi_kms);
 
                cl_object_attr_lock(&osc->oo_cl);
                memcpy(lvb, &oinfo->loi_lvb, sizeof(oinfo->loi_lvb));
@@ -280,7 +281,7 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
        mode = ldlm_lock_match(exp->exp_obd->obd_namespace,
                               LDLM_FL_BLOCK_GRANTED | LDLM_FL_LVB_READY,
                               &resid, LDLM_EXTENT, &policy,
-                              LCK_PR | LCK_PW, &lockh, 0);
+                              LCK_PR | LCK_PW, &lockh);
        if (mode) { /* lock is cached on client */
                if (mode != LCK_PR) {
                        ldlm_lock_addref(&lockh, LCK_PR);
@@ -332,32 +333,6 @@ drop_lock:
        RETURN(rc);
 }
 
-int osc_object_is_contended(struct osc_object *obj)
-{
-       struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
-       time64_t osc_contention_time = dev->od_contention_time;
-       ktime_t retry_time;
-
-        if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
-                return 1;
-
-        if (!obj->oo_contended)
-                return 0;
-
-       /*
-        * I like copy-paste. the code is copied from
-        * ll_file_is_contended.
-        */
-       retry_time = ktime_add_ns(obj->oo_contention_time,
-                                 osc_contention_time * NSEC_PER_SEC);
-       if (ktime_after(ktime_get(), retry_time)) {
-               osc_object_clear_contended(obj);
-               return 0;
-       }
-       return 1;
-}
-EXPORT_SYMBOL(osc_object_is_contended);
-
 /**
  * Implementation of struct cl_object_operations::coo_req_attr_set() for osc
  * layer. osc is responsible for struct obdo::o_id and struct obdo::o_seq
@@ -370,16 +345,23 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
        struct obdo      *oa;
        struct ost_lvb   *lvb;
        u64               flags = attr->cra_flags;
+       struct osc_page *opg;
 
-       oinfo   = cl2osc(obj)->oo_oinfo;
-       lvb     = &oinfo->loi_lvb;
-       oa      = attr->cra_oa;
+       oinfo = cl2osc(obj)->oo_oinfo;
+       lvb = &oinfo->loi_lvb;
+       oa = attr->cra_oa;
+       opg = osc_cl_page_osc(attr->cra_page, cl2osc(obj));
 
        if ((flags & OBD_MD_FLMTIME) != 0) {
                oa->o_mtime = lvb->lvb_mtime;
                oa->o_valid |= OBD_MD_FLMTIME;
        }
-       if ((flags & OBD_MD_FLATIME) != 0) {
+       /* XXX:
+        * I don't understand this part, what for OSC resets atime just
+        * set by VVP layer to 0 so that OST gets 0 instead of actual
+        * atime, bzzz. please inspect this place with extra care.
+        */
+       if ((flags & OBD_MD_FLATIME) && lvb->lvb_atime > oa->o_atime) {
                oa->o_atime = lvb->lvb_atime;
                oa->o_valid |= OBD_MD_FLATIME;
        }
@@ -402,14 +384,15 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
                }
                oa->o_valid |= OBD_MD_FLID;
        }
-       if (flags & OBD_MD_FLHANDLE) {
+       /* if srvlock is set, don't look for a local lock, since we won't use
+        * it and shouldn't note it in the RPC
+        */
+       if (flags & OBD_MD_FLHANDLE && !opg->ops_srvlock) {
                struct ldlm_lock *lock;
-               struct osc_page *opg;
 
-               opg = osc_cl_page_osc(attr->cra_page, cl2osc(obj));
                lock = osc_dlmlock_at_pgoff(env, cl2osc(obj), osc_index(opg),
                                OSC_DAP_FL_TEST_LOCK | OSC_DAP_FL_CANCELING);
-               if (lock == NULL && !opg->ops_srvlock) {
+               if (lock == NULL) {
                        struct ldlm_resource *res;
                        struct ldlm_res_id *resname;
 
@@ -418,21 +401,20 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 
                        resname = &osc_env_info(env)->oti_resname;
                        ostid_build_res_name(&oinfo->loi_oi, resname);
-                       res = ldlm_resource_get(
-                               osc_export(cl2osc(obj))->exp_obd->obd_namespace,
-                               NULL, resname, LDLM_EXTENT, 0);
-                       ldlm_resource_dump(D_ERROR, res);
+                       res = ldlm_resource_get(osc_export(cl2osc(obj))->
+                                                       exp_obd->obd_namespace,
+                                               resname, LDLM_EXTENT, 0);
+                       if (IS_ERR(res))
+                               CERROR("No lock resource\n");
+                       else
+                               ldlm_resource_dump(D_ERROR, res);
 
-                       libcfs_debug_dumpstack(NULL);
                        LBUG();
                }
 
-               /* check for lockless io. */
-               if (lock != NULL) {
-                       oa->o_handle = lock->l_remote_handle;
-                       oa->o_valid |= OBD_MD_FLHANDLE;
-                       LDLM_LOCK_PUT(lock);
-               }
+               oa->o_handle = lock->l_remote_handle;
+               oa->o_valid |= OBD_MD_FLHANDLE;
+               LDLM_LOCK_PUT(lock);
        }
 }
 
@@ -491,7 +473,7 @@ int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc)
        osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF, true);
 
        /* Clear ast data of dlm lock. Do this after discarding all pages */
-       osc_object_prune(env, osc2cl(osc));
+       cl_object_prune(env, osc2cl(osc));
 
        RETURN(0);
 }