Whamcloud - gitweb
LU-9045 osp: Revert "LU-8840 osp: handle EA cache properly"
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 8388f63..1fcbac7 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * lustre/osp/osp_object.c
  *     char                     oxe_buf[0];
  * };
  *
- * struct osp_object_attr {
- *     struct lu_attr          ooa_attr;
- *     struct list_head        ooa_xattr_list;
- * };
- *
  * struct osp_object {
  *     ...
- *     struct osp_object_attr *opo_ooa;
+ *     struct lu_attr          opo_attr;
+ *     struct list_head        opo_xattr_list;
  *     spinlock_t              opo_lock;
  *     ...
  * };
  *
  * The basic attributes, such as owner/mode/flags, are stored in the
- * osp_object_attr::ooa_attr. The extended attributes will be stored
+ * osp_object::opo_attr. The extended attributes will be stored
  * as osp_xattr_entry. Every extended attribute has an independent
  * osp_xattr_entry, and all the osp_xattr_entry are linked into the
- * osp_object_attr::ooa_xattr_list. The OSP object attributes cache
+ * osp_object::opo_xattr_list. The OSP object attributes cache
  * is protected by the osp_object::opo_lock.
  *
  * Not all OSP objects have an attributes cache because maintaining
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <lustre_obdo.h>
+#include <lustre_swab.h>
+
 #include "osp_internal.h"
 
 static inline __u32 osp_dev2node(struct osp_device *osp)
@@ -161,41 +156,12 @@ static void osp_object_assign_fid(const struct lu_env *env,
 }
 
 /**
- * Initialize the OSP object attributes cache.
- *
- * \param[in] obj      pointer to the OSP object
- *
- * \retval             0 for success
- * \retval             negative error number on failure
- */
-static int osp_oac_init(struct osp_object *obj)
-{
-       struct osp_object_attr *ooa;
-
-       OBD_ALLOC_PTR(ooa);
-       if (ooa == NULL)
-               return -ENOMEM;
-
-       INIT_LIST_HEAD(&ooa->ooa_xattr_list);
-       spin_lock(&obj->opo_lock);
-       if (likely(obj->opo_ooa == NULL)) {
-               obj->opo_ooa = ooa;
-               spin_unlock(&obj->opo_lock);
-       } else {
-               spin_unlock(&obj->opo_lock);
-               OBD_FREE_PTR(ooa);
-       }
-
-       return 0;
-}
-
-/**
  * Find the named extended attribute in the OSP object attributes cache.
  *
  * The caller should take the osp_object::opo_lock before calling
  * this function.
  *
- * \param[in] ooa      pointer to the OSP object attributes cache
+ * \param[in] obj      pointer to the OSP object
  * \param[in] name     the name of the extended attribute
  * \param[in] namelen  the name length of the extended attribute
  *
@@ -204,12 +170,12 @@ static int osp_oac_init(struct osp_object *obj)
  *                     in the cache
  */
 static struct osp_xattr_entry *
