#define MAX_PORTALS 64
-static inline struct lnet_eq *
-lnet_eq_alloc(void)
-{
- struct lnet_eq *eq;
-
- LIBCFS_ALLOC(eq, sizeof(*eq));
- return eq;
-}
-
-static inline void
-lnet_eq_free(struct lnet_eq *eq)
-{
- LIBCFS_FREE(eq, sizeof(*eq));
-}
-
static inline struct lnet_libmd *
lnet_md_alloc(struct lnet_md *umd)
{
size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
}
- LIBCFS_ALLOC(md, size);
+ md = kzalloc(size, GFP_NOFS);
if (md) {
/* Set here in case of early free */
return md;
}
-static inline void
-lnet_md_free(struct lnet_libmd *md)
-{
- unsigned int size;
-
- if (md->md_options & LNET_MD_KIOV)
- size = offsetof(struct lnet_libmd, md_iov.kiov[md->md_niov]);
- else
- size = offsetof(struct lnet_libmd, md_iov.iov[md->md_niov]);
-
- LIBCFS_FREE(md, size);
-}
-
-static inline struct lnet_me *
-lnet_me_alloc(void)
-{
- struct lnet_me *me;
-
- LIBCFS_ALLOC(me, sizeof(*me));
- return me;
-}
-
-static inline void
-lnet_me_free(struct lnet_me *me)
-{
- LIBCFS_FREE(me, sizeof(*me));
-}
-
-static inline struct lnet_msg *
-lnet_msg_alloc(void)
-{
- struct lnet_msg *msg;
-
- LIBCFS_ALLOC(msg, sizeof(*msg));
-
- /* no need to zero, LIBCFS_ALLOC does for us */
- return msg;
-}
-
-static inline void
-lnet_msg_free(struct lnet_msg *msg)
-{
- LASSERT(!msg->msg_onactivelist);
- LIBCFS_FREE(msg, sizeof(*msg));
-}
-
struct lnet_libhandle *lnet_res_lh_lookup(struct lnet_res_container *rec,
__u64 cookie);
void lnet_res_lh_initialize(struct lnet_res_container *rec,
list_del_init(e);
if (rec->rec_type == LNET_COOKIE_TYPE_EQ) {
- lnet_eq_free(list_entry(e, struct lnet_eq, eq_list));
+ kfree(list_entry(e, struct lnet_eq, eq_list));
} else if (rec->rec_type == LNET_COOKIE_TYPE_MD) {
- lnet_md_free(list_entry(e, struct lnet_libmd, md_list));
+ kfree(list_entry(e, struct lnet_libmd, md_list));
} else { /* NB: Active MEs should be attached on portals */
LBUG();
if (!count && callback == LNET_EQ_HANDLER_NONE)
return -EINVAL;
- eq = lnet_eq_alloc();
+ eq = kzalloc(sizeof(*eq), GFP_NOFS);
if (!eq)
return -ENOMEM;
if (eq->eq_refs)
cfs_percpt_free(eq->eq_refs);
- lnet_eq_free(eq);
+ kfree(eq);
return -ENOMEM;
}
EXPORT_SYMBOL(LNetEQAlloc);
lnet_res_lh_invalidate(&eq->eq_lh);
list_del(&eq->eq_list);
- lnet_eq_free(eq);
+ kfree(eq);
out:
lnet_eq_wait_unlock();
lnet_res_unlock(LNET_LOCK_EX);
LASSERT(!list_empty(&md->md_list));
list_del_init(&md->md_list);
- lnet_md_free(md);
+ kfree(md);
}
static int
/*
* NB we are passed an allocated, but inactive md.
* if we return success, caller may lnet_md_unlink() it.
- * otherwise caller may only lnet_md_free() it.
+ * otherwise caller may only kfree() it.
*/
/*
* This implementation doesn't know how to create START events or
out_unlock:
lnet_res_unlock(cpt);
out_free:
- lnet_md_free(md);
+ kfree(md);
return rc;
}
EXPORT_SYMBOL(LNetMDAttach);
out_unlock:
lnet_res_unlock(cpt);
out_free:
- lnet_md_free(md);
+ kfree(md);
return rc;
}
if (!mtable) /* can't match portal type */
return -EPERM;
- me = lnet_me_alloc();
+ me = kzalloc(sizeof(*me), GFP_NOFS);
if (!me)
return -ENOMEM;
if (pos == LNET_INS_LOCAL)
return -EPERM;
- new_me = lnet_me_alloc();
+ new_me = kzalloc(sizeof(*new_me), GFP_NOFS);
if (!new_me)
return -ENOMEM;
current_me = lnet_handle2me(¤t_meh);
if (!current_me) {
- lnet_me_free(new_me);
+ kfree(new_me);
lnet_res_unlock(cpt);
return -ENOENT;
ptl = the_lnet.ln_portals[current_me->me_portal];
if (lnet_ptl_is_unique(ptl)) {
/* nosense to insertion on unique portal */
- lnet_me_free(new_me);
+ kfree(new_me);
lnet_res_unlock(cpt);
return -EPERM;
}
}
lnet_res_lh_invalidate(&me->me_lh);
- lnet_me_free(me);
+ kfree(me);
}
goto drop;
}
- msg = lnet_msg_alloc();
+ msg = kzalloc(sizeof(*msg), GFP_NOFS);
if (!msg) {
CERROR("%s, src %s: Dropping %s (out of memory)\n",
libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
goto drop;
}
- /* msg zeroed in lnet_msg_alloc;
+ /* msg zeroed by kzalloc()
* i.e. flags all clear, pointers NULL etc
*/
msg->msg_type = type;
CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
lnet_msgtyp2str(type), rc);
- lnet_msg_free(msg);
+ kfree(msg);
if (rc == -ESHUTDOWN)
/* We are shutting down. Don't do anything more */
return 0;
return -EIO;
}
- msg = lnet_msg_alloc();
+ msg = kzalloc(sizeof(*msg), GFP_NOFS);
if (!msg) {
CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n",
libcfs_id2str(target));
md->md_me->me_portal);
lnet_res_unlock(cpt);
- lnet_msg_free(msg);
+ kfree(msg);
return -ENOENT;
}
* CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when
* lnet_finalize() is called on it, so the LND must call this first
*/
- struct lnet_msg *msg = lnet_msg_alloc();
+ struct lnet_msg *msg = kzalloc(sizeof(*msg), GFP_NOFS);
struct lnet_libmd *getmd = getmsg->msg_md;
struct lnet_process_id peer_id = getmsg->msg_target;
int cpt;
lnet_net_unlock(cpt);
if (msg)
- lnet_msg_free(msg);
+ kfree(msg);
return NULL;
}
return -EIO;
}
- msg = lnet_msg_alloc();
+ msg = kzalloc(sizeof(*msg), GFP_NOFS);
if (!msg) {
CERROR("Dropping GET to %s: ENOMEM on struct lnet_msg\n",
libcfs_id2str(target));
lnet_res_unlock(cpt);
- lnet_msg_free(msg);
+ kfree(msg);
return -ENOENT;
}
}
lnet_msg_decommit(msg, cpt, status);
- lnet_msg_free(msg);
+ kfree(msg);
return 0;
}
if (!msg->msg_tx_committed && !msg->msg_rx_committed) {
/* not committed to network yet */
LASSERT(!msg->msg_onactivelist);
- lnet_msg_free(msg);
+ kfree(msg);
return;
}
LASSERT(msg->msg_onactivelist);
msg->msg_onactivelist = 0;
list_del(&msg->msg_activelist);
- lnet_msg_free(msg);
+ kfree(msg);
count++;
}
struct lnet_me, me_list);
CERROR("Active ME %p on exit\n", me);
list_del(&me->me_list);
- lnet_me_free(me);
+ kfree(me);
}
}
/* the extra entry is for MEs with ignore bits */