Whamcloud - gitweb
LU-14185 osp: alloc fails for OSP obj xattr cache
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 336eb54..fabf7d6 100644 (file)
@@ -186,7 +186,7 @@ static inline void osp_oac_xattr_put(struct osp_xattr_entry *oxe)
        if (atomic_dec_and_test(&oxe->oxe_ref)) {
                LASSERT(list_empty(&oxe->oxe_list));
 
-               OBD_FREE(oxe, oxe->oxe_buflen);
+               OBD_FREE_LARGE(oxe, oxe->oxe_buflen);
        }
 }
 
@@ -279,7 +279,7 @@ osp_oac_xattr_find_or_add(struct osp_object *obj, const char *name, size_t len)
        if (oxe)
                return oxe;
 
-       OBD_ALLOC(oxe, size);
+       OBD_ALLOC_LARGE(oxe, size);
        if (unlikely(!oxe))
                return NULL;
 
@@ -300,7 +300,7 @@ osp_oac_xattr_find_or_add(struct osp_object *obj, const char *name, size_t len)
        spin_unlock(&obj->opo_lock);
 
        if (tmp) {
-               OBD_FREE(oxe, size);
+               OBD_FREE_LARGE(oxe, size);
                oxe = tmp;
        }
 
@@ -332,7 +332,7 @@ osp_oac_xattr_assignment(struct osp_object *obj, struct osp_xattr_entry *oxe,
        bool unlink_only = false;
 
        if (oxe->oxe_buflen < size) {
-               OBD_ALLOC(new, size);
+               OBD_ALLOC_LARGE(new, size);
                if (likely(new)) {
                        INIT_LIST_HEAD(&new->oxe_list);
                        new->oxe_buflen = size;
@@ -1761,7 +1761,7 @@ void osp_it_fini(const struct lu_env *env, struct dt_it *di)
                                __free_page(pages[i]);
                        }
                }
-               OBD_FREE(pages, npages * sizeof(*pages));
+               OBD_FREE_PTR_ARRAY(pages, npages);
        }
        OBD_FREE_PTR(it);
 }
@@ -1795,7 +1795,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
        npages = min_t(unsigned int, OFD_MAX_BRW_SIZE, 1 << 20);
        npages /= PAGE_SIZE;
 
-       OBD_ALLOC(pages, npages * sizeof(*pages));
+       OBD_ALLOC_PTR_ARRAY(pages, npages);
        if (pages == NULL)
                RETURN(-ENOMEM);
 
@@ -1844,7 +1844,7 @@ 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,
-                                   PTLRPC_BULK_PUT_SINK | PTLRPC_BULK_BUF_KIOV,
+                                   PTLRPC_BULK_PUT_SINK,
                                    MDS_BULK_PORTAL,
                                    &ptlrpc_bulk_kiov_pin_ops);
        if (desc == NULL)
@@ -1971,7 +1971,7 @@ again0:
                        if (pages[i] != NULL)
                                __free_page(pages[i]);
                }
-               OBD_FREE(pages, it->ooi_total_npages * sizeof(*pages));
+               OBD_FREE_PTR_ARRAY(pages, it->ooi_total_npages);
 
                it->ooi_pos_page = 0;
                it->ooi_total_npages = 0;
@@ -2272,6 +2272,14 @@ static int osp_object_init(const struct lu_env *env, struct lu_object *o,
        RETURN(rc);
 }
 
+static void osp_object_free_rcu(struct rcu_head *head)
+{
+       struct osp_object *obj = container_of(head, struct osp_object,
+                                             opo_header.loh_rcu);
+
+       kmem_cache_free(osp_object_kmem, obj);
+}
+
 /**
  * Implement OSP layer lu_object_operations::loo_object_free() interface.
  *
@@ -2300,9 +2308,10 @@ static void osp_object_free(const struct lu_env *env, struct lu_object *o)
                         "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_LARGE(oxe, oxe->oxe_buflen);
        }
-       OBD_SLAB_FREE_PTR(obj, osp_object_kmem);
+       OBD_FREE_PRE(obj, sizeof(*obj), "slab-freed");
+       call_rcu(&obj->opo_header.loh_rcu, osp_object_free_rcu);
 }
 
 /**