-osp_oac_xattr_find_locked(struct osp_object_attr *ooa,
-                         const char *name, size_t namelen)
+osp_oac_xattr_find_locked(struct osp_object *obj, const char *name,
+                         size_t namelen)
 {
        struct osp_xattr_entry *oxe;
 
-       list_for_each_entry(oxe, &ooa->ooa_xattr_list, oxe_list) {
+       list_for_each_entry(oxe, &obj->opo_xattr_list, oxe_list) {
                if (namelen == oxe->oxe_namelen &&
                    strncmp(name, oxe->oxe_buf, namelen) == 0)
                        return oxe;
@@ -238,15 +204,12 @@ static struct osp_xattr_entry *osp_oac_xattr_find(struct osp_object *obj,
        struct osp_xattr_entry *oxe = NULL;
 
        spin_lock(&obj->opo_lock);
-       if (obj->opo_ooa != NULL) {
-               oxe = osp_oac_xattr_find_locked(obj->opo_ooa, name,
-                                               strlen(name));
-               if (oxe != NULL) {
-                       if (unlink)
-                               list_del_init(&oxe->oxe_list);
-                       else
-                               atomic_inc(&oxe->oxe_ref);
-               }
+       oxe = osp_oac_xattr_find_locked(obj, name, strlen(name));
+       if (oxe != NULL) {
+               if (unlink)
+                       list_del_init(&oxe->oxe_list);
+               else
+                       atomic_inc(&oxe->oxe_ref);
        }
        spin_unlock(&obj->opo_lock);
 
@@ -271,14 +234,11 @@ static struct osp_xattr_entry *osp_oac_xattr_find(struct osp_object *obj,
 static struct osp_xattr_entry *
 osp_oac_xattr_find_or_add(struct osp_object *obj, const char *name, size_t len)
 {
-       struct osp_object_attr *ooa     = obj->opo_ooa;
        struct osp_xattr_entry *oxe;
        struct osp_xattr_entry *tmp     = NULL;
        size_t                  namelen = strlen(name);
        size_t                  size    = sizeof(*oxe) + namelen + 1 + len;
 
-       LASSERT(ooa != NULL);
-
        oxe = osp_oac_xattr_find(obj, name, false);
        if (oxe != NULL)
                return oxe;
@@ -296,9 +256,9 @@ osp_oac_xattr_find_or_add(struct osp_object *obj, const char *name, size_t len)
        atomic_set(&oxe->oxe_ref, 2);
 
        spin_lock(&obj->opo_lock);
-       tmp = osp_oac_xattr_find_locked(ooa, name, namelen);
+       tmp = osp_oac_xattr_find_locked(obj, name, namelen);
        if (tmp == NULL)
-               list_add_tail(&oxe->oxe_list, &ooa->ooa_xattr_list);
+               list_add_tail(&oxe->oxe_list, &obj->opo_xattr_list);
        else
                atomic_inc(&tmp->oxe_ref);
        spin_unlock(&obj->opo_lock);
@@ -319,7 +279,7 @@ osp_oac_xattr_find_or_add(struct osp_object *obj, const char *name, size_t len)
  *
  * \param[in] obj      pointer to the OSP object
  * \param[in,out] poxe double pointer to the OSP object extended attribute
- *                     entry: the new extended attribute entry is transfered
+ *                     entry: the new extended attribute entry is transferred
  *                     via such pointer target, and if old the extended
  *                     attribute entry exists, then it will be returned back
  *                     via such pointer target.
@@ -332,13 +292,10 @@ static struct osp_xattr_entry *
 osp_oac_xattr_replace(struct osp_object *obj,
                      struct osp_xattr_entry **poxe, size_t len)
 {
-       struct osp_object_attr *ooa     = obj->opo_ooa;
        struct osp_xattr_entry *oxe;
        size_t                  namelen = (*poxe)->oxe_namelen;
        size_t                  size    = sizeof(*oxe) + namelen + 1 + len;
 
-       LASSERT(ooa != NULL);
-
        OBD_ALLOC(oxe, size);
        if (unlikely(oxe == NULL))
                return NULL;
@@ -352,11 +309,11 @@ osp_oac_xattr_replace(struct osp_object *obj,
        atomic_set(&oxe->oxe_ref, 2);
 
        spin_lock(&obj->opo_lock);
-       *poxe = osp_oac_xattr_find_locked(ooa, oxe->oxe_buf, namelen);
+       *poxe = osp_oac_xattr_find_locked(obj, oxe->oxe_buf, namelen);
        LASSERT(*poxe != NULL);
 
        list_del_init(&(*poxe)->oxe_list);
-       list_add_tail(&oxe->oxe_list, &ooa->ooa_xattr_list);
+       list_add_tail(&oxe->oxe_list, &obj->opo_xattr_list);
        spin_unlock(&obj->opo_lock);
 
        return oxe;
@@ -420,15 +377,9 @@ static int osp_get_attr_from_reply(const struct lu_env *env,
 
        lustre_get_wire_obdo(NULL, lobdo, wobdo);
        spin_lock(&obj->opo_lock);
-       if (obj->opo_ooa != NULL) {
-               la_from_obdo(&obj->opo_ooa->ooa_attr, lobdo, lobdo->o_valid);
-               if (attr != NULL)
-                       *attr = obj->opo_ooa->ooa_attr;
-       } else {
-               LASSERT(attr != NULL);
-
-               la_from_obdo(attr, lobdo, lobdo->o_valid);
-       }
+       la_from_obdo(&obj->opo_attr, lobdo, lobdo->o_valid);
+       if (attr != NULL)
+               *attr = obj->opo_attr;
        spin_unlock(&obj->opo_lock);
 
        return 0;
@@ -459,8 +410,6 @@ static int osp_attr_get_interpterer(const struct lu_env *env,
 {
        struct lu_attr *attr = data;
 
-       LASSERT(obj->opo_ooa != NULL);
-
        if (rc == 0) {
                osp2lu_obj(obj)->lo_header->loh_attr |= LOHA_EXISTS;
                obj->opo_non_exist = 0;
@@ -503,15 +452,9 @@ static int osp_declare_attr_get(const struct lu_env *env, struct dt_object *dt)
        struct osp_device       *osp    = lu2osp_dev(dt->do_lu.lo_dev);
        int                      rc     = 0;
 
-       if (obj->opo_ooa == NULL) {
-               rc = osp_oac_init(obj);
-               if (rc != 0)
-                       return rc;
-       }
-
        mutex_lock(&osp->opd_async_requests_mutex);
        rc = osp_insert_async_request(env, OUT_ATTR_GET, obj, 0, NULL, NULL,
-                                     &obj->opo_ooa->ooa_attr,
+                                     &obj->opo_attr, sizeof(struct obdo),
                                      osp_attr_get_interpterer);
        mutex_unlock(&osp->opd_async_requests_mutex);
 
@@ -541,7 +484,7 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt,
        struct osp_device               *osp = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_object               *obj = dt2osp_obj(dt);
        struct dt_device                *dev = &osp->opd_dt_dev;
-       struct dt_update_request        *update;
+       struct osp_update_request       *update;
        struct object_update_reply      *reply;
        struct ptlrpc_request           *req = NULL;
        int                             rc = 0;
@@ -550,23 +493,21 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt,
        if (is_ost_obj(&dt->do_lu) && obj->opo_non_exist)
                RETURN(-ENOENT);
 
-       if (obj->opo_ooa != NULL) {
-               spin_lock(&obj->opo_lock);
-               if (obj->opo_ooa->ooa_attr.la_valid != 0) {
-                       *attr = obj->opo_ooa->ooa_attr;
-                       spin_unlock(&obj->opo_lock);
-
-                       RETURN(0);
-               }
+       spin_lock(&obj->opo_lock);
+       if (obj->opo_attr.la_valid != 0 && !obj->opo_stale) {
+               *attr = obj->opo_attr;
                spin_unlock(&obj->opo_lock);
+
+               RETURN(0);
        }
+       spin_unlock(&obj->opo_lock);
 
-       update = dt_update_request_create(dev);
+       update = osp_update_request_create(dev);
        if (IS_ERR(update))
                RETURN(PTR_ERR(update));
 
-       rc = out_attr_get_pack(env, &update->dur_buf,
-                              lu_object_fid(&dt->do_lu));
+       rc = osp_update_rpc_pack(env, attr_get, update, OUT_ATTR_GET,
+                                lu_object_fid(&dt->do_lu));
        if (rc != 0) {
                CERROR("%s: Insert update error "DFID": rc = %d\n",
                       dev->dd_lu_dev.ld_obd->obd_name,
@@ -575,7 +516,7 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt,
                GOTO(out, rc);
        }
 
-       rc = osp_remote_sync(env, osp, update, &req, false);
+       rc = osp_remote_sync(env, osp, update, &req);
        if (rc != 0) {
                if (rc == -ENOENT) {
                        osp2lu_obj(obj)->lo_header->loh_attr &= ~LOHA_EXISTS;
@@ -601,26 +542,44 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt,
        if (rc != 0)
                GOTO(out, rc);
 
-       GOTO(out, rc = 0);
+       spin_lock(&obj->opo_lock);
+       obj->opo_stale = 0;
+       spin_unlock(&obj->opo_lock);
+
+       GOTO(out, rc);
 
 out:
        if (req != NULL)
                ptlrpc_req_finished(req);
 
-       dt_update_request_destroy(update);
+       osp_update_request_destroy(env, update);
 
        return rc;
 }
 
-static int __osp_attr_set(const struct lu_env *env, struct dt_object *dt,
-                         const struct lu_attr *attr, struct thandle *th)
+/**
+ * Implement OSP layer dt_object_operations::do_declare_attr_set() interface.
+ *
+ * If the transaction is not remote one, then declare the credits that will
+ * be used for the subsequent llog record for the object's attributes.
+ *
+ * \param[in] env      pointer to the thread context
+ * \param[in] dt       pointer to the OSP layer dt_object
+ * \param[in] attr     pointer to the attribute to be set
+ * \param[in] th       pointer to the transaction handler
+ *
+ * \retval             0 for success
+ * \retval             negative error number on failure
+ */
+static int osp_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
+                               const struct lu_attr *attr, struct thandle *th)
 {
        struct osp_device       *d = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_object       *o = dt2osp_obj(dt);
-       struct lu_attr          *la;
-       int                      rc = 0;
-       ENTRY;
+       int                     rc;
 
+       if (is_only_remote_trans(th))
+               return osp_md_declare_attr_set(env, dt, attr, th);
        /*
         * Usually we don't allow server stack to manipulate size
         * but there is a special case when striping is created
@@ -649,71 +608,17 @@ static int __osp_attr_set(const struct lu_env *env, struct dt_object *dt,
                LASSERT(!dt_object_exists(dt));
                osp_object_assign_fid(env, d, o);
                rc = osp_object_truncate(env, dt, attr->la_size);
-               if (rc)
+               if (rc != 0)
                        RETURN(rc);
        }
 
        if (!(attr->la_valid & (LA_UID | LA_GID)))
                RETURN(0);
 
-       if (!is_only_remote_trans(th)) {
-               /*
-                * track all UID/GID changes via llog
-                */
-               rc = osp_sync_declare_add(env, o, MDS_SETATTR64_REC, th);
-       } else {
-               /* It is for OST-object attr_set directly without updating
-                * local MDT-object attribute. It is usually used by LFSCK. */
-               rc = __osp_md_attr_set(env, dt, attr, th);
-       }
-
-       if (rc != 0 || o->opo_ooa == NULL)
-               RETURN(rc);
+       /* track all UID/GID changes via llog */
+       rc = osp_sync_declare_add(env, o, MDS_SETATTR64_REC, th);
 
-       /* Update the OSP object attributes cache. */
-       la = &o->opo_ooa->ooa_attr;
-       spin_lock(&o->opo_lock);
-       if (attr->la_valid & LA_UID) {
-               la->la_uid = attr->la_uid;
-               la->la_valid |= LA_UID;
-       }
-
-       if (attr->la_valid & LA_GID) {
-               la->la_gid = attr->la_gid;
-               la->la_valid |= LA_GID;
-       }
-       spin_unlock(&o->opo_lock);
-
-       RETURN(0);
-}
-
-/**
- * Implement OSP layer dt_object_operations::do_declare_attr_set() interface.
- *
- * If the transaction is not remote one, then declare the credits that will
- * be used for the subsequent llog record for the object's attributes.
- *
- * \param[in] env      pointer to the thread context
- * \param[in] dt       pointer to the OSP layer dt_object
- * \param[in] attr     pointer to the attribute to be set
- * \param[in] th       pointer to the transaction handler
- *
- * \retval             0 for success
- * \retval             negative error number on failure
- */
-static int osp_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
-                               const struct lu_attr *attr, struct thandle *th)
-{
-       int rc = 0;
-
-       if (!is_only_remote_trans(th)) {
-               rc = __osp_attr_set(env, dt, attr, th);
-
-               CDEBUG(D_INFO, "declare set attr "DFID": rc = %d\n",
-                      PFID(&dt->do_lu.lo_header->loh_fid), rc);
-       }
-
-       return rc;
+       return 0;
 }
 
 /**
@@ -744,24 +649,39 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt,
        int                      rc = 0;
        ENTRY;
 
-       if (is_only_remote_trans(th)) {
-               rc = __osp_attr_set(env, dt, attr, th);
+       /* we're interested in uid/gid changes only */
+       if (!(attr->la_valid & (LA_UID | LA_GID)))
+               RETURN(0);
+
+       if (!is_only_remote_trans(th)) {
+               rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr);
+               /* XXX: send new uid/gid to OST ASAP? */
+       } else {
+               struct lu_attr  *la;
 
+               /* It is for OST-object attr_set directly without updating
+                * local MDT-object attribute. It is usually used by LFSCK. */
+               rc = osp_md_attr_set(env, dt, attr, th);
                CDEBUG(D_INFO, "(1) set attr "DFID": rc = %d\n",
                       PFID(&dt->do_lu.lo_header->loh_fid), rc);
 
-               RETURN(rc);
-       }
-
-       /* we're interested in uid/gid changes only */
-       if (!(attr->la_valid & (LA_UID | LA_GID)))
-               RETURN(0);
+               if (rc != 0)
+                       RETURN(rc);
 
-       rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr);
-       /* XXX: send new uid/gid to OST ASAP? */
+               /* Update the OSP object attributes cache. */
+               la = &o->opo_attr;
+               spin_lock(&o->opo_lock);
+               if (attr->la_valid & LA_UID) {
+                       la->la_uid = attr->la_uid;
+                       la->la_valid |= LA_UID;
+               }
 
-       CDEBUG(D_INFO, "(2) set attr "DFID": rc = %d\n",
-              PFID(&dt->do_lu.lo_header->loh_fid), rc);
+               if (attr->la_valid & LA_GID) {
+                       la->la_gid = attr->la_gid;
+                       la->la_valid |= LA_GID;
+               }
+               spin_unlock(&o->opo_lock);
+       }
 
        RETURN(rc);
 }
@@ -789,12 +709,9 @@ static int osp_xattr_get_interpterer(const struct lu_env *env,
                                     struct osp_object *obj,
                                     void *data, int index, int rc)
 {
-       struct osp_object_attr  *ooa  = obj->opo_ooa;
        struct osp_xattr_entry  *oxe  = data;
        struct lu_buf           *rbuf = &osp_env_info(env)->osi_lb2;
 
-       LASSERT(ooa != NULL);
-
        if (rc == 0) {
                size_t len = sizeof(*oxe) + oxe->oxe_namelen + 1;
 
@@ -854,47 +771,46 @@ static int osp_declare_xattr_get(const struct lu_env *env, struct dt_object *dt,
        struct osp_object       *obj     = dt2osp_obj(dt);
        struct osp_device       *osp     = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_xattr_entry  *oxe;
-       __u16                    namelen = strlen(name);
+       __u16 namelen;
        int                      rc      = 0;
 
        LASSERT(buf != NULL);
        LASSERT(name != NULL);
 
+       namelen = strlen(name);
+
        /* If only for xattr size, return directly. */
        if (unlikely(buf->lb_len == 0))
                return 0;
 
-       if (obj->opo_ooa == NULL) {
-               rc = osp_oac_init(obj);
-               if (rc != 0)
-                       return rc;
-       }
-
        oxe = osp_oac_xattr_find_or_add(obj, name, buf->lb_len);
        if (oxe == NULL)
                return -ENOMEM;
 
        mutex_lock(&osp->opd_async_requests_mutex);
        rc = osp_insert_async_request(env, OUT_XATTR_GET, obj, 1,
-                                     &namelen, (const void **)&name, oxe,
+                                     &namelen, (const void **)&name,
+                                     oxe, buf->lb_len,
                                      osp_xattr_get_interpterer);
        if (rc != 0) {
                mutex_unlock(&osp->opd_async_requests_mutex);
                osp_oac_xattr_put(oxe);
        } else {
-               struct dt_update_request *update;
+               struct osp_update_request *our;
+               struct osp_update_request_sub *ours;
 
                /* XXX: Currently, we trigger the batched async OUT
                 *      RPC via dt_declare_xattr_get(). It is not
                 *      perfect solution, but works well now.
                 *
                 *      We will improve it in the future. */
-               update = osp->opd_async_requests;
-               if (update != NULL && update->dur_buf.ub_req != NULL &&
-                   update->dur_buf.ub_req->ourq_count > 0) {
+               our = osp->opd_async_requests;
+               ours = osp_current_object_update_request(our);
+               if (ours != NULL && ours->ours_req != NULL &&
+                   ours->ours_req->ourq_count > 0) {
                        osp->opd_async_requests = NULL;
                        mutex_unlock(&osp->opd_async_requests_mutex);
-                       rc = osp_unplug_async_request(env, osp, update);
+                       rc = osp_unplug_async_request(env, osp, our);
                } else {
                        mutex_unlock(&osp->opd_async_requests_mutex);
                }
@@ -933,7 +849,7 @@ int osp_xattr_get(const struct lu_env *env, struct dt_object *dt,
        struct osp_object       *obj    = dt2osp_obj(dt);
        struct dt_device        *dev    = &osp->opd_dt_dev;
        struct lu_buf           *rbuf   = &osp_env_info(env)->osi_lb2;
-       struct dt_update_request *update = NULL;
+       struct osp_update_request *update = NULL;
        struct ptlrpc_request   *req    = NULL;
        struct object_update_reply *reply;
        struct osp_xattr_entry  *oxe    = NULL;
@@ -971,7 +887,8 @@ int osp_xattr_get(const struct lu_env *env, struct dt_object *dt,
                        if (buf->lb_len < oxe->oxe_vallen)
                                GOTO(unlock, rc = -ERANGE);
 
-                       memcpy(buf->lb_buf, oxe->oxe_value, oxe->oxe_vallen);
+                       memcpy(buf->lb_buf, oxe->oxe_value,
+                              oxe->oxe_vallen);
 
                        GOTO(unlock, rc = oxe->oxe_vallen);
 
@@ -983,29 +900,25 @@ unlock:
                }
                spin_unlock(&obj->opo_lock);
        }
-
-       update = dt_update_request_create(dev);
+       update = osp_update_request_create(dev);
        if (IS_ERR(update))
                GOTO(out, rc = PTR_ERR(update));
 
-       rc = out_xattr_get_pack(env, &update->dur_buf,
-                               lu_object_fid(&dt->do_lu), name);
+       rc = osp_update_rpc_pack(env, xattr_get, update, OUT_XATTR_GET,
+                                lu_object_fid(&dt->do_lu), name, buf->lb_len);
        if (rc != 0) {
                CERROR("%s: Insert update error "DFID": rc = %d\n",
                       dname, PFID(lu_object_fid(&dt->do_lu)), rc);
                GOTO(out, rc);
        }
 
-       rc = osp_remote_sync(env, osp, update, &req, false);
-       if (rc != 0) {
+       rc = osp_remote_sync(env, osp, update, &req);
+       if (rc < 0) {
                if (rc == -ENOENT) {
                        dt->do_lu.lo_header->loh_attr &= ~LOHA_EXISTS;
                        obj->opo_non_exist = 1;
                }
 
-               if (obj->opo_ooa == NULL)
-                       GOTO(out, rc);
-
                if (oxe == NULL)
                        oxe = osp_oac_xattr_find_or_add(obj, name, buf->lb_len);
 
@@ -1045,15 +958,12 @@ unlock:
                GOTO(out, rc);
 
        if (buf->lb_buf == NULL)
-               GOTO(out, rc = rbuf->lb_len);
+               GOTO(out, rc);
 
        if (unlikely(buf->lb_len < rbuf->lb_len))
                GOTO(out, rc = -ERANGE);
 
        memcpy(buf->lb_buf, rbuf->lb_buf, rbuf->lb_len);
-       rc = rbuf->lb_len;
-       if (obj->opo_ooa == NULL)
-               GOTO(out, rc);
 
        if (oxe == NULL) {
                oxe = osp_oac_xattr_find_or_add(obj, name, rbuf->lb_len);
@@ -1102,7 +1012,7 @@ out:
                ptlrpc_req_finished(req);
 
        if (update != NULL && !IS_ERR(update))
-               dt_update_request_destroy(update);
+               osp_update_request_destroy(env, update);
 
        if (oxe != NULL)
                osp_oac_xattr_put(oxe);
@@ -1110,34 +1020,88 @@ out:
        return rc;
 }
 
-static int __osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
-                          const struct lu_buf *buf, const char *name,
-                          int flag, struct thandle *th)
+/**
+ * Implement OSP layer dt_object_operations::do_declare_xattr_set() interface.
+ *
+ * Declare that the caller will set extended attribute to the specified
+ * MDT/OST object.
+ *
+ * If it is non-remote transaction, it will add an OUT_XATTR_SET sub-request
+ * to the OUT RPC that will be flushed when the transaction start. And if the
+ * OSP attributes cache is initialized, then check whether the name extended
+ * attribute entry exists in the cache or not. If yes, replace it; otherwise,
+ * add the extended attribute to the cache.
+ *
+ * \param[in] env      pointer to the thread context
+ * \param[in] dt       pointer to the OSP layer dt_object
+ * \param[in] buf      pointer to the lu_buf to hold the extended attribute
+ * \param[in] name     the name of the extended attribute to be set
+ * \param[in] flag     to indicate the detailed set operation: LU_XATTR_CREATE
+ *                     or LU_XATTR_REPLACE or others
+ * \param[in] th       pointer to the transaction handler
+ *
+ * \retval             0 for success
+ * \retval             negative error number on failure
+ */
+int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt,
+                         const struct lu_buf *buf, const char *name,
+                         int flag, struct thandle *th)
+{
+       return osp_trans_update_request_create(th);
+}
+
+/**
+ * Implement OSP layer dt_object_operations::do_xattr_set() interface.
+ *
+ * Set extended attribute to the specified MDT/OST object.
+ *
+ * Add an OUT_XATTR_SET sub-request into the OUT RPC that will be flushed in
+ * the transaction stop. And if the OSP attributes cache is initialized, then
+ * check whether the name extended attribute entry exists in the cache or not.
+ * If yes, replace it; otherwise, add the extended attribute to the cache.
+ *
+ * \param[in] env      pointer to the thread context
+ * \param[in] dt       pointer to the OSP layer dt_object
+ * \param[in] buf      pointer to the lu_buf to hold the extended attribute
+ * \param[in] name     the name of the extended attribute to be set
+ * \param[in] fl       to indicate the detailed set operation: LU_XATTR_CREATE
+ *                     or LU_XATTR_REPLACE or others
+ * \param[in] th       pointer to the transaction handler
+ *
+ * \retval             0 for success
+ * \retval             negative error number on failure
+ */
+int osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
+                 const struct lu_buf *buf, const char *name, int fl,
+                 struct thandle *th)
 {
        struct osp_object       *o = dt2osp_obj(dt);
-       struct dt_update_request *update;
+       struct osp_update_request *update;
        struct osp_xattr_entry  *oxe;
        int                     rc;
        ENTRY;
 
-       LASSERT(buf->lb_len > 0 && buf->lb_buf != NULL);
+       update = thandle_to_osp_update_request(th);
+       LASSERT(update != NULL);
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed "DFID": rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      PFID(lu_object_fid(&dt->do_lu)),
-                      (int)PTR_ERR(update));
+       CDEBUG(D_INODE, DFID" set xattr '%s' with size %zd\n",
+              PFID(lu_object_fid(&dt->do_lu)), name, buf->lb_len);
 
-               RETURN(PTR_ERR(update));
-       }
-
-       rc = out_xattr_set_pack(env, &update->dur_buf,
-                               lu_object_fid(&dt->do_lu),
-                               buf, name, flag, update->dur_batchid);
-       if (rc != 0 || o->opo_ooa == NULL)
+       rc = osp_update_rpc_pack(env, xattr_set, update, OUT_XATTR_SET,
+                                lu_object_fid(&dt->do_lu), buf, name, fl);
+       if (rc != 0)
                RETURN(rc);
 
+       /* Do not cache linkEA that may be self-adjusted by peers
+        * under EA overflow case. */
+       if (strcmp(name, XATTR_NAME_LINK) == 0) {
+               oxe = osp_oac_xattr_find(o, name, true);
+               if (oxe != NULL)
+                       osp_oac_xattr_put(oxe);
+
+               RETURN(0);
+       }
+
        oxe = osp_oac_xattr_find_or_add(o, name, buf->lb_len);
        if (oxe == NULL) {
                CWARN("%s: cannot cache xattr '%s' of "DFID"\n",
@@ -1181,101 +1145,63 @@ static int __osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
 }
 
 /**
- * Implement OSP layer dt_object_operations::do_declare_xattr_set() interface.
+ * Implement OSP layer dt_object_operations::do_declare_xattr_del() interface.
  *
- * Declare that the caller will set extended attribute to the specified
+ * Declare that the caller will delete extended attribute on the specified
  * MDT/OST object.
  *
- * If it is non-remote transaction, it will add an OUT_XATTR_SET sub-request
+ * If it is non-remote transaction, it will add an OUT_XATTR_DEL sub-request
  * to the OUT RPC that will be flushed when the transaction start. And if the
- * OSP attributes cache is initialized, then check whether the name extended
- * attribute entry exists in the cache or not. If yes, replace it; otherwise,
- * add the extended attribute to the cache.
+ * name extended attribute entry exists in the OSP attributes cache, then remove
+ * it from the cache.
  *
  * \param[in] env      pointer to the thread context
  * \param[in] dt       pointer to the OSP layer dt_object
- * \param[in] buf      pointer to the lu_buf to hold the extended attribute
  * \param[in] name     the name of the extended attribute to be set
- * \param[in] flag     to indicate the detailed set operation: LU_XATTR_CREATE
- *                     or LU_XATTR_REPLACE or others
  * \param[in] th       pointer to the transaction handler
  *
  * \retval             0 for success
  * \retval             negative error number on failure
  */
-int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt,
-                         const struct lu_buf *buf, const char *name,
-                         int flag, struct thandle *th)
+int osp_declare_xattr_del(const struct lu_env *env, struct dt_object *dt,
+                         const char *name, struct thandle *th)
 {
-       int rc = 0;
-
-       if (!is_only_remote_trans(th)) {
-               rc = __osp_xattr_set(env, dt, buf, name, flag, th);
-
-               CDEBUG(D_INFO, "declare xattr %s set object "DFID": rc = %d\n",
-                      name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
-       }
-
-       return rc;
+       return osp_trans_update_request_create(th);
 }
 
 /**
- * Implement OSP layer dt_object_operations::do_xattr_set() interface.
+ * Implement OSP layer dt_object_operations::do_xattr_del() interface.
  *
- * Set extended attribute to the specified MDT/OST object.
+ * Delete extended attribute on the specified MDT/OST object.
  *
- * If it is remote transaction, it will add an OUT_XATTR_SET sub-request into
- * the OUT RPC that will be flushed when the transaction stop. And if the OSP
- * attributes cache is initialized, then check whether the name extended
- * attribute entry exists in the cache or not. If yes, replace it; otherwise,
- * add the extended attribute to the cache.
+ * If it is remote transaction, it will add an OUT_XATTR_DEL sub-request into
+ * the OUT RPC that will be flushed when the transaction stop. And if the name
+ * extended attribute entry exists in the OSP attributes cache, then remove it
+ * from the cache.
  *
  * \param[in] env      pointer to the thread context
  * \param[in] dt       pointer to the OSP layer dt_object
- * \param[in] buf      pointer to the lu_buf to hold the extended attribute
  * \param[in] name     the name of the extended attribute to be set
- * \param[in] fl       to indicate the detailed set operation: LU_XATTR_CREATE
- *                     or LU_XATTR_REPLACE or others
  * \param[in] th       pointer to the transaction handler
  *
  * \retval             0 for success
  * \retval             negative error number on failure
  */
-int osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
-                 const struct lu_buf *buf, const char *name, int fl,
-                 struct thandle *th)
-{
-       int rc = 0;
-
-       if (is_only_remote_trans(th)) {
-               rc = __osp_xattr_set(env, dt, buf, name, fl, th);
-
-               CDEBUG(D_INFO, "xattr %s set object "DFID": rc = %d\n",
-                      name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
-       }
-
-       return rc;
-}
-
-static int __osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
-                          const char *name, struct thandle *th)
+int osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
+                 const char *name, struct thandle *th)
 {
-       struct dt_update_request *update;
-       const struct lu_fid      *fid;
+       struct osp_update_request *update;
+       const struct lu_fid      *fid = lu_object_fid(&dt->do_lu);
        struct osp_object        *o     = dt2osp_obj(dt);
        struct osp_xattr_entry   *oxe;
        int                       rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update))
-               return PTR_ERR(update);
-
-       fid = lu_object_fid(&dt->do_lu);
-
-       rc = out_xattr_del_pack(env, &update->dur_buf, fid, name,
-                               update->dur_batchid);
+       update = thandle_to_osp_update_request(th);
+       LASSERT(update != NULL);
 
-       if (rc != 0 || o->opo_ooa == NULL)
+       rc = osp_update_rpc_pack(env, xattr_del, update, OUT_XATTR_DEL,
+                                fid, name);
+       if (rc != 0)
                return rc;
 
        oxe = osp_oac_xattr_find(o, name, true);
@@ -1286,71 +1212,46 @@ static int __osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
        return 0;
 }
 
-/**
- * Implement OSP layer dt_object_operations::do_declare_xattr_del() interface.
- *
- * Declare that the caller will delete extended attribute on the specified
- * MDT/OST object.
- *
- * If it is non-remote transaction, it will add an OUT_XATTR_DEL sub-request
- * to the OUT RPC that will be flushed when the transaction start. And if the
- * name extended attribute entry exists in the OSP attributes cache, then remove
- * it from the cache.
- *
- * \param[in] env      pointer to the thread context
- * \param[in] dt       pointer to the OSP layer dt_object
- * \param[in] name     the name of the extended attribute to be set
- * \param[in] th       pointer to the transaction handler
- *
- * \retval             0 for success
- * \retval             negative error number on failure
- */
-int osp_declare_xattr_del(const struct lu_env *env, struct dt_object *dt,
-                         const char *name, struct thandle *th)
+void osp_obj_invalidate_cache(struct osp_object *obj)
 {
-       int rc = 0;
-
-       if (!is_only_remote_trans(th)) {
-               rc = __osp_xattr_del(env, dt, name, th);
+       struct osp_xattr_entry *oxe;
+       struct osp_xattr_entry *tmp;
 
-               CDEBUG(D_INFO, "declare xattr %s del object "DFID": rc = %d\n",
-                      name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
+       spin_lock(&obj->opo_lock);
+       list_for_each_entry_safe(oxe, tmp, &obj->opo_xattr_list, oxe_list) {
+               oxe->oxe_ready = 0;
+               list_del_init(&oxe->oxe_list);
+               osp_oac_xattr_put(oxe);
        }
-
-       return rc;
+       obj->opo_attr.la_valid = 0;
+       spin_unlock(&obj->opo_lock);
 }
 
 /**
- * Implement OSP layer dt_object_operations::do_xattr_del() interface.
+ * Implement OSP layer dt_object_operations::do_invalidate() interface.
  *
- * Delete extended attribute on the specified MDT/OST object.
- *
- * If it is remote transaction, it will add an OUT_XATTR_DEL sub-request into
- * the OUT RPC that will be flushed when the transaction stop. And if the name
- * extended attribute entry exists in the OSP attributes cache, then remove it
- * from the cache.
+ * Invalidate attributes cached on the specified MDT/OST object.
  *
  * \param[in] env      pointer to the thread context
  * \param[in] dt       pointer to the OSP layer dt_object
- * \param[in] name     the name of the extended attribute to be set
- * \param[in] th       pointer to the transaction handler
  *
  * \retval             0 for success
  * \retval             negative error number on failure
  */
-int osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
-                 const char *name, struct thandle *th)
+int osp_invalidate(const struct lu_env *env, struct dt_object *dt)
 {
-       int rc = 0;
+       struct osp_object *obj = dt2osp_obj(dt);
+       ENTRY;
 
-       if (is_only_remote_trans(th)) {
-               rc = __osp_xattr_del(env, dt, name, th);
+       CDEBUG(D_HA, "Invalidate osp_object "DFID"\n",
+              PFID(lu_object_fid(&dt->do_lu)));
+       osp_obj_invalidate_cache(obj);
 
-               CDEBUG(D_INFO, "xattr %s del object "DFID": rc = %d\n",
-                      name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
-       }
+       spin_lock(&obj->opo_lock);
+       obj->opo_stale = 1;
+       spin_unlock(&obj->opo_lock);
 
-       return rc;
+       RETURN(0);
 }
 
 /**
@@ -1388,6 +1289,7 @@ static int osp_declare_object_create(const struct lu_env *env,
        struct osp_device       *d = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_object       *o = dt2osp_obj(dt);
        const struct lu_fid     *fid = lu_object_fid(&dt->do_lu);
+       struct thandle          *local_th;
        int                      rc = 0;
 
        ENTRY;
@@ -1416,13 +1318,19 @@ static int osp_declare_object_create(const struct lu_env *env,
         */
        /* rc = osp_sync_declare_add(env, o, MDS_UNLINK64_REC, th); */
 
+       local_th = osp_get_storage_thandle(env, th, d);
+       if (IS_ERR(local_th))
+               RETURN(PTR_ERR(local_th));
+
        if (unlikely(!fid_is_zero(fid))) {
                /* replay case: caller knows fid */
                osi->osi_off = sizeof(osi->osi_id) * d->opd_index;
                osi->osi_lb.lb_len = sizeof(osi->osi_id);
                osi->osi_lb.lb_buf = NULL;
+
                rc = dt_declare_record_write(env, d->opd_last_used_oid_file,
-                                            &osi->osi_lb, osi->osi_off, th);
+                                            &osi->osi_lb, osi->osi_off,
+                                            local_th);
                RETURN(rc);
        }
 
@@ -1447,7 +1355,8 @@ static int osp_declare_object_create(const struct lu_env *env,
                osi->osi_lb.lb_len = sizeof(osi->osi_id);
                osi->osi_lb.lb_buf = NULL;
                rc = dt_declare_record_write(env, d->opd_last_used_oid_file,
-                                            &osi->osi_lb, osi->osi_off, th);
+                                            &osi->osi_lb, osi->osi_off,
+                                            local_th);
        } else {
                /* not needed in the cache anymore */
                set_bit(LU_OBJECT_HEARD_BANSHEE,
@@ -1487,6 +1396,7 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
        struct osp_object       *o = dt2osp_obj(dt);
        int                     rc = 0;
        struct lu_fid           *fid = &osi->osi_fid;
+       struct thandle          *local_th;
        ENTRY;
 
        if (is_only_remote_trans(th) &&
@@ -1529,6 +1439,9 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
        if (osp_precreate_end_seq(env, d) && osp_is_fid_client(d))
                th->th_sync = 1;
 
+       local_th = osp_get_storage_thandle(env, th, d);
+       if (IS_ERR(local_th))
+               RETURN(PTR_ERR(local_th));
        /*
         * it's OK if the import is inactive by this moment - id was created
         * by OST earlier, we just need to maintain it consistently on the disk
@@ -1563,7 +1476,7 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
                           &d->opd_last_used_fid.f_oid, d->opd_index);
 
        rc = dt_record_write(env, d->opd_last_used_oid_file, &osi->osi_lb,
-                            &osi->osi_off, th);
+                            &osi->osi_off, local_th);
 
        CDEBUG(D_HA, "%s: Wrote last used FID: "DFID", index %d: %d\n",
               d->opd_obd->obd_name, PFID(fid), d->opd_index, rc);
@@ -1590,13 +1503,12 @@ int osp_declare_object_destroy(const struct lu_env *env,
                               struct dt_object *dt, struct thandle *th)
 {
        struct osp_object       *o = dt2osp_obj(dt);
+       struct osp_device       *osp = lu2osp_dev(dt->do_lu.lo_dev);
        int                      rc = 0;
 
        ENTRY;
 
-       /*
-        * track objects to be destroyed via llog
-        */
+       LASSERT(!osp->opd_connect_mdt);
        rc = osp_sync_declare_add(env, o, MDS_UNLINK64_REC, th);
 
        RETURN(rc);
@@ -1619,20 +1531,23 @@ int osp_declare_object_destroy(const struct lu_env *env,
  * \retval             0 for success
  * \retval             negative error number on failure
  */
-int osp_object_destroy(const struct lu_env *env, struct dt_object *dt,
-                      struct thandle *th)
+static int osp_object_destroy(const struct lu_env *env, struct dt_object *dt,
+                             struct thandle *th)
 {
        struct osp_object       *o = dt2osp_obj(dt);
+       struct osp_device       *osp = lu2osp_dev(dt->do_lu.lo_dev);
        int                      rc = 0;
 
        ENTRY;
 
        o->opo_non_exist = 1;
-       /*
-        * once transaction is committed put proper command on
-        * the queue going to our OST
-        */
+
+       LASSERT(!osp->opd_connect_mdt);
+       /* once transaction is committed put proper command on
+        * the queue going to our OST. */
        rc = osp_sync_add(env, o, MDS_UNLINK64_REC, th, NULL);
+       if (rc < 0)
+               RETURN(rc);
 
        /* not needed in cache any more */
        set_bit(LU_OBJECT_HEARD_BANSHEE, &dt->do_lu.lo_header->loh_flags);
@@ -1741,7 +1656,7 @@ void osp_it_fini(const struct lu_env *env, struct dt_it *di)
  * Get more records for the iteration from peer.
  *
  * The new records will be filled in an array of pages. The OSP side
- * allows 1MB bulk data to be transfered.
+ * allows 1MB bulk data to be transferred.
  *
  * \param[in] env      pointer to the thread context
  * \param[in] it       pointer to the iteration structure
@@ -1764,7 +1679,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
 
        /* 1MB bulk */
        npages = min_t(unsigned int, OFD_MAX_BRW_SIZE, 1 << 20);
-       npages /= PAGE_CACHE_SIZE;
+       npages /= PAGE_SIZE;
 
        OBD_ALLOC(pages, npages * sizeof(*pages));
        if (pages == NULL)
@@ -1773,7 +1688,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
        it->ooi_pages = pages;
        it->ooi_total_npages = npages;
        for (i = 0; i < npages; i++) {
-               pages[i] = alloc_page(GFP_IOFS);
+               pages[i] = alloc_page(GFP_NOFS);
                if (pages[i] == NULL)
                        RETURN(-ENOMEM);
        }
@@ -1789,6 +1704,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
                RETURN(rc);
        }
 
+       osp_set_req_replay(osp, req);
        req->rq_request_portal = OUT_PORTAL;
        ii = req_capsule_client_get(&req->rq_pill, &RMF_IDX_INFO);
        memset(ii, 0, sizeof(*ii));
@@ -1813,15 +1729,18 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
 
        ptlrpc_at_set_req_timeout(req);
 
-       desc = ptlrpc_prep_bulk_imp(req, npages, 1, BULK_PUT_SINK,
-                                   MDS_BULK_PORTAL);
+       desc = ptlrpc_prep_bulk_imp(req, npages, 1,
+                                   PTLRPC_BULK_PUT_SINK | PTLRPC_BULK_BUF_KIOV,
+                                   MDS_BULK_PORTAL,
+                                   &ptlrpc_bulk_kiov_pin_ops);
        if (desc == NULL) {
                ptlrpc_request_free(req);
                RETURN(-ENOMEM);
        }
 
        for (i = 0; i < npages; i++)
-               ptlrpc_prep_bulk_page_pin(desc, pages[i], 0, PAGE_CACHE_SIZE);
+               desc->bd_frag_ops->add_kiov_frag(desc, pages[i], 0,
+                                                PAGE_SIZE);
 
        ptlrpc_request_set_replen(req);
        rc = ptlrpc_queue_wait(req);
@@ -1839,7 +1758,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
                 GOTO(out, rc = -EPROTO);
 
        npages = (ii->ii_count + LU_PAGE_COUNT - 1) >>
-                (PAGE_CACHE_SHIFT - LU_PAGE_SHIFT);
+                (PAGE_SHIFT - LU_PAGE_SHIFT);
        if (npages > it->ooi_total_npages) {
                CERROR("%s: returned more pages than expected, %u > %u\n",
                       osp->opd_obd->obd_name, npages, it->ooi_total_npages);
@@ -2179,6 +2098,8 @@ static int osp_object_init(const struct lu_env *env, struct lu_object *o,
 
        spin_lock_init(&po->opo_lock);
        o->lo_header->loh_attr |= LOHA_REMOTE;
+       INIT_LIST_HEAD(&po->opo_xattr_list);
+       INIT_LIST_HEAD(&po->opo_invalidate_cb_list);
 
        if (is_ost_obj(o)) {
                po->opo_obj.do_ops = &osp_obj_ops;
@@ -2187,13 +2108,19 @@ static int osp_object_init(const struct lu_env *env, struct lu_object *o,
 
                po->opo_obj.do_ops = &osp_md_obj_ops;
                po->opo_obj.do_body_ops = &osp_md_body_ops;
-               rc = po->opo_obj.do_ops->do_attr_get(env, lu2dt_obj(o), la);
-               if (rc == 0)
-                       o->lo_header->loh_attr |=
-                               LOHA_EXISTS | (la->la_mode & S_IFMT);
-               if (rc == -ENOENT) {
+
+               if (conf != NULL && conf->loc_flags & LOC_F_NEW) {
                        po->opo_non_exist = 1;
-                       rc = 0;
+               } else {
+                       rc = po->opo_obj.do_ops->do_attr_get(env, lu2dt_obj(o),
+                                                            la);
+                       if (rc == 0)
+                               o->lo_header->loh_attr |=
+                                       LOHA_EXISTS | (la->la_mode & S_IFMT);
+                       if (rc == -ENOENT) {
+                               po->opo_non_exist = 1;
+                               rc = 0;
+                       }
                }
                init_rwsem(&po->opo_sem);
        }
@@ -2215,26 +2142,20 @@ static void osp_object_free(const struct lu_env *env, struct lu_object *o)
 {
        struct osp_object       *obj = lu2osp_obj(o);
        struct lu_object_header *h = o->lo_header;
+       struct osp_xattr_entry *oxe;
+       struct osp_xattr_entry *tmp;
+       int                     count;
 
        dt_object_fini(&obj->opo_obj);
        lu_object_header_fini(h);
-       if (obj->opo_ooa != NULL) {
-               struct osp_xattr_entry *oxe;
-               struct osp_xattr_entry *tmp;
-               int                     count;
-
-               list_for_each_entry_safe(oxe, tmp,
-                                        &obj->opo_ooa->ooa_xattr_list,
-                                        oxe_list) {
-                       list_del(&oxe->oxe_list);
-                       count = atomic_read(&oxe->oxe_ref);
-                       LASSERTF(count == 1,
-                                "Still has %d users on the xattr entry %.*s\n",
-                                count-1, (int)oxe->oxe_namelen, oxe->oxe_buf);
-
-                       OBD_FREE(oxe, oxe->oxe_buflen);
-               }
-               OBD_FREE_PTR(obj->opo_ooa);
+       list_for_each_entry_safe(oxe, tmp, &obj->opo_xattr_list, oxe_list) {
+               list_del(&oxe->oxe_list);
+               count = atomic_read(&oxe->oxe_ref);
+               LASSERTF(count == 1,
+                        "Still has %d users on the xattr entry %.*s\n",
+                        count-1, (int)oxe->oxe_namelen, oxe->oxe_buf);
+
+               OBD_FREE(oxe, oxe->oxe_buflen);
        }
        OBD_SLAB_FREE_PTR(obj, osp_object_kmem);
 }