struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) { struct lov_stripe_md *lsm; struct lov_oinfo *loi; int i, oinfo_ptrs_size; LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT); oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size; OBD_ALLOC_LARGE(lsm, *size); if (!lsm) return NULL;; for (i = 0; i < stripe_count; i++) { OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, __GFP_IO); if (loi == NULL) goto err; lsm->lsm_oinfo[i] = loi; } lsm->lsm_stripe_count = stripe_count; return lsm; err: while (--i >= 0) OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi)); OBD_FREE_LARGE(lsm, *size); return NULL; }
/* * Concurrency: no concurrent access is possible that early in object * life-cycle. */ struct lu_object *osd_object_alloc(const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *d) { struct osd_object *mo; OBD_SLAB_ALLOC_PTR_GFP(mo, osd_object_kmem, GFP_NOFS); if (mo != NULL) { struct lu_object *l; l = &mo->oo_dt.do_lu; dt_object_init(&mo->oo_dt, NULL, d); mo->oo_dt.do_ops = &osd_obj_ops; l->lo_ops = &osd_lu_obj_ops; INIT_LIST_HEAD(&mo->oo_sa_linkage); INIT_LIST_HEAD(&mo->oo_unlinked_linkage); init_rwsem(&mo->oo_sem); init_rwsem(&mo->oo_guard); rwlock_init(&mo->oo_attr_lock); mo->oo_destroy = OSD_DESTROY_NONE; return l; } else { return NULL; } }
struct lu_object *vvp_object_alloc(const struct lu_env *env, const struct lu_object_header *unused, struct lu_device *dev) { struct vvp_object *vob; struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(vob, vvp_object_kmem, GFP_NOFS); if (vob != NULL) { struct cl_object_header *hdr; obj = &vob->vob_cl.co_lu; hdr = &vob->vob_header; cl_object_header_init(hdr); hdr->coh_page_bufsize = cfs_size_round(sizeof(struct cl_page)); lu_object_init(obj, &hdr->coh_lu, dev); lu_object_add_top(&hdr->coh_lu, obj); vob->vob_cl.co_ops = &vvp_ops; obj->lo_ops = &vvp_lu_obj_ops; } else obj = NULL; return obj; }
static inline struct ll_remote_perm *alloc_ll_remote_perm(void) { struct ll_remote_perm *lrp; OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL); if (lrp) INIT_HLIST_NODE(&lrp->lrp_list); return lrp; }
static void *osc_session_init(const struct lu_context *ctx, struct lu_context_key *key) { struct osc_session *info; OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, __GFP_IO); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; }
static void *vvp_key_init(const struct lu_context *ctx, struct lu_context_key *key) { struct vvp_thread_info *info; OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; }
static void *vvp_session_key_init(const struct lu_context *ctx, struct lu_context_key *key) { struct vvp_session *session; OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, GFP_NOFS); if (session == NULL) session = ERR_PTR(-ENOMEM); return session; }
static void *lov_session_key_init(const struct lu_context *ctx, struct lu_context_key *key) { struct lov_session *info; OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; }
static struct inode *ll_alloc_inode(struct super_block *sb) { struct ll_inode_info *lli; ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, CFS_ALLOC_IO); if (lli == NULL) return NULL; inode_init_once(&lli->lli_vfs_inode); return &lli->lli_vfs_inode; }
static void *lov_key_init(const struct lu_context *ctx, struct lu_context_key *key) { struct lov_thread_info *info; OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS); if (info != NULL) INIT_LIST_HEAD(&info->lti_closure.clc_list); else info = ERR_PTR(-ENOMEM); return info; }
int osc_req_init(const struct lu_env *env, struct cl_device *dev, struct cl_req *req) { struct osc_req *or; int result; OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS); if (or != NULL) { cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops); result = 0; } else result = -ENOMEM; return result; }
static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev, struct cl_req *req) { struct lovsub_req *lsr; int result; OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, GFP_NOFS); if (lsr != NULL) { cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops); result = 0; } else result = -ENOMEM; return result; }
int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *io) { struct lovsub_lock *lsk; int result; ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, GFP_NOFS); if (lsk != NULL) { INIT_LIST_HEAD(&lsk->lss_parents); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); result = 0; } else result = -ENOMEM; RETURN(result); }
struct lu_object *osc_object_alloc(const struct lu_env *env, const struct lu_object_header *unused, struct lu_device *dev) { struct osc_object *osc; struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS); if (osc != NULL) { obj = osc2lu(osc); lu_object_init(obj, NULL, dev); osc->oo_cl.co_ops = &osc_ops; obj->lo_ops = &osc_lu_obj_ops; } else obj = NULL; return obj; }
int vvp_lock_init(const struct lu_env *env, struct cl_object *obj, struct cl_lock *lock, const struct cl_io *unused) { struct vvp_lock *vlk; int result; CLOBINVRNT(env, obj, vvp_object_invariant(obj)); OBD_SLAB_ALLOC_PTR_GFP(vlk, vvp_lock_kmem, GFP_NOFS); if (vlk != NULL) { cl_lock_slice_add(lock, &vlk->vlk_cl, obj, &vvp_lock_ops); result = 0; } else { result = -ENOMEM; } return result; }
struct lu_object *lovsub_object_alloc(const struct lu_env *env, const struct lu_object_header *unused, struct lu_device *dev) { struct lovsub_object *los; struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, GFP_NOFS); if (los != NULL) { struct cl_object_header *hdr; obj = lovsub2lu(los); hdr = &los->lso_header; cl_object_header_init(hdr); lu_object_init(obj, &hdr->coh_lu, dev); lu_object_add_top(&hdr->coh_lu, obj); los->lso_cl.co_ops = &lovsub_ops; obj->lo_ops = &lovsub_lu_obj_ops; } else obj = NULL; return obj; }
struct lu_object *lov_object_alloc(const struct lu_env *env, const struct lu_object_header *unused, struct lu_device *dev) { struct lov_object *lov; struct lu_object *obj; OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, GFP_NOFS); if (lov != NULL) { obj = lov2lu(lov); lu_object_init(obj, NULL, dev); lov->lo_cl.co_ops = &lov_ops; lov->lo_type = -1; /* invalid, to catch uninitialized type */ /* * object io operation vector (cl_object::co_iop) is installed * later in lov_object_init(), as different vectors are used * for object with different layouts. */ obj->lo_ops = &lov_lu_obj_ops; } else obj = NULL; return obj; }
/* * Concurrency: no concurrent access is possible that early in object * life-cycle. */ struct lu_object *osd_object_alloc(const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *d) { struct osd_object *mo; OBD_SLAB_ALLOC_PTR_GFP(mo, osd_object_kmem, CFS_ALLOC_IO); if (mo != NULL) { struct lu_object *l; l = &mo->oo_dt.do_lu; dt_object_init(&mo->oo_dt, NULL, d); mo->oo_dt.do_ops = &osd_obj_ops; l->lo_ops = &osd_lu_obj_ops; CFS_INIT_LIST_HEAD(&mo->oo_sa_linkage); init_rwsem(&mo->oo_sem); sema_init(&mo->oo_guard, 1); rwlock_init(&mo->oo_attr_lock); return l; } else { return NULL; } }