26 #include <linux/version.h> 28 #if M0_LUSTRE_VERSION < 2110 29 #include <lustre_ver.h> 31 #include <lustre/lustre_ver.h> 32 #include <lustre/lustre_idl.h> 35 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LNET 40 static void __nlx_kprint_lnet_handle(
const char *pre, uint64_t cookie)
45 #define nlx_kprint_lnet_handle(pre, h) \ 46 __nlx_kprint_lnet_handle(pre, (h).cookie) 49 static void nlx_kprint_lnet_process_id(
const char *pre, lnet_process_id_t
p)
52 (
long unsigned)
p.nid, (
unsigned)
p.pid);
55 static void nlx_kprint_lnet_md(
const char *pre,
const lnet_md_t *
md)
64 (
char*)pre,
md,
md->start,
md->options,
md->length,
65 md->threshold,
md->max_size,
md->user_ptr);
67 nlx_kprint_lnet_handle(
"\teq_handle",
md->eq_handle);
71 for(
i = 0;
i < kcb->kb_kiov_len; ++
i) {
73 kcb->kb_kiov[
i].kiov_page,
74 kcb->kb_kiov[
i].kiov_len,
75 kcb->kb_kiov[
i].kiov_offset);
81 static const char *nlx_kcore_lnet_event_type_to_string(lnet_event_kind_t et)
94 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 2, 57, 0) 100 M0_LNET_EV_UNLINK = 5,
104 M0_LNET_EV_REPLY = 3,
107 M0_LNET_EV_UNLINK = 6,
111 M0_LNET_EV__FIRST = M0_LNET_EV_GET,
112 M0_LNET_EV__LAST = M0_LNET_EV_UNLINK,
115 static const char *lnet_event_s[] = {
116 [LNET_EVENT_GET] =
"GET",
117 [LNET_EVENT_PUT] =
"PUT",
118 [LNET_EVENT_REPLY] =
"REPLY",
119 [LNET_EVENT_ACK] =
"ACK",
120 [LNET_EVENT_SEND] =
"SEND",
121 [LNET_EVENT_UNLINK] =
"UNLINK",
123 [M0_LNET_EV_UNKNOWN] =
"<Unknown>" 126 M0_CASSERT((
int)LNET_EVENT_GET == (
int)M0_LNET_EV_GET);
127 M0_CASSERT((
int)LNET_EVENT_PUT == (
int)M0_LNET_EV_PUT);
128 M0_CASSERT((
int)LNET_EVENT_REPLY == (
int)M0_LNET_EV_REPLY);
129 M0_CASSERT((
int)LNET_EVENT_ACK == (
int)M0_LNET_EV_ACK);
130 M0_CASSERT((
int)LNET_EVENT_SEND == (
int)M0_LNET_EV_SEND);
131 M0_CASSERT((
int)LNET_EVENT_UNLINK == (
int)M0_LNET_EV_UNLINK);
133 if (et >= (
int)M0_LNET_EV__FIRST && et <= (
int)M0_LNET_EV__LAST)
134 name = lnet_event_s[et];
136 name = lnet_event_s[M0_LNET_EV_UNKNOWN];
141 static void nlx_kprint_lnet_event(
const char *pre,
const lnet_event_t *e)
151 nlx_kprint_lnet_process_id(
"\t target:", e->target);
152 nlx_kprint_lnet_process_id(
"\tinitiator:", e->target);
158 "\tmatch_bits: %lx\n" 161 (
long unsigned) e->sender, e->type,
162 (
char*) nlx_kcore_lnet_event_type_to_string(e->type),
163 e->pt_index, (
long unsigned) e->match_bits,
164 e->rlength, e->mlength);
166 nlx_kprint_lnet_handle(
"\t md_handle", e->md_handle);
173 (
long unsigned) e->hdr_data, e->status, e->unlinked, e->offset);
175 nlx_kprint_lnet_md(
"\t md", &e->md);
178 static void nlx_kprint_kcore_tm(
const char *pre,
181 M0_LOG(
M0_DEBUG,
"%s: %p (nlx_kcore_transfer_mc)\n", (
char*) pre, ktm);
185 nlx_kprint_lnet_handle(
"\t eqh", ktm->
ktm_eqh);
277 umd->options |= LNET_MD_KIOV;
288 umd->threshold = threshold;
290 umd->max_size = max_size;
291 umd->options |= LNET_MD_MAX_SIZE;
294 umd->eq_handle = kctm->
ktm_eqh;
296 NLXDBG(kctm, 2, nlx_kprint_lnet_md(
"umd init", umd));
323 M0_PRE(umd->options & LNET_MD_KIOV);
330 umd->length, bytes, &
last);
331 NLXDBGP(ktm, 2,
"%p: kbuf:%p size:%ld vec:%lu/%lu loff:%u\n",
332 ktm, kcb, (
unsigned long) bytes,
333 (
unsigned long)
num, (
unsigned long) umd->length,
last);
382 lnet_handle_me_t me_handle;
383 lnet_process_id_t
id;
391 id.nid = LNET_NID_ANY;
392 id.pid = LNET_PID_ANY;
395 LNET_UNLINK, LNET_INS_AFTER, &me_handle);
397 NLXDBGP(kctm, 1,
"LNetMEAttach: %d\n",
rc);
401 NLXDBG(kctm, 2, nlx_print_core_buffer(
"nlx_kcore_LNetMDAttach", lcbuf));
404 rc = LNetMDAttach(me_handle, *umd, LNET_UNLINK, &kcb->
kb_mdh);
406 NLXDBG(kctm, 1, nlx_kprint_lnet_handle(
"MDAttach",kcb->
kb_mdh));
408 int trc = LNetMEUnlink(me_handle);
409 NLXDBGP(kctm, 1,
"LNetMDAttach: %d\n",
rc);
410 NLXDBGP(kctm, 1,
"LNetMEUnlink: %d\n", trc);
412 LNetInvalidateMDHandle(&kcb->
kb_mdh);
466 lnet_process_id_t target;
474 rc = LNetMDBind(*umd, LNET_UNLINK, &kcb->
kb_mdh);
479 NLXDBG(kctm, 2, nlx_print_core_buffer(
"nlx_kcore_LNetPut", lcbuf));
480 NLXDBG(kctm, 2, nlx_kprint_lnet_handle(
"LNetMDBind", kcb->
kb_mdh));
490 int trc = LNetMDUnlink(kcb->
kb_mdh);
492 NLXDBGP(kctm, 1,
"LNetMDUnlink: %d\n", trc);
494 LNetInvalidateMDHandle(&kcb->
kb_mdh);
528 lnet_process_id_t target;
536 M0_PRE(umd->threshold == 2);
538 rc = LNetMDBind(*umd, LNET_UNLINK, &kcb->
kb_mdh);
543 NLXDBG(kctm, 2, nlx_print_core_buffer(
"nlx_kcore_LNetGet", lcbuf));
544 NLXDBG(kctm, 2, nlx_kprint_lnet_handle(
"LNetMDBind", kcb->
kb_mdh));
552 #
if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 11, 55, 0)
558 int trc = LNetMDUnlink(kcb->
kb_mdh);
560 NLXDBGP(kctm, 1,
"LNetMDUnlink: %d\n", trc);
562 LNetInvalidateMDHandle(&kcb->
kb_mdh);
730 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) 752 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) 755 kunmap_atomic(ctm, KM_USER0);
static void nlx_kcore_core_domain_unmap(struct nlx_kcore_domain *kd)
static void nlx_kcore_hdr_data_decode(uint64_t hdr_data, uint32_t *portal, uint32_t *tmid)
struct nlx_core_kmem_loc kd_cd_loc
static void nlx_kcore_kiov_restore_length(struct nlx_kcore_buffer *kcb)
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
static struct m0_addb2_philter p
static uint64_t nlx_kcore_hdr_data_encode(struct nlx_kcore_transfer_mc *kctm)
static uint64_t nlx_kcore_hdr_data_encode_raw(uint32_t tmid, uint32_t portal)
static struct nlx_core_transfer_mc * nlx_kcore_core_tm_map(struct nlx_kcore_transfer_mc *ktm)
unsigned kb_kiov_orig_len
struct nlx_core_ep_addr cb_addr
static size_t nlx_kcore_num_kiov_entries_for_bytes(const lnet_kiov_t *kiov, size_t kiov_len, m0_bcount_t bytes, unsigned *last_len)
#define M0_LOG(level,...)
static void nlx_kcore_umd_init(struct nlx_kcore_transfer_mc *kctm, struct nlx_core_buffer *lcbuf, struct nlx_kcore_buffer *kcb, int threshold, int max_size, unsigned options, bool isLNetGetOp, lnet_md_t *umd)
static bool nlx_kcore_tm_invariant(const struct nlx_kcore_transfer_mc *kctm)
static bool nlx_core_buffer_invariant(const struct nlx_core_buffer *lcb)
#define NLXDBG(ptr, dbg, stmt)
struct m0hsm_options options
static struct m0_mdstore md
static void nlx_kcore_core_tm_unmap_atomic(struct nlx_core_transfer_mc *ctm)
static struct nlx_core_domain * nlx_kcore_core_domain_map(struct nlx_kcore_domain *kd)
static struct nlx_core_buffer * nlx_kcore_core_buffer_map(struct nlx_kcore_buffer *kb)
static int nlx_kcore_LNetMDAttach(struct nlx_kcore_transfer_mc *kctm, struct nlx_core_buffer *lcbuf, struct nlx_kcore_buffer *kcb, lnet_md_t *umd)
#define LNetHandleIsInvalid(h)
m0_time_t m0_time_now(void)
static bool nlx_kcore_buffer_event_invariant(const struct nlx_kcore_buffer_event *kbe)
static void nlx_kcore_core_bev_unmap(struct nlx_kcore_buffer_event *kbe)
static int nlx_kcore_LNetGet(struct nlx_kcore_transfer_mc *kctm, struct nlx_core_buffer *lcbuf, struct nlx_kcore_buffer *kcb, lnet_md_t *umd)
struct nlx_core_ep_addr ktm_addr
static void nlx_kcore_kiov_adjust_length(struct nlx_kcore_transfer_mc *ktm, struct nlx_kcore_buffer *kcb, lnet_md_t *umd, m0_bcount_t bytes)
struct nlx_kcore_transfer_mc * kb_ktm
static void nlx_kcore_core_tm_unmap(struct nlx_kcore_transfer_mc *ktm)
static int nlx_kcore_LNetPut(struct nlx_kcore_transfer_mc *kctm, struct nlx_core_buffer *lcbuf, struct nlx_kcore_buffer *kcb, lnet_md_t *umd)
static struct nlx_core_transfer_mc * nlx_kcore_core_tm_map_atomic(struct nlx_kcore_transfer_mc *ktm)
struct nlx_core_kmem_loc kb_cb_loc
#define NLXDBGP(ptr, dbg, fmt,...)
static bool nlx_kcore_kiov_invariant(const lnet_kiov_t *k, size_t len)
enum m0_net_queue_type cb_qtype
static bool nlx_core_tm_invariant(const struct nlx_core_transfer_mc *lctm)
struct nlx_core_kmem_loc kbe_bev_loc
static struct nlx_core_buffer_event * nlx_kcore_core_bev_map(struct nlx_kcore_buffer_event *kbe)
enum m0_net_queue_type kb_qtype
static bool nlx_core_kmem_loc_invariant(const struct nlx_core_kmem_loc *loc)
static bool nlx_core_kmem_loc_is_empty(const struct nlx_core_kmem_loc *loc)
struct nlx_core_kmem_loc ktm_ctm_loc
static bool nlx_kcore_buffer_invariant(const struct nlx_kcore_buffer *kcb)
static void nlx_kcore_core_buffer_unmap(struct nlx_kcore_buffer *kb)
static struct m0_addb2_frame_header last
static bool nlx_kcore_domain_invariant(const struct nlx_kcore_domain *kd)
static int nlx_kcore_LNetMDUnlink(struct nlx_kcore_transfer_mc *kctm, struct nlx_kcore_buffer *kcb)