diff mbox series

[04/34] lnet: embed lnd_tunables in lnet_ni

Message ID 153628137138.8267.11270892110905717079.stgit@noble (mailing list archive)
State New, archived
Headers show
Series Beginning of multi-rail support for drivers/staging/lustre | expand

Commit Message

NeilBrown Sept. 7, 2018, 12:49 a.m. UTC
Instead of a pointer, embed the data struct.
Also other related changes.

This is part of
    8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
       LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-types.h  |    6 ++++
 .../lustre/include/uapi/linux/lnet/lnet-dlc.h      |   10 +++++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 +++---
 .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |   13 +++-------
 drivers/staging/lustre/lnet/lnet/api-ni.c          |   27 +++++++++-----------
 drivers/staging/lustre/lnet/lnet/config.c          |    2 -
 8 files changed, 36 insertions(+), 38 deletions(-)

Comments

Doug Oucharek Sept. 10, 2018, 11:08 p.m. UTC | #1
James Simmons: Should these tunable changes be made to gnilnd in a separate patch set?

Reviewed-by: Doug Oucharek <dougso@me.com<mailto:dougso@me.com>>

Doug

On Sep 6, 2018, at 5:49 PM, NeilBrown <neilb@suse.com<mailto:neilb@suse.com>> wrote:

Instead of a pointer, embed the data struct.
Also other related changes.

This is part of
   8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
      LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com<mailto:neilb@suse.com>>
