Whamcloud - gitweb
LU-7660 dne: support fs default stripe
[fs/lustre-release.git] / lustre / osp / osp_md_object.c
index 21ccacf..461df06 100644 (file)
@@ -88,16 +88,11 @@ static int osp_object_create_interpreter(const struct lu_env *env,
                obj->opo_non_exist = 1;
        }
 
-       /* Invalid the opo cache for the object after the object
-        * is being created, so attr_get will try to get attr
-        * from the remote object. XXX this can be improved when
-        * we have object lock/cache invalidate mechanism in OSP
-        * layer */
-       if (obj->opo_ooa != NULL) {
-               spin_lock(&obj->opo_lock);
-               obj->opo_ooa->ooa_attr.la_valid = 0;
-               spin_unlock(&obj->opo_lock);
-       }
+       /*
+        * invalidate opo cache for the object after the object is created, so
+        * attr_get will try to get attr from remote object.
+        */
+       osp_invalidate(env, &obj->opo_obj);
 
        return 0;
 }
@@ -125,15 +120,6 @@ int osp_md_declare_object_create(const struct lu_env *env,
                                 struct dt_object_format *dof,
                                 struct thandle *th)
 {
-       struct osp_object *obj = dt2osp_obj(dt);
-       int               rc;
-
-       if (obj->opo_ooa == NULL) {
-               rc = osp_oac_init(obj);
-               if (rc != 0)
-                       return rc;
-       }
-
        return osp_trans_update_request_create(th);
 }
 
@@ -196,8 +182,7 @@ int osp_md_object_create(const struct lu_env *env, struct dt_object *dt,
        dt->do_lu.lo_header->loh_attr |= LOHA_EXISTS | (attr->la_mode & S_IFMT);
        dt2osp_obj(dt)->opo_non_exist = 0;
 
-       LASSERT(obj->opo_ooa != NULL);
-       obj->opo_ooa->ooa_attr = *attr;
+       obj->opo_attr = *attr;
 out:
        return rc;
 }
@@ -1033,6 +1018,7 @@ struct dt_object_operations osp_md_obj_ops = {
        .do_index_try         = osp_md_index_try,
        .do_object_lock       = osp_md_object_lock,
        .do_object_unlock     = osp_md_object_unlock,
+       .do_invalidate        = osp_invalidate,
 };
 
 /**
@@ -1115,10 +1101,8 @@ static ssize_t osp_md_write(const struct lu_env *env, struct dt_object *dt,
        /* XXX: how about the write error happened later? */
        *pos += buf->lb_len;
 
-       if (obj->opo_ooa != NULL &&
-           obj->opo_ooa->ooa_attr.la_valid & LA_SIZE &&
-           obj->opo_ooa->ooa_attr.la_size < *pos)
-               obj->opo_ooa->ooa_attr.la_size = *pos;
+       if (obj->opo_attr.la_valid & LA_SIZE && obj->opo_attr.la_size < *pos)
+               obj->opo_attr.la_size = *pos;
 
        RETURN(buf->lb_len);
 }