Whamcloud - gitweb
LU-12681 osc: wrong cache of LVB attrs
[fs/lustre-release.git] / lustre / osc / osc_object.c
index 025e68a..b6b01a3 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -200,10 +200,30 @@ EXPORT_SYMBOL(osc_object_glimpse);
 
 static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
 {
+       struct osc_object *osc = (struct osc_object *)data;
+       struct ost_lvb *lvb = lock->l_lvb_data;
+       struct lov_oinfo *oinfo;
        ENTRY;
 
-       if (lock->l_ast_data == data)
+       if (lock->l_ast_data == data) {
                lock->l_ast_data = NULL;
+
+               LASSERT(osc != NULL);
+               LASSERT(osc->oo_oinfo != NULL);
+               LASSERT(lvb != NULL);
+
+               /* Updates lvb in lock by the cached oinfo */
+               oinfo = osc->oo_oinfo;
+               cl_object_attr_lock(&osc->oo_cl);
+               memcpy(lvb, &oinfo->loi_lvb, sizeof(oinfo->loi_lvb));
+               cl_object_attr_unlock(&osc->oo_cl);
+
+               LDLM_DEBUG(lock, "update lvb size %llu blocks %llu [cma]time: "
+                          "%llu %llu %llu", lvb->lvb_size, lvb->lvb_blocks,
+                          lvb->lvb_ctime, lvb->lvb_mtime, lvb->lvb_atime);
+
+               ldlm_clear_lvb_cached(lock);
+       }
        RETURN(LDLM_ITER_CONTINUE);
 }
 
@@ -310,7 +330,7 @@ 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;
-       time64_t retry_time;
+       ktime_t retry_time;
 
         if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
                 return 1;
@@ -322,8 +342,9 @@ int osc_object_is_contended(struct osc_object *obj)
         * I like copy-paste. the code is copied from
         * ll_file_is_contended.
         */
-       retry_time = obj->oo_contention_time + osc_contention_time;
-       if (ktime_get_seconds() > retry_time) {
+       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;
        }