Whamcloud - gitweb
LU-13004 lnet: always pass struct lnet_md by reference.
[fs/lustre-release.git] / lnet / lnet / lib-md.c
index 0ab9060..268e856 100644 (file)
@@ -142,7 +142,7 @@ out:
 }
 
 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;
@@ -299,7 +299,7 @@ lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev)
 }
 
 static int
-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",
@@ -343,7 +343,7 @@ lnet_md_validate(struct lnet_md *umd)
  * a MD.
  */
 int
-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);
@@ -354,15 +354,15 @@ LNetMDAttach(struct lnet_me *me, struct lnet_md umd,
 
        LASSERT(the_lnet.ln_refcount > 0);
 
-       if (lnet_md_validate(&umd) != 0)
+       if (lnet_md_validate(umd) != 0)
                return -EINVAL;
 
-       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;
        }
 
-       md = lnet_md_build(&umd, unlink);
+       md = lnet_md_build(umd, unlink);
        if (IS_ERR(md))
                return PTR_ERR(md);
 
@@ -373,7 +373,7 @@ LNetMDAttach(struct lnet_me *me, struct lnet_md umd,
        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;
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(LNetMDAttach);
  * 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;
@@ -424,15 +424,15 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
 
        LASSERT(the_lnet.ln_refcount > 0);
 
-       if (lnet_md_validate(&umd) != 0)
+       if (lnet_md_validate(umd) != 0)
                return -EINVAL;
 
-       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;
        }
 
-       md = lnet_md_build(&umd, unlink);
+       md = lnet_md_build(umd, unlink);
        if (IS_ERR(md))
                return PTR_ERR(md);
 
@@ -445,7 +445,7 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
 
        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;