---
.../staging/lustre/include/linux/lnet/lib-types.h  |    6 ++++
.../lustre/include/uapi/linux/lnet/lnet-dlc.h      |   10 +++++--
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 +++---
.../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |   13 +++-------
drivers/staging/lustre/lnet/lnet/api-ni.c          |   27 +++++++++-----------
drivers/staging/lustre/lnet/lnet/config.c          |    2 -
8 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index e170eb07a5bf..c5e3363de727 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -302,7 +302,11 @@ struct lnet_ni {
struct lnet_ni_status *ni_status;

/* per NI LND tunables */
- struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables;
+ struct lnet_lnd_tunables ni_lnd_tunables;
+
+ /* lnd tunables set explicitly */
+ bool ni_lnd_tunables_set;
+
/*
* equivalent interfaces to use
* This is an array because socklnd bonding can still be configured
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index a8eb3b8f9fd7..ac29f9d24d5d 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -57,11 +57,15 @@ struct lnet_ioctl_config_o2iblnd_tunables {
__u16 pad;
};

+struct lnet_lnd_tunables {
+ union {
+ struct lnet_ioctl_config_o2iblnd_tunables lnd_o2ib;
+ } lnd_tun_u;
+};
+
struct lnet_ioctl_config_lnd_tunables {
struct lnet_ioctl_config_lnd_cmn_tunables lt_cmn;
- union {
- struct lnet_ioctl_config_o2iblnd_tunables lt_o2ib;
- } lt_tun_u;
+ struct lnet_lnd_tunables lt_tun;
};

struct lnet_ioctl_net_config {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 5e1592b398c1..ade566d20c69 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2122,7 +2122,7 @@ static int kiblnd_net_init_pools(struct kib_net *net, struct lnet_ni *ni,
int rc;
int i;

- tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;

if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) {
CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n",
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index 42dc15cef194..522eb150d9a6 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -608,7 +608,7 @@ kiblnd_cfg_rdma_frags(struct lnet_ni *ni)
struct lnet_ioctl_config_o2iblnd_tunables *tunables;
int mod;

- tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
mod = tunables->lnd_map_on_demand;
return mod ? mod : IBLND_MAX_RDMA_FRAGS >> IBLND_FRAG_SHIFT;
}
@@ -627,7 +627,7 @@ kiblnd_concurrent_sends(int version, struct lnet_ni *ni)
struct lnet_ioctl_config_o2iblnd_tunables *tunables;
int concurrent_sends;

- tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
concurrent_sends = tunables->lnd_concurrent_sends;

if (version == IBLND_MSG_VERSION_1) {
@@ -777,7 +777,7 @@ kiblnd_need_noop(struct kib_conn *conn)
struct lnet_ni *ni = conn->ibc_peer->ibp_ni;

LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
- tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;

if (conn->ibc_outstanding_credits <
   IBLND_CREDITS_HIGHWATER(tunables, conn->ibc_version) &&
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index a8d2b4911dab..c266940cb2ae 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1452,7 +1452,7 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)

/* Brand new peer */
LASSERT(!peer->ibp_connecting);
- tunables = &peer->ibp_ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+ tunables = &peer->ibp_ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
peer->ibp_connecting = tunables->lnd_conns_per_peer;

/* always called with a ref on ni, which prevents ni being shutdown */
@@ -2592,14 +2592,14 @@ kiblnd_check_reconnect(struct kib_conn *conn, int version,
break;

case IBLND_REJECT_RDMA_FRAGS: {
- struct lnet_ioctl_config_lnd_tunables *tunables;
+ struct lnet_ioctl_config_o2iblnd_tunables *tunables;

if (!cp) {
reason = "can't negotiate max frags";
goto out;
}
- tunables = peer->ibp_ni->ni_lnd_tunables;
- if (!tunables->lt_tun_u.lt_o2ib.lnd_map_on_demand) {
+ tunables = &peer->ibp_ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
+ if (!tunables->lnd_map_on_demand) {
reason = "map_on_demand must be enabled";
goto out;
}
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index a1aca4dda38f..5117594f38fb 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -185,16 +185,11 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)
* if there was no tunables specified, setup the tunables to be
* defaulted
*/
- if (!ni->ni_lnd_tunables) {
- ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
-      GFP_NOFS);
- if (!ni->ni_lnd_tunables)
- return -ENOMEM;
-
- memcpy(&ni->ni_lnd_tunables->lt_tun_u.lt_o2ib,
+ if (!ni->ni_lnd_tunables_set)
+ memcpy(&ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib,
      &default_tunables, sizeof(*tunables));
- }
- tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+
+ tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;

/* Current API version */
tunables->lnd_version = 0;
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 0896e75bc3d7..c944fbb155c8 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1198,6 +1198,7 @@ static int
lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
{
struct lnet_ioctl_config_lnd_tunables *lnd_tunables = NULL;
+ struct lnet_lnd_tunables *tun = NULL;
int rc = -EINVAL;
int lnd_type;
struct lnet_lnd *lnd;
@@ -1250,19 +1251,15 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)

ni->ni_net->net_lnd = lnd;

- if (conf && conf->cfg_hdr.ioc_len > sizeof(*conf))
+ if (conf && conf->cfg_hdr.ioc_len > sizeof(*conf)) {
lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk;
+ tun = &lnd_tunables->lt_tun;
+ }

- if (lnd_tunables) {
- ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
-      GFP_NOFS);
- if (!ni->ni_lnd_tunables) {
- mutex_unlock(&the_lnet.ln_lnd_mutex);
- rc = -ENOMEM;
- goto failed0;
- }
- memcpy(ni->ni_lnd_tunables, lnd_tunables,
-       sizeof(*ni->ni_lnd_tunables));
+ if (tun) {
+ memcpy(&ni->ni_lnd_tunables, tun,
+       sizeof(*tun));
+ ni->ni_lnd_tunables_set = true;
}

/*
@@ -1702,15 +1699,15 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)
tunable_size = config->cfg_hdr.ioc_len - min_size;

/* Don't copy to much data to user space */
- min_size = min(tunable_size, sizeof(*ni->ni_lnd_tunables));
+ min_size = min(tunable_size, sizeof(ni->ni_lnd_tunables));
lnd_cfg = (struct lnet_ioctl_config_lnd_tunables *)net_config->cfg_bulk;

- if (ni->ni_lnd_tunables && lnd_cfg && min_size) {
- memcpy(lnd_cfg, ni->ni_lnd_tunables, min_size);
+ if (lnd_cfg && min_size) {
+ memcpy(&lnd_cfg->lt_tun, &ni->ni_lnd_tunables, min_size);
config->cfg_config_u.cfg_net.net_interface_count = 1;

/* Tell user land that kernel side has less data */
- if (tunable_size > sizeof(*ni->ni_lnd_tunables)) {
+ if (tunable_size > sizeof(ni->ni_lnd_tunables)) {
min_size = tunable_size - sizeof(ni->ni_lnd_tunables);
config->cfg_hdr.ioc_len -= min_size;
}
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 86a53854e427..5646feeb433e 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -105,8 +105,6 @@ lnet_ni_free(struct lnet_ni *ni)
if (ni->ni_cpts)
cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);

- kfree(ni->ni_lnd_tunables);
-
for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++)
kfree(ni->ni_interfaces[i]);
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
James Simmons: Should these tunable changes be made to gnilnd in a separate patch set?
<div class=""><br class="">
</div>
<div class="">Reviewed-by: Doug Oucharek &lt;<a href="mailto:dougso@me.com" class="">dougso@me.com</a>&gt;</div>
<div class=""><br class="">
</div>
<div class="">Doug</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Sep 6, 2018, at 5:49 PM, NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Instead of a pointer, embed the data struct.<br class="">
Also other related changes.<br class="">
<br class="">
This is part of<br class="">
&nbsp;&nbsp;&nbsp;8cbb8cd3e771e7f7e0f99cafc19fad32770dc015<br class="">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LU-7734 lnet: Multi-Rail local NI split<br class="">
<br class="">
Signed-off-by: NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt;<br class="">
---<br class="">
.../staging/lustre/include/linux/lnet/lib-types.h &nbsp;| &nbsp;&nbsp;&nbsp;6 &#43;&#43;&#43;&#43;<br class="">
.../lustre/include/uapi/linux/lnet/lnet-dlc.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;10 &#43;&#43;&#43;&#43;&#43;--<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 &#43;<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;6 &#43;&#43;--<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | &nbsp;&nbsp;&nbsp;8 &#43;&#43;&#43;---<br class="">
.../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c &nbsp;| &nbsp;&nbsp;13 &#43;&#43;&#43;-------<br class="">
drivers/staging/lustre/lnet/lnet/api-ni.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;27 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;-----------<br class="">
drivers/staging/lustre/lnet/lnet/config.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 -<br class="">
8 files changed, 36 insertions(&#43;), 38 deletions(-)<br class="">
<br class="">
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
index e170eb07a5bf..c5e3363de727 100644<br class="">
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
@@ -302,7 &#43;302,11 @@ struct lnet_ni {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ni_status<span class="Apple-tab-span" style="white-space:pre">
</span>*ni_status;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* per NI LND tunables */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_lnd_tunables ni_lnd_tunables;<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/* lnd tunables set explicitly */<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>bool ni_lnd_tunables_set;<br class="">
&#43;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/*<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* equivalent interfaces to use<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* This is an array because socklnd bonding can still be configured<br class="">
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
index a8eb3b8f9fd7..ac29f9d24d5d 100644<br class="">
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
@@ -57,11 &#43;57,15 @@ struct lnet_ioctl_config_o2iblnd_tunables {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>__u16 pad;<br class="">
};<br class="">
<br class="">
&#43;struct lnet_lnd_tunables {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>union {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables lnd_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>} lnd_tun_u;<br class="">
&#43;};<br class="">
&#43;<br class="">
struct lnet_ioctl_config_lnd_tunables {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_lnd_cmn_tunables lt_cmn;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>union {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables lt_o2ib;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>} lt_tun_u;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_lnd_tunables lt_tun;<br class="">
};<br class="">
<br class="">
struct lnet_ioctl_net_config {<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
index 5e1592b398c1..ade566d20c69 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
@@ -2122,7 &#43;2122,7 @@ static int kiblnd_net_init_pools(struct kib_net *net, struct lnet_ni *ni,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int rc;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int i;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (tunables-&gt;lnd_fmr_pool_size &lt; *kiblnd_tunables.kib_ntx / 4) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>CERROR(&quot;Can't set fmr pool size (%d) &lt; ntx / 4(%d)\n&quot;,<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h<br class="">
index 42dc15cef194..522eb150d9a6 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h<br class="">
@@ -608,7 &#43;608,7 @@ kiblnd_cfg_rdma_frags(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables *tunables;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int mod;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>mod = tunables-&gt;lnd_map_on_demand;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return mod ? mod : IBLND_MAX_RDMA_FRAGS &gt;&gt; IBLND_FRAG_SHIFT;<br class="">
}<br class="">
@@ -627,7 &#43;627,7 @@ kiblnd_concurrent_sends(int version, struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables *tunables;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int concurrent_sends;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>concurrent_sends = tunables-&gt;lnd_concurrent_sends;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (version == IBLND_MSG_VERSION_1) {<br class="">
@@ -777,7 &#43;777,7 @@ kiblnd_need_noop(struct kib_conn *conn)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ni *ni = conn-&gt;ibc_peer-&gt;ibp_ni;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(conn-&gt;ibc_state &gt;= IBLND_CONN_ESTABLISHED);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (conn-&gt;ibc_outstanding_credits &lt;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;IBLND_CREDITS_HIGHWATER(tunables, conn-&gt;ibc_version) &amp;&amp;<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
index a8d2b4911dab..c266940cb2ae 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c<br class="">
@@ -1452,7 &#43;1452,7 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* Brand new peer */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(!peer-&gt;ibp_connecting);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;peer-&gt;ibp_ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;peer-&gt;ibp_ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>peer-&gt;ibp_connecting = tunables-&gt;lnd_conns_per_peer;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* always called with a ref on ni, which prevents ni being shutdown */<br class="">
@@ -2592,14 &#43;2592,14 @@ kiblnd_check_reconnect(struct kib_conn *conn, int version,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>break;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>case IBLND_REJECT_RDMA_FRAGS: {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_lnd_tunables *tunables;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables *tunables;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (!cp) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>reason = &quot;can't negotiate max frags&quot;;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto out;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables = peer-&gt;ibp_ni-&gt;ni_lnd_tunables;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (!tunables-&gt;lt_tun_u.lt_o2ib.lnd_map_on_demand) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables = &amp;peer-&gt;ibp_ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (!tunables-&gt;lnd_map_on_demand) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>reason = &quot;map_on_demand must be enabled&quot;;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto out;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
index a1aca4dda38f..5117594f38fb 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
@@ -185,16 &#43;185,11 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* if there was no tunables specified, setup the tunables to be<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* defaulted<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>*/<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_lnd_tunables) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_lnd_tunables = kzalloc(sizeof(*ni-&gt;ni_lnd_tunables),<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GFP_NOFS);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (!ni-&gt;ni_lnd_tunables)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return -ENOMEM;<br class="">
-<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(&amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_lnd_tunables_set)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(&amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;default_tunables, sizeof(*tunables));<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables-&gt;lt_tun_u.lt_o2ib;<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>tunables = &amp;ni-&gt;ni_lnd_tunables.lnd_tun_u.lnd_o2ib;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* Current API version */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_version = 0;<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
index 0896e75bc3d7..c944fbb155c8 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
@@ -1198,6 &#43;1198,7 @@ static int<br class="">
lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_lnd_tunables *lnd_tunables = NULL;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_lnd_tunables *tun = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int rc = -EINVAL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int lnd_type;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_lnd *lnd;<br class="">
@@ -1250,19 &#43;1251,15 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_lnd = lnd;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (conf &amp;&amp; conf-&gt;cfg_hdr.ioc_len &gt; sizeof(*conf))<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (conf &amp;&amp; conf-&gt;cfg_hdr.ioc_len &gt; sizeof(*conf)) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf-&gt;cfg_bulk;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tun = &amp;lnd_tunables-&gt;lt_tun;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (lnd_tunables) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_lnd_tunables = kzalloc(sizeof(*ni-&gt;ni_lnd_tunables),<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GFP_NOFS);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (!ni-&gt;ni_lnd_tunables) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>mutex_unlock(&amp;the_lnet.ln_lnd_mutex);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>rc = -ENOMEM;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto failed0;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(ni-&gt;ni_lnd_tunables, lnd_tunables,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sizeof(*ni-&gt;ni_lnd_tunables));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tun) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(&amp;ni-&gt;ni_lnd_tunables, tun,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sizeof(*tun));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_lnd_tunables_set = true;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/*<br class="">
@@ -1702,15 &#43;1699,15 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tunable_size = config-&gt;cfg_hdr.ioc_len - min_size;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* Don't copy to much data to user space */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>min_size = min(tunable_size, sizeof(*ni-&gt;ni_lnd_tunables));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>min_size = min(tunable_size, sizeof(ni-&gt;ni_lnd_tunables));<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnd_cfg = (struct lnet_ioctl_config_lnd_tunables *)net_config-&gt;cfg_bulk;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni-&gt;ni_lnd_tunables &amp;&amp; lnd_cfg &amp;&amp; min_size) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(lnd_cfg, ni-&gt;ni_lnd_tunables, min_size);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (lnd_cfg &amp;&amp; min_size) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>memcpy(&amp;lnd_cfg-&gt;lt_tun, &amp;ni-&gt;ni_lnd_tunables, min_size);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>config-&gt;cfg_config_u.cfg_net.net_interface_count = 1;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>/* Tell user land that kernel side has less data */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (tunable_size &gt; sizeof(*ni-&gt;ni_lnd_tunables)) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (tunable_size &gt; sizeof(ni-&gt;ni_lnd_tunables)) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>min_size = tunable_size - sizeof(ni-&gt;ni_lnd_tunables);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>config-&gt;cfg_hdr.ioc_len -= min_size;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c<br class="">
index 86a53854e427..5646feeb433e 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/config.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/config.c<br class="">
@@ -105,8 &#43;105,6 @@ lnet_ni_free(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (ni-&gt;ni_cpts)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>cfs_expr_list_values_free(ni-&gt;ni_cpts, ni-&gt;ni_ncpts);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>kfree(ni-&gt;ni_lnd_tunables);<br class="">
-<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>for (i = 0; i &lt; LNET_MAX_INTERFACES &amp;&amp; ni-&gt;ni_interfaces[i]; i&#43;&#43;)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>kfree(ni-&gt;ni_interfaces[i]);<br class="">
<br class="">
<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>
diff mbox series

Patch

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index e170eb07a5bf..c5e3363de727 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -302,7 +302,11 @@  struct lnet_ni {
 	struct lnet_ni_status	*ni_status;
 
 	/* per NI LND tunables */
-	struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables;
+	struct lnet_lnd_tunables ni_lnd_tunables;
+
+	/* lnd tunables set explicitly */
+	bool ni_lnd_tunables_set;
+
 	/*
 	 * equivalent interfaces to use
 	 * This is an array because socklnd bonding can still be configured
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index a8eb3b8f9fd7..ac29f9d24d5d 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -57,11 +57,15 @@  struct lnet_ioctl_config_o2iblnd_tunables {
 	__u16 pad;
 };
 
+struct lnet_lnd_tunables {
+	union {
+		struct lnet_ioctl_config_o2iblnd_tunables lnd_o2ib;
+	} lnd_tun_u;
+};
+
 struct lnet_ioctl_config_lnd_tunables {
 	struct lnet_ioctl_config_lnd_cmn_tunables lt_cmn;
-	union {
-		struct lnet_ioctl_config_o2iblnd_tunables lt_o2ib;
-	} lt_tun_u;
+	struct lnet_lnd_tunables lt_tun;
 };
 
 struct lnet_ioctl_net_config {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 5e1592b398c1..ade566d20c69 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2122,7 +2122,7 @@  static int kiblnd_net_init_pools(struct kib_net *net, struct lnet_ni *ni,
 	int rc;
 	int i;
 
-	tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+	tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 
 	if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) {
 		CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n",
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index 42dc15cef194..522eb150d9a6 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -608,7 +608,7 @@  kiblnd_cfg_rdma_frags(struct lnet_ni *ni)
 	struct lnet_ioctl_config_o2iblnd_tunables *tunables;
 	int mod;
 
-	tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+	tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 	mod = tunables->lnd_map_on_demand;
 	return mod ? mod : IBLND_MAX_RDMA_FRAGS >> IBLND_FRAG_SHIFT;
 }
@@ -627,7 +627,7 @@  kiblnd_concurrent_sends(int version, struct lnet_ni *ni)
 	struct lnet_ioctl_config_o2iblnd_tunables *tunables;
 	int concurrent_sends;
 
-	tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+	tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 	concurrent_sends = tunables->lnd_concurrent_sends;
 
 	if (version == IBLND_MSG_VERSION_1) {
@@ -777,7 +777,7 @@  kiblnd_need_noop(struct kib_conn *conn)
 	struct lnet_ni *ni = conn->ibc_peer->ibp_ni;
 
 	LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
-	tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+	tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 
 	if (conn->ibc_outstanding_credits <
 	    IBLND_CREDITS_HIGHWATER(tunables, conn->ibc_version) &&
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index a8d2b4911dab..c266940cb2ae 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1452,7 +1452,7 @@  kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
 
 	/* Brand new peer */
 	LASSERT(!peer->ibp_connecting);
-	tunables = &peer->ibp_ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+	tunables = &peer->ibp_ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 	peer->ibp_connecting = tunables->lnd_conns_per_peer;
 
 	/* always called with a ref on ni, which prevents ni being shutdown */
@@ -2592,14 +2592,14 @@  kiblnd_check_reconnect(struct kib_conn *conn, int version,
 		break;
 
 	case IBLND_REJECT_RDMA_FRAGS: {
-		struct lnet_ioctl_config_lnd_tunables *tunables;
+		struct lnet_ioctl_config_o2iblnd_tunables *tunables;
 
 		if (!cp) {
 			reason = "can't negotiate max frags";
 			goto out;
 		}
-		tunables = peer->ibp_ni->ni_lnd_tunables;
-		if (!tunables->lt_tun_u.lt_o2ib.lnd_map_on_demand) {
+		tunables = &peer->ibp_ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
+		if (!tunables->lnd_map_on_demand) {
 			reason = "map_on_demand must be enabled";
 			goto out;
 		}
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index a1aca4dda38f..5117594f38fb 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -185,16 +185,11 @@  int kiblnd_tunables_setup(struct lnet_ni *ni)
 	 * if there was no tunables specified, setup the tunables to be
 	 * defaulted
 	 */
-	if (!ni->ni_lnd_tunables) {
-		ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
-					      GFP_NOFS);
-		if (!ni->ni_lnd_tunables)
-			return -ENOMEM;
-
-		memcpy(&ni->ni_lnd_tunables->lt_tun_u.lt_o2ib,
+	if (!ni->ni_lnd_tunables_set)
+		memcpy(&ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib,
 		       &default_tunables, sizeof(*tunables));
-	}
-	tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+
+	tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 
 	/* Current API version */
 	tunables->lnd_version = 0;
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 0896e75bc3d7..c944fbb155c8 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1198,6 +1198,7 @@  static int
 lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 {
 	struct lnet_ioctl_config_lnd_tunables *lnd_tunables = NULL;
+	struct lnet_lnd_tunables *tun = NULL;
 	int rc = -EINVAL;
 	int lnd_type;
 	struct lnet_lnd *lnd;
@@ -1250,19 +1251,15 @@  lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 
 	ni->ni_net->net_lnd = lnd;
 
-	if (conf && conf->cfg_hdr.ioc_len > sizeof(*conf))
+	if (conf && conf->cfg_hdr.ioc_len > sizeof(*conf)) {
 		lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk;
+		tun = &lnd_tunables->lt_tun;
+	}
 
-	if (lnd_tunables) {
-		ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
-					      GFP_NOFS);
-		if (!ni->ni_lnd_tunables) {
-			mutex_unlock(&the_lnet.ln_lnd_mutex);
-			rc = -ENOMEM;
-			goto failed0;
-		}
-		memcpy(ni->ni_lnd_tunables, lnd_tunables,
-		       sizeof(*ni->ni_lnd_tunables));
+	if (tun) {
+		memcpy(&ni->ni_lnd_tunables, tun,
+		       sizeof(*tun));
+		ni->ni_lnd_tunables_set = true;
 	}
 
 	/*
@@ -1702,15 +1699,15 @@  lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)
 		tunable_size = config->cfg_hdr.ioc_len - min_size;
 
 	/* Don't copy to much data to user space */
-	min_size = min(tunable_size, sizeof(*ni->ni_lnd_tunables));
+	min_size = min(tunable_size, sizeof(ni->ni_lnd_tunables));
 	lnd_cfg = (struct lnet_ioctl_config_lnd_tunables *)net_config->cfg_bulk;
 
-	if (ni->ni_lnd_tunables && lnd_cfg && min_size) {
-		memcpy(lnd_cfg, ni->ni_lnd_tunables, min_size);
+	if (lnd_cfg && min_size) {
+		memcpy(&lnd_cfg->lt_tun, &ni->ni_lnd_tunables, min_size);
 		config->cfg_config_u.cfg_net.net_interface_count = 1;
 
 		/* Tell user land that kernel side has less data */
-		if (tunable_size > sizeof(*ni->ni_lnd_tunables)) {
+		if (tunable_size > sizeof(ni->ni_lnd_tunables)) {
 			min_size = tunable_size - sizeof(ni->ni_lnd_tunables);
 			config->cfg_hdr.ioc_len -= min_size;
 		}
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 86a53854e427..5646feeb433e 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -105,8 +105,6 @@  lnet_ni_free(struct lnet_ni *ni)
 	if (ni->ni_cpts)
 		cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
 
-	kfree(ni->ni_lnd_tunables);
-
 	for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++)
 		kfree(ni->ni_interfaces[i]);