Both LNetMDAttach and LNetMDBind expected a struct lnet_md to be
passed by value. This requires copying the data structure onto the
stack, which is a waste of stack space and brings no value.
So change them to expect a reference, and declare it 'const' to be
sure it doesn't get changed.
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I343797d1e70cc85fde92d544e56536e982e02973
Reviewed-on: https://review.whamcloud.com/37853
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
* associated with a MD: LNetMDUnlink().
* @{ */
int LNetMDAttach(struct lnet_me *current_in,
* associated with a MD: LNetMDUnlink().
* @{ */
int LNetMDAttach(struct lnet_me *current_in,
+ const struct lnet_md *md_in,
enum lnet_unlink unlink_in,
struct lnet_handle_md *md_handle_out);
enum lnet_unlink unlink_in,
struct lnet_handle_md *md_handle_out);
-int LNetMDBind(struct lnet_md md_in,
+int LNetMDBind(const struct lnet_md *md_in,
enum lnet_unlink unlink_in,
struct lnet_handle_md *md_handle_out);
enum lnet_unlink unlink_in,
struct lnet_handle_md *md_handle_out);
md.handler = the_lnet.ln_ping_target_handler;
md.user_ptr = *ppbuf;
md.handler = the_lnet.ln_ping_target_handler;
md.user_ptr = *ppbuf;
- rc = LNetMDAttach(me, md, LNET_RETAIN, ping_mdh);
+ rc = LNetMDAttach(me, &md, LNET_RETAIN, ping_mdh);
if (rc != 0) {
CERROR("Can't attach ping target MD: %d\n", rc);
goto fail_unlink_ping_me;
if (rc != 0) {
CERROR("Can't attach ping target MD: %d\n", rc);
goto fail_unlink_ping_me;
md.user_ptr = pbuf;
md.handler = the_lnet.ln_push_target_handler;
md.user_ptr = pbuf;
md.handler = the_lnet.ln_push_target_handler;
- rc = LNetMDAttach(me, md, LNET_UNLINK, mdhp);
+ rc = LNetMDAttach(me, &md, LNET_UNLINK, mdhp);
if (rc) {
CERROR("Can't attach push MD: %d\n", rc);
LNetMEUnlink(me);
if (rc) {
CERROR("Can't attach push MD: %d\n", rc);
LNetMEUnlink(me);
init_completion(&pd.completion);
init_completion(&pd.completion);
- rc = LNetMDBind(md, LNET_UNLINK, &pd.mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, &pd.mdh);
if (rc != 0) {
CERROR("Can't bind MD: %d\n", rc);
goto fail_ping_buffer_decref;
if (rc != 0) {
CERROR("Can't bind MD: %d\n", rc);
goto fail_ping_buffer_decref;
}
static struct lnet_libmd *
}
static struct lnet_libmd *
-lnet_md_build(struct lnet_md *umd, int unlink)
+lnet_md_build(const struct lnet_md *umd, int unlink)
{
int i;
unsigned int niov;
{
int i;
unsigned int niov;
-lnet_md_validate(struct lnet_md *umd)
+lnet_md_validate(const struct lnet_md *umd)
{
if (umd->start == NULL && umd->length != 0) {
CERROR("MD start pointer can not be NULL with length %u\n",
{
if (umd->start == NULL && umd->length != 0) {
CERROR("MD start pointer can not be NULL with length %u\n",
-LNetMDAttach(struct lnet_me *me, struct lnet_md umd,
+LNetMDAttach(struct lnet_me *me, const struct lnet_md *umd,
enum lnet_unlink unlink, struct lnet_handle_md *handle)
{
LIST_HEAD(matches);
enum lnet_unlink unlink, struct lnet_handle_md *handle)
{
LIST_HEAD(matches);
LASSERT(the_lnet.ln_refcount > 0);
LASSERT(the_lnet.ln_refcount > 0);
- if (lnet_md_validate(&umd) != 0)
+ if (lnet_md_validate(umd) != 0)
- if ((umd.options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) == 0) {
+ if ((umd->options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) == 0) {
CERROR("Invalid option: no MD_OP set\n");
return -EINVAL;
}
CERROR("Invalid option: no MD_OP set\n");
return -EINVAL;
}
- md = lnet_md_build(&umd, unlink);
+ md = lnet_md_build(umd, unlink);
if (IS_ERR(md))
return PTR_ERR(md);
if (IS_ERR(md))
return PTR_ERR(md);
if (me->me_md)
rc = -EBUSY;
else
if (me->me_md)
rc = -EBUSY;
else
- rc = lnet_md_link(md, umd.handler, cpt);
+ rc = lnet_md_link(md, umd->handler, cpt);
if (rc != 0)
goto out_unlock;
if (rc != 0)
goto out_unlock;
* LNetInvalidateHandle() on it.
*/
int
* LNetInvalidateHandle() on it.
*/
int
-LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
+LNetMDBind(const struct lnet_md *umd, enum lnet_unlink unlink,
struct lnet_handle_md *handle)
{
struct lnet_libmd *md;
struct lnet_handle_md *handle)
{
struct lnet_libmd *md;
LASSERT(the_lnet.ln_refcount > 0);
LASSERT(the_lnet.ln_refcount > 0);
- if (lnet_md_validate(&umd) != 0)
+ if (lnet_md_validate(umd) != 0)
- if ((umd.options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) != 0) {
+ if ((umd->options & (LNET_MD_OP_GET | LNET_MD_OP_PUT)) != 0) {
CERROR("Invalid option: GET|PUT illegal on active MDs\n");
return -EINVAL;
}
CERROR("Invalid option: GET|PUT illegal on active MDs\n");
return -EINVAL;
}
- md = lnet_md_build(&umd, unlink);
+ md = lnet_md_build(umd, unlink);
if (IS_ERR(md))
return PTR_ERR(md);
if (IS_ERR(md))
return PTR_ERR(md);
cpt = lnet_res_lock_current();
cpt = lnet_res_lock_current();
- rc = lnet_md_link(md, umd.handler, cpt);
+ rc = lnet_md_link(md, umd->handler, cpt);
if (rc != 0)
goto out_unlock;
if (rc != 0)
goto out_unlock;
md.user_ptr = user_data;
md.handler = handler;
md.user_ptr = user_data;
md.handler = handler;
- rc = LNetMDBind(md, LNET_UNLINK, mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, mdh);
if (rc) {
lnet_ping_buffer_decref(pbuf);
CERROR("Can't bind MD: %d\n", rc);
if (rc) {
lnet_ping_buffer_decref(pbuf);
CERROR("Can't bind MD: %d\n", rc);
md.handler = the_lnet.ln_dc_handler;
md.user_ptr = lp;
md.handler = the_lnet.ln_dc_handler;
md.user_ptr = lp;
- rc = LNetMDBind(md, LNET_UNLINK, &lp->lp_push_mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, &lp->lp_push_mdh);
if (rc) {
lnet_ping_buffer_decref(pbuf);
CERROR("Can't bind push source MD: %d\n", rc);
if (rc) {
lnet_ping_buffer_decref(pbuf);
CERROR("Can't bind push source MD: %d\n", rc);
md.options = options;
md.handler = srpc_data.rpc_lnet_handler;
md.options = options;
md.handler = srpc_data.rpc_lnet_handler;
- rc = LNetMDAttach(me, md, LNET_UNLINK, mdh);
+ rc = LNetMDAttach(me, &md, LNET_UNLINK, mdh);
if (rc != 0) {
CERROR("LNetMDAttach failed: %d\n", rc);
LASSERT(rc == -ENOMEM);
if (rc != 0) {
CERROR("LNetMDAttach failed: %d\n", rc);
LASSERT(rc == -ENOMEM);
md.threshold = ((options & LNET_MD_OP_GET) != 0) ? 2 : 1;
md.options = options & ~(LNET_MD_OP_PUT | LNET_MD_OP_GET);
md.threshold = ((options & LNET_MD_OP_GET) != 0) ? 2 : 1;
md.options = options & ~(LNET_MD_OP_PUT | LNET_MD_OP_GET);
- rc = LNetMDBind(md, LNET_UNLINK, mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, mdh);
if (rc != 0) {
CERROR("LNetMDBind failed: %d\n", rc);
LASSERT(rc == -ENOMEM);
if (rc != 0) {
CERROR("LNetMDBind failed: %d\n", rc);
LASSERT(rc == -ENOMEM);
- rc = LNetMDBind (md, LNET_UNLINK, mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, mdh);
if (unlikely(rc != 0)) {
CERROR ("LNetMDBind failed: %d\n", rc);
LASSERT (rc == -ENOMEM);
if (unlikely(rc != 0)) {
CERROR ("LNetMDBind failed: %d\n", rc);
LASSERT (rc == -ENOMEM);
* page-aligned. Otherwise we'd have to send client bulk
* sizes over and split server buffer accordingly */
ptlrpc_fill_bulk_md(&md, desc, posted_md);
* page-aligned. Otherwise we'd have to send client bulk
* sizes over and split server buffer accordingly */
ptlrpc_fill_bulk_md(&md, desc, posted_md);
- rc = LNetMDBind(md, LNET_UNLINK, &desc->bd_mds[posted_md]);
+ rc = LNetMDBind(&md, LNET_UNLINK, &desc->bd_mds[posted_md]);
if (rc != 0) {
CERROR("%s: LNetMDBind failed for MD %u: rc = %d\n",
exp->exp_obd->obd_name, posted_md, rc);
if (rc != 0) {
CERROR("%s: LNetMDBind failed for MD %u: rc = %d\n",
exp->exp_obd->obd_name, posted_md, rc);
percpu_ref_get(&ptlrpc_pending);
/* About to let the network at it... */
percpu_ref_get(&ptlrpc_pending);
/* About to let the network at it... */
- rc = LNetMDAttach(me, md, LNET_UNLINK,
+ rc = LNetMDAttach(me, &md, LNET_UNLINK,
&desc->bd_mds[posted_md]);
if (rc != 0) {
CERROR("%s: LNetMDAttach failed x%llu/%d: rc = %d\n",
&desc->bd_mds[posted_md]);
if (rc != 0) {
CERROR("%s: LNetMDAttach failed x%llu/%d: rc = %d\n",
/* We must see the unlink callback to set rq_reply_unlinked,
* so we can't auto-unlink */
/* We must see the unlink callback to set rq_reply_unlinked,
* so we can't auto-unlink */
- rc = LNetMDAttach(reply_me, reply_md, LNET_RETAIN,
+ rc = LNetMDAttach(reply_me, &reply_md, LNET_RETAIN,
&request->rq_reply_md_h);
if (rc != 0) {
CERROR("LNetMDAttach failed: %d\n", rc);
&request->rq_reply_md_h);
if (rc != 0) {
CERROR("LNetMDAttach failed: %d\n", rc);
md.user_ptr = &rqbd->rqbd_cbid;
md.handler = ptlrpc_handler;
md.user_ptr = &rqbd->rqbd_cbid;
md.handler = ptlrpc_handler;
- rc = LNetMDAttach(me, md, LNET_UNLINK, &rqbd->rqbd_md_h);
+ rc = LNetMDAttach(me, &md, LNET_UNLINK, &rqbd->rqbd_md_h);
if (rc == 0) {
percpu_ref_get(&ptlrpc_pending);
return 0;
if (rc == 0) {
percpu_ref_get(&ptlrpc_pending);
return 0;