Whamcloud - gitweb
LU-9045 osp: Revert "LU-8840 osp: handle EA cache properly"
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 8571ce3..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) 2012, 2015, 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
- */
-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 @@ 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);
@@ -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);
 
@@ -550,16 +493,14 @@ 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 = osp_update_request_create(dev);
        if (IS_ERR(update))
@@ -601,13 +542,17 @@ 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);
 
-       osp_update_request_destroy(update);
+       osp_update_request_destroy(env, update);
 
        return rc;
 }
@@ -720,11 +665,11 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt,
                CDEBUG(D_INFO, "(1) set attr "DFID": rc = %d\n",
                       PFID(&dt->do_lu.lo_header->loh_fid), rc);
 
-               if (rc != 0 || o->opo_ooa == NULL)
+               if (rc != 0)
                        RETURN(rc);
 
                /* Update the OSP object attributes cache. */
-               la = &o->opo_ooa->ooa_attr;
+               la = &o->opo_attr;
                spin_lock(&o->opo_lock);
                if (attr->la_valid & LA_UID) {
                        la->la_uid = attr->la_uid;
@@ -764,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;
 
@@ -829,29 +771,26 @@ 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);
@@ -935,41 +874,38 @@ int osp_xattr_get(const struct lu_env *env, struct dt_object *dt,
        if (unlikely(obj->opo_non_exist))
                RETURN(-ENOENT);
 
-       /* Only cache xattr for OST object */
-       if (!osp->opd_connect_mdt) {
-               oxe = osp_oac_xattr_find(obj, name, false);
-               if (oxe != NULL) {
-                       spin_lock(&obj->opo_lock);
-                       if (oxe->oxe_ready) {
-                               if (!oxe->oxe_exist)
-                                       GOTO(unlock, rc = -ENODATA);
+       oxe = osp_oac_xattr_find(obj, name, false);
+       if (oxe != NULL) {
+               spin_lock(&obj->opo_lock);
+               if (oxe->oxe_ready) {
+                       if (!oxe->oxe_exist)
+                               GOTO(unlock, rc = -ENODATA);
 
-                               if (buf->lb_buf == NULL)
-                                       GOTO(unlock, rc = oxe->oxe_vallen);
+                       if (buf->lb_buf == NULL)
+                               GOTO(unlock, rc = oxe->oxe_vallen);
 
-                               if (buf->lb_len < oxe->oxe_vallen)
-                                       GOTO(unlock, rc = -ERANGE);
+                       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);
+                       GOTO(unlock, rc = oxe->oxe_vallen);
 
 unlock:
-                               spin_unlock(&obj->opo_lock);
-                               osp_oac_xattr_put(oxe);
-
-                               return rc;
-                       }
                        spin_unlock(&obj->opo_lock);
+                       osp_oac_xattr_put(oxe);
+
+                       return rc;
                }
+               spin_unlock(&obj->opo_lock);
        }
        update = osp_update_request_create(dev);
        if (IS_ERR(update))
                GOTO(out, rc = PTR_ERR(update));
 
        rc = osp_update_rpc_pack(env, xattr_get, update, OUT_XATTR_GET,
-                                lu_object_fid(&dt->do_lu), name);
+                                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);
@@ -977,15 +913,12 @@ unlock:
        }
 
        rc = osp_remote_sync(env, osp, update, &req);
-       if (rc != 0) {
+       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);
 
@@ -1025,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 || osp->opd_connect_mdt)
-               GOTO(out, rc);
 
        if (oxe == NULL) {
                oxe = osp_oac_xattr_find_or_add(obj, name, rbuf->lb_len);
@@ -1082,7 +1012,7 @@ out:
                ptlrpc_req_finished(req);
 
        if (update != NULL && !IS_ERR(update))
-               osp_update_request_destroy(update);
+               osp_update_request_destroy(env, update);
 
        if (oxe != NULL)
                osp_oac_xattr_put(oxe);
@@ -1146,7 +1076,6 @@ int osp_xattr_set(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);
        struct osp_update_request *update;
        struct osp_xattr_entry  *oxe;
        int                     rc;
@@ -1160,9 +1089,19 @@ int osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
 
        rc = osp_update_rpc_pack(env, xattr_set, update, OUT_XATTR_SET,
                                 lu_object_fid(&dt->do_lu), buf, name, fl);
-       if (rc != 0 || o->opo_ooa == NULL || osp->opd_connect_mdt)
+       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",
@@ -1262,7 +1201,7 @@ int osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
 
        rc = osp_update_rpc_pack(env, xattr_del, update, OUT_XATTR_DEL,
                                 fid, name);
-       if (rc != 0 || o->opo_ooa == NULL)
+       if (rc != 0)
                return rc;
 
        oxe = osp_oac_xattr_find(o, name, true);
@@ -1273,6 +1212,48 @@ int osp_xattr_del(const struct lu_env *env, struct dt_object *dt,
        return 0;
 }
 
+void osp_obj_invalidate_cache(struct osp_object *obj)
+{
+       struct osp_xattr_entry *oxe;
+       struct osp_xattr_entry *tmp;
+
+       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);
+       }
+       obj->opo_attr.la_valid = 0;
+       spin_unlock(&obj->opo_lock);
+}
+
+/**
+ * Implement OSP layer dt_object_operations::do_invalidate() interface.
+ *
+ * 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
+ *
+ * \retval             0 for success
+ * \retval             negative error number on failure
+ */
+int osp_invalidate(const struct lu_env *env, struct dt_object *dt)
+{
+       struct osp_object *obj = dt2osp_obj(dt);
+       ENTRY;
+
+       CDEBUG(D_HA, "Invalidate osp_object "DFID"\n",
+              PFID(lu_object_fid(&dt->do_lu)));
+       osp_obj_invalidate_cache(obj);
+
+       spin_lock(&obj->opo_lock);
+       obj->opo_stale = 1;
+       spin_unlock(&obj->opo_lock);
+
+       RETURN(0);
+}
+
 /**
  * Implement OSP layer dt_object_operations::do_declare_create() interface.
  *
@@ -1698,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)
@@ -1707,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);
        }
@@ -1723,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));
@@ -1758,7 +1740,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
 
        for (i = 0; i < npages; i++)
                desc->bd_frag_ops->add_kiov_frag(desc, pages[i], 0,
-                                                PAGE_CACHE_SIZE);
+                                                PAGE_SIZE);
 
        ptlrpc_request_set_replen(req);
        rc = ptlrpc_queue_wait(req);
@@ -1776,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);
@@ -2116,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;
@@ -2124,6 +2108,7 @@ 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;
+
                if (conf != NULL && conf->loc_flags & LOC_F_NEW) {
                        po->opo_non_exist = 1;
                } else {
@@ -2157,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);
 }