- lib_eq_t *eq = NULL;
- int rc;
- int i;
- int niov;
-
- /* NB we are passed an allocated, but uninitialised/active md.
- * if we return success, caller may lib_md_unlink() it.
- * otherwise caller may only lib_md_free() it.
- */
-
- if (!PtlHandleIsEqual (*eqh, PTL_EQ_NONE)) {
- eq = ptl_handle2eq(eqh, nal);
- if (eq == NULL)
- return PTL_EQ_INVALID;
- }
-
- /* Must check this _before_ allocation. Also, note that non-iov
- * MDs must set md_niov to 0. */
- LASSERT((md->options & (PTL_MD_IOVEC | PTL_MD_KIOV)) == 0 ||
- md->length <= PTL_MD_MAX_IOV);
-
- /* This implementation doesn't know how to create START events or
- * disable END events. Best to LASSERT our caller is compliant so
- * we find out quickly... */
- LASSERT (PtlHandleIsEqual (*eqh, PTL_EQ_NONE) ||
- ((md->options & PTL_MD_EVENT_START_DISABLE) != 0 &&
- (md->options & PTL_MD_EVENT_END_DISABLE) == 0));
-
- if ((md->options & PTL_MD_MAX_SIZE) != 0 && /* max size used */
- (md->max_size < 0 || md->max_size > md->length)) // illegal max_size
- return PTL_MD_INVALID;
-
- new->me = NULL;
- new->start = md->start;
- new->offset = 0;
- new->max_size = md->max_size;
- new->options = md->options;
- new->user_ptr = md->user_ptr;
- new->eq = eq;
- new->threshold = md->threshold;
- new->pending = 0;
- new->md_flags = (unlink == PTL_UNLINK) ? PTL_MD_FLAG_AUTO_UNLINK : 0;
-
- if ((md->options & PTL_MD_IOVEC) != 0) {
- int total_length = 0;
-
- if ((md->options & PTL_MD_KIOV) != 0) /* Can't specify both */
- return PTL_MD_INVALID;
-
- new->md_niov = niov = md->length;
-
- if (nal->cb_read (nal, private, new->md_iov.iov, md->start,
- niov * sizeof (new->md_iov.iov[0])))
- return PTL_SEGV;
-
- for (i = 0; i < niov; i++) {
+ int i;
+ unsigned int niov;
+ int total_length = 0;
+
+ lmd->md_me = NULL;
+ lmd->md_start = umd->start;
+ lmd->md_offset = 0;
+ lmd->md_max_size = umd->max_size;
+ lmd->md_options = umd->options;
+ lmd->md_user_ptr = umd->user_ptr;
+ lmd->md_eq = NULL;
+ lmd->md_threshold = umd->threshold;
+ lmd->md_refcount = 0;
+ lmd->md_flags = (unlink == LNET_UNLINK) ? LNET_MD_FLAG_AUTO_UNLINK : 0;
+
+ if ((umd->options & LNET_MD_IOVEC) != 0) {
+
+ if ((umd->options & LNET_MD_KIOV) != 0) /* Can't specify both */
+ return -EINVAL;
+
+ lmd->md_niov = niov = umd->length;
+ memcpy(lmd->md_iov.iov, umd->start,
+ niov * sizeof (lmd->md_iov.iov[0]));
+
+ for (i = 0; i < (int)niov; i++) {