From: Dan Carpenter <dan.carpenter@oracle.com>
To: James Simmons <jsimmons@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, Oleg Drokin <oleg.drokin@intel.com>,
Andreas Dilger <andreas.dilger@intel.com>,
Amir Shehata <amir.shehata@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
lustre-devel@lists.lustre.org
Subject: Re: [PATCH 15/40] staging: lustre: DLC user/kernel space glue code
Date: Wed, 2 Dec 2015 15:11:54 +0300 [thread overview]
Message-ID: <20151202121154.GP18797@mwanda> (raw)
In-Reply-To: <1448062576-23757-16-git-send-email-jsimmons@infradead.org>
On Fri, Nov 20, 2015 at 06:35:51PM -0500, James Simmons wrote:
> From: Amir Shehata <amir.shehata@intel.com>
>
> This is the sixth patch of a set of patches that enables DLC.
>
> This patch enables the user space to call into the kernel space
> DLC code. Added handlers in the LNetCtl function to call
> the new functions added for Dynamic Lnet Configuration
>
> Signed-off-by: Amir Shehata <amir.shehata@intel.com>
> ntel-bug-id: https://jira.hpdd.intel.com/browse/LU-2456
> Reviewed-on: http://review.whamcloud.com/8023
> Reviewed-by: James Simmons <uja.ornl@gmail.com>
> Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
> Reviewed-by: John L. Hammond <john.hammond@intel.com>
> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
> ---
> .../staging/lustre/include/linux/lnet/lib-lnet.h | 22 ++-
> .../staging/lustre/include/linux/lnet/lib-types.h | 8 +
> drivers/staging/lustre/lnet/lnet/api-ni.c | 172 ++++++++++++++++++--
> drivers/staging/lustre/lnet/lnet/module.c | 53 ++++++-
> drivers/staging/lustre/lnet/lnet/peer.c | 34 ++--
> drivers/staging/lustre/lnet/lnet/router.c | 71 +++++++--
> 6 files changed, 307 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index f2874e0..63919dd 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -39,6 +39,7 @@
> #include "api.h"
> #include "lnet.h"
> #include "lib-types.h"
> +#include "lib-dlc.h"
>
> extern lnet_t the_lnet; /* THE network */
>
> @@ -456,6 +457,12 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
> void lnet_destroy_routes(void);
> int lnet_get_route(int idx, __u32 *net, __u32 *hops,
> lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
> +int lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid,
> + int *peer_timeout, int *peer_tx_credits,
> + int *peer_rtr_cr, int *max_tx_credits,
> + struct lnet_ioctl_net_config *net_config);
> +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg);
> +
> void lnet_router_debugfs_init(void);
> void lnet_router_debugfs_fini(void);
> int lnet_rtrpools_alloc(int im_a_router);
> @@ -465,6 +472,10 @@ int lnet_rtrpools_enable(void);
> void lnet_rtrpools_disable(void);
> void lnet_rtrpools_free(int keep_pools);
> lnet_remotenet_t *lnet_find_net_locked(__u32 net);
> +int lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
> + __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr,
> + __s32 credits);
> +int lnet_dyn_del_ni(__u32 net);
>
> int lnet_islocalnid(lnet_nid_t nid);
> int lnet_islocalnet(__u32 net);
> @@ -694,11 +705,12 @@ void lnet_peer_tables_cleanup(lnet_ni_t *ni);
> void lnet_peer_tables_destroy(void);
> int lnet_peer_tables_create(void);
> void lnet_debug_peer(lnet_nid_t nid);
> -int lnet_get_peers(int count, __u64 *nid, char *alivness,
> - int *ncpt, int *refcount,
> - int *ni_peer_tx_credits, int *peer_tx_credits,
> - int *peer_rtr_credits, int *peer_min_rtr_credtis,
> - int *peer_tx_qnob);
> +int lnet_get_peer_info(__u32 peer_index, __u64 *nid,
> + char alivness[LNET_MAX_STR_LEN],
> + __u32 *cpt_iter, __u32 *refcount,
> + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits,
> + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis,
> + __u32 *peer_tx_qnob);
>
> static inline void
> lnet_peer_set_alive(lnet_peer_t *lp)
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> index e7585b9..3282782 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> @@ -611,6 +611,14 @@ typedef struct {
> /* test protocol compatibility flags */
> int ln_testprotocompat;
>
> + /*
> + * 0 - load the NIs from the mod params
> + * 1 - do not load the NIs from the mod params
> + * Reverse logic to ensure that other calls to LNetNIInit
> + * need no change
> + */
> + bool ln_nis_from_mod_params;
> +
> } lnet_t;
>
> #endif
> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
> index cc87900..125d018 100644
> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
> @@ -1542,7 +1542,9 @@ LNetNIInit(lnet_pid_t requested_pid)
> if (rc != 0)
> goto failed0;
>
> - rc = lnet_parse_networks(&net_head, lnet_get_networks());
> + rc = lnet_parse_networks(&net_head,
> + !the_lnet.ln_nis_from_mod_params ?
> + lnet_get_networks() : "");
> if (rc < 0)
> goto failed1;
>
> @@ -1657,6 +1659,93 @@ LNetNIFini(void)
> }
> EXPORT_SYMBOL(LNetNIFini);
>
> +/**
> + * Grabs the ni data from the ni structure and fills the out
> + * parameters
> + *
> + * \param[in] ni network interface structure
> + * \param[out] cpt_count the number of cpts the ni is on
> + * \param[out] nid Network Interface ID
> + * \param[out] peer_timeout NI peer timeout
> + * \param[out] peer_tx_crdits NI peer transmit credits
> + * \param[out] peer_rtr_credits NI peer router credits
> + * \param[out] max_tx_credits NI max transmit credit
> + * \param[out] net_config Network configuration
> + */
> +static void
> +lnet_fill_ni_info(struct lnet_ni *ni, __u32 *cpt_count, __u64 *nid,
> + int *peer_timeout, int *peer_tx_credits,
> + int *peer_rtr_credits, int *max_tx_credits,
> + struct lnet_ioctl_net_config *net_config)
> +{
> + int i;
> +
> + if (!ni)
> + return;
> +
> + if (!net_config)
> + return;
> +
> + CLASSERT(ARRAY_SIZE(ni->ni_interfaces) ==
> + ARRAY_SIZE(net_config->ni_interfaces));
The kernel has a macro for this BUILD_BUG_ON().
> +
> + if (ni->ni_interfaces[0]) {
Couldn't we just break at the first NULL?
> + for (i = 0; i < ARRAY_SIZE(ni->ni_interfaces); i++) {
> + if (ni->ni_interfaces[i]) {
> + strncpy(net_config->ni_interfaces[i],
> + ni->ni_interfaces[i],
> + sizeof(net_config->ni_interfaces[i]));
> + }
> + }
> + }
> +
for (i = 0; i < ARRAY_SIZE(ni->ni_interfaces); i++) {
if (!ni->ni_interfaces[i])
break;
strncpy(net_config->ni_interfaces[i],
ni->ni_interfaces[i],
sizeof(net_config->ni_interfaces[i]));
}
> + *nid = ni->ni_nid;
> + *peer_timeout = ni->ni_peertimeout;
> + *peer_tx_credits = ni->ni_peertxcredits;
> + *peer_rtr_credits = ni->ni_peerrtrcredits;
> + *max_tx_credits = ni->ni_maxtxcredits;
> +
> + net_config->ni_status = ni->ni_status->ns_status;
> +
> + for (i = 0;
> + ni->ni_cpts && i < ni->ni_ncpts &&
> + i < LNET_MAX_SHOW_NUM_CPT;
This is really sort of a crap condition and either you are doing it to
please an inferior static checker (don't write nonsense code to please
the static checker) or there is something very confused about your code
and you should fix it elsewhere. The loop here should be:
for (i = 0; i < ni->ni_ncpts; i++)
net_config->ni_cpts[i] = ni->ni_cpts[i];
> + i++)
> + net_config->ni_cpts[i] = ni->ni_cpts[i];
> +
> + *cpt_count = ni->ni_ncpts;
> +}
> +
> +int
> +lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid, int *peer_timeout,
> + int *peer_tx_credits, int *peer_rtr_credits,
> + int *max_tx_credits,
> + struct lnet_ioctl_net_config *net_config)
> +{
> + struct lnet_ni *ni;
> + struct list_head *tmp;
> + int cpt;
> + int rc = -ENOENT;
> +
> + cpt = lnet_net_lock_current();
> +
> + list_for_each(tmp, &the_lnet.ln_nis) {
> + ni = list_entry(tmp, lnet_ni_t, ni_list);
> + if (idx-- == 0) {
> + rc = 0;
> + lnet_ni_lock(ni);
> + lnet_fill_ni_info(ni, cpt_count, nid, peer_timeout,
> + peer_tx_credits, peer_rtr_credits,
> + max_tx_credits, net_config);
> + lnet_ni_unlock(ni);
> + break;
> + }
> + }
Write it something like this:
i = 0;
list_for_each(tmp, &the_lnet.ln_nis) {
if (i++ != idx)
continue;
ni = list_entry(tmp, lnet_ni_t, ni_list);
lnet_ni_lock(ni);
lnet_fill_ni_info(ni, cpt_count, nid, peer_timeout,
peer_tx_credits, peer_rtr_credits,
max_tx_credits, net_config);
lnet_ni_unlock(ni);
rc = 0;
break;
}
> +
> + lnet_net_unlock(cpt);
> + return rc;
> +}
> +
> int
> lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
> __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr,
> @@ -1757,9 +1846,13 @@ LNetCtl(unsigned int cmd, void *arg)
> return lnet_fail_nid(data->ioc_nid, data->ioc_count);
>
> case IOC_LIBCFS_ADD_ROUTE:
> + config = arg;
Check ioc_len.
> mutex_lock(&the_lnet.ln_api_mutex);
> - rc = lnet_add_route(data->ioc_net, data->ioc_count,
> - data->ioc_nid, data->ioc_priority);
> + rc = lnet_add_route(config->cfg_net,
> + config->cfg_config_u.cfg_route.rtr_hop,
> + config->cfg_nid,
> + config->cfg_config_u.cfg_route.
> + rtr_priority);
> mutex_unlock(&the_lnet.ln_api_mutex);
> return (rc != 0) ? rc : lnet_check_routes();
>
> @@ -1780,14 +1873,28 @@ LNetCtl(unsigned int cmd, void *arg)
> &config->cfg_config_u.cfg_route.
> rtr_priority);
>
> - case IOC_LIBCFS_ADD_NET:
> - return 0;
> -
> - case IOC_LIBCFS_DEL_NET:
> - return 0;
> + case IOC_LIBCFS_GET_NET: {
> + struct lnet_ioctl_net_config *net_config;
>
> - case IOC_LIBCFS_GET_NET:
> - return 0;
> + config = arg;
Check ioc_len.
> + net_config = (struct lnet_ioctl_net_config *)
> + config->cfg_bulk;
> + if (!config || !net_config)
We already dereferenced "config" so it's a bit late to check for NULL.
But that's an interesting question if we need to add NULL checks every
where. I forget. Please check this and reply to the email thread.
> + return -1;
This is not a correct error code. return -EINVAL.
> +
> + return lnet_get_net_config(config->cfg_count,
> + &config->cfg_ncpts,
> + &config->cfg_nid,
> + &config->cfg_config_u.cfg_net.
> + net_peer_timeout,
> + &config->cfg_config_u.cfg_net.
> + net_peer_tx_credits,
> + &config->cfg_config_u.cfg_net.
> + net_peer_rtr_credits,
> + &config->cfg_config_u.cfg_net.
> + net_max_tx_credits,
> + net_config);
Breaking it up like this is nasty.
return lnet_get_net_config(
config->cfg_count,
&config->cfg_ncpts,
&config->cfg_nid,
&config->cfg_config_u.cfg_net.net_peer_timeout,
&config->cfg_config_u.cfg_net.net_peer_tx_credits,
&config->cfg_config_u.cfg_net.net_peer_rtr_credits,
&config->cfg_config_u.cfg_net.net_max_tx_credits,
net_config);
It violates checkpatch.pl rules, but don't write ugly code just to make
a tool happy.
> + }
>
> case IOC_LIBCFS_GET_LNET_STATS:
> {
> @@ -1798,16 +1905,51 @@ LNetCtl(unsigned int cmd, void *arg)
> }
>
> case IOC_LIBCFS_CONFIG_RTR:
> + config = arg;
ioc_len.
> + mutex_lock(&the_lnet.ln_api_mutex);
> + if (config->cfg_config_u.cfg_buffers.buf_enable) {
> + rc = lnet_rtrpools_enable();
> + mutex_unlock(&the_lnet.ln_api_mutex);
> + return rc;
> + }
> + lnet_rtrpools_disable();
> + mutex_unlock(&the_lnet.ln_api_mutex);
> return 0;
>
> case IOC_LIBCFS_ADD_BUF:
> - return 0;
> + config = arg;
ioc_len.
> + mutex_lock(&the_lnet.ln_api_mutex);
> + rc = lnet_rtrpools_adjust(config->cfg_config_u.cfg_buffers.
> + buf_tiny,
> + config->cfg_config_u.cfg_buffers.
> + buf_small,
> + config->cfg_config_u.cfg_buffers.
> + buf_large);
Ugh.
> + mutex_unlock(&the_lnet.ln_api_mutex);
> + return rc;
>
> - case IOC_LIBCFS_GET_BUF:
> - return 0;
> + case IOC_LIBCFS_GET_BUF: {
> + struct lnet_ioctl_pool_cfg *pool_cfg;
>
> - case IOC_LIBCFS_GET_PEER_INFO:
> - return 0;
> + config = arg;
ioc_len.
> + pool_cfg = (struct lnet_ioctl_pool_cfg *)config->cfg_bulk;
> + return lnet_get_rtr_pool_cfg(config->cfg_count, pool_cfg);
> + }
> +
> + case IOC_LIBCFS_GET_PEER_INFO: {
> + struct lnet_ioctl_peer *peer_info = arg;
ioc_len.
> +
> + return lnet_get_peer_info(peer_info->pr_count,
> + &peer_info->pr_nid,
> + peer_info->pr_lnd_u.pr_peer_credits.cr_aliveness,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_ncpt,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_refcount,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_ni_peer_tx_credits,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_credits,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_rtr_credits,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_min_rtr_credits,
> + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob);
> + }
>
> case IOC_LIBCFS_NOTIFY_ROUTER:
> secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]);
> diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
> index ffc5700..281315c 100644
> --- a/drivers/staging/lustre/lnet/lnet/module.c
> +++ b/drivers/staging/lustre/lnet/lnet/module.c
> @@ -84,20 +84,69 @@ lnet_unconfigure(void)
> return (refcount == 0) ? 0 : -EBUSY;
> }
>
> +int
> +lnet_dyn_configure(struct libcfs_ioctl_hdr *hdr)
> +{
> + struct lnet_ioctl_config_data *conf =
> + (struct lnet_ioctl_config_data *)hdr;
> + int rc;
> +
We never checked ioc_len before calling this function so it could oops
if we read unmapped memory.
> + mutex_lock(&lnet_config_mutex);
> + if (the_lnet.ln_niinit_self)
Flip this around:
if (!the_lnet.ln_niinit_self) {
rc = -EINVAL;
goto unlock;
}
rc = lnet_dyn_add_ni(LUSTRE_SRV_LNET_PID, ...
> + rc = lnet_dyn_add_ni(LUSTRE_SRV_LNET_PID,
> + conf->cfg_config_u.cfg_net.net_intf,
> + conf->cfg_config_u.cfg_net.
> + net_peer_timeout,
> + conf->cfg_config_u.cfg_net.
> + net_peer_tx_credits,
> + conf->cfg_config_u.cfg_net.
> + net_peer_rtr_credits,
> + conf->cfg_config_u.cfg_net.
> + net_max_tx_credits);
> + else
> + rc = -EINVAL;
> + mutex_unlock(&lnet_config_mutex);
> + return rc;
> +}
> +
> +int
> +lnet_dyn_unconfigure(struct libcfs_ioctl_hdr *hdr)
> +{
> + struct lnet_ioctl_config_data *conf =
> + (struct lnet_ioctl_config_data *)hdr;
> + int rc;
> +
> + mutex_lock(&lnet_config_mutex);
> + if (the_lnet.ln_niinit_self)
Always consistently do error handling instead of success handling.
if (!the_lnet.ln_niinit_self) {
rc = -EINVAL;
goto unlock;
}
> + rc = lnet_dyn_del_ni(conf->cfg_net);
> + else
> + rc = -EINVAL;
> + mutex_unlock(&lnet_config_mutex);
> +
> + return rc;
> +}
> +
> static int
> lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
> {
> int rc;
>
> switch (cmd) {
> - case IOC_LIBCFS_CONFIGURE:
> + case IOC_LIBCFS_CONFIGURE: {
> + struct libcfs_ioctl_data *data =
> + (struct libcfs_ioctl_data *)hdr;
ioc_len.
> + the_lnet.ln_nis_from_mod_params = data->ioc_flags;
> return lnet_configure(NULL);
> + }
>
> case IOC_LIBCFS_UNCONFIGURE:
> return lnet_unconfigure();
>
> case IOC_LIBCFS_ADD_NET:
> - return LNetCtl(cmd, hdr);
> + return lnet_dyn_configure(hdr);
> +
> + case IOC_LIBCFS_DEL_NET:
> + return lnet_dyn_unconfigure(hdr);
ioc_len etc.
>
> default:
> /* Passing LNET_PID_ANY only gives me a ref if the net is up
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index 1402e27..3b71812 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -394,16 +394,18 @@ lnet_debug_peer(lnet_nid_t nid)
> lnet_net_unlock(cpt);
> }
>
> -int lnet_get_peers(int count, __u64 *nid, char *aliveness,
> - int *ncpt, int *refcount,
> - int *ni_peer_tx_credits, int *peer_tx_credits,
> - int *peer_rtr_credits, int *peer_min_rtr_credits,
> - int *peer_tx_qnob)
> +int
> +lnet_get_peer_info(__u32 peer_index, __u64 *nid,
> + char aliveness[LNET_MAX_STR_LEN],
> + __u32 *cpt_iter, __u32 *refcount,
> + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits,
> + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credits,
> + __u32 *peer_tx_qnob)
> {
> struct lnet_peer_table *peer_table;
> lnet_peer_t *lp;
> - int j;
> - int lncpt, found = 0;
> + bool found = false;
Unrelated.
> + int lncpt, j;
>
> /* get the number of CPTs */
> lncpt = cfs_percpt_number(the_lnet.ln_peer_tables);
> @@ -412,22 +414,22 @@ int lnet_get_peers(int count, __u64 *nid, char *aliveness,
> * if the cpt number to be examined is >= the number of cpts in
> * the system then indicate that there are no more cpts to examin
> */
> - if (*ncpt > lncpt)
> - return -1;
> + if (*cpt_iter > lncpt)
> + return -ENOENT;
Don't mix unrelated changes.
>
> /* get the current table */
> - peer_table = the_lnet.ln_peer_tables[*ncpt];
> + peer_table = the_lnet.ln_peer_tables[*cpt_iter];
> /* if the ptable is NULL then there are no more cpts to examine */
> if (!peer_table)
> - return -1;
> + return -ENOENT;
>
> - lnet_net_lock(*ncpt);
> + lnet_net_lock(*cpt_iter);
>
> for (j = 0; j < LNET_PEER_HASH_SIZE && !found; j++) {
> struct list_head *peers = &peer_table->pt_hash[j];
>
> list_for_each_entry(lp, peers, lp_hashlist) {
> - if (count-- > 0)
> + if (peer_index-- > 0)
> continue;
>
> snprintf(aliveness, LNET_MAX_STR_LEN, "NA");
> @@ -444,12 +446,12 @@ int lnet_get_peers(int count, __u64 *nid, char *aliveness,
> *peer_min_rtr_credits = lp->lp_mintxcredits;
> *peer_tx_qnob = lp->lp_txqnob;
>
> - found = 1;
> + found = true;
> }
> }
> - lnet_net_unlock(*ncpt);
> + lnet_net_unlock(*cpt_iter);
>
> - *ncpt = lncpt;
> + *cpt_iter = lncpt;
>
> return found ? 0 : -ENOENT;
> }
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 749085f..17e6795 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -541,6 +541,42 @@ lnet_destroy_routes(void)
> lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
> }
>
> +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg)
> +{
> + int i, rc = -ENOENT, lidx, j;
> +
> + if (!the_lnet.ln_rtrpools)
> + return rc;
Use literals where ever possible.
return -ENOENT;
> +
> + for (i = 0; i < LNET_NRBPOOLS; i++) {
> + lnet_rtrbufpool_t *rbp;
> +
> + lnet_net_lock(LNET_LOCK_EX);
> + lidx = idx;
> + cfs_percpt_for_each(rbp, j, the_lnet.ln_rtrpools) {
> + if (lidx-- == 0) {
Flip this around so you're not smooshed against the right side of the
screen.
if (i++ != idx)
continue;
Don't modify the original parameter. That way you can use it again and
also it makes the code easier to understand.
> + rc = 0;
Put the rc = 0 at the end next to the break. rc is used by the return
keep them near together so that the code is easier to understand.
> + pool_cfg->pl_pools[i].pl_npages =
> + rbp[i].rbp_npages;
> + pool_cfg->pl_pools[i].pl_nbuffers =
> + rbp[i].rbp_nbuffers;
> + pool_cfg->pl_pools[i].pl_credits =
> + rbp[i].rbp_credits;
> + pool_cfg->pl_pools[i].pl_mincredits =
> + rbp[i].rbp_mincredits;
> + break;
> + }
> + }
> + lnet_net_unlock(LNET_LOCK_EX);
> + }
> +
> + lnet_net_lock(LNET_LOCK_EX);
> + pool_cfg->pl_routing = the_lnet.ln_routing;
> + lnet_net_unlock(LNET_LOCK_EX);
> +
> + return rc;
> +}
> +
> int
> lnet_get_route(int idx, __u32 *net, __u32 *hops,
> lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
> @@ -1531,8 +1567,8 @@ lnet_rtrpools_alloc(int im_a_router)
> return rc;
> }
>
> -int
> -lnet_rtrpools_adjust(int tiny, int small, int large)
> +static int
> +lnet_rtrpools_adjust_helper(int tiny, int small, int large)
> {
> int nrb = 0;
> int rc = 0;
> @@ -1540,19 +1576,10 @@ lnet_rtrpools_adjust(int tiny, int small, int large)
> lnet_rtrbufpool_t *rtrp;
>
> /*
> - * this function doesn't revert the changes if adding new buffers
> - * failed. It's up to the user space caller to revert the
> - * changes.
> - */
> -
> - if (!the_lnet.ln_routing)
> - return 0;
> -
> - /*
> * If the provided values for each buffer pool are different than the
> * configured values, we need to take action.
> */
> - if (tiny >= 0 && tiny != tiny_router_buffers) {
> + if (tiny >= 0) {
Unrelated cleanups. And below.
regards,
dan carpenter
next prev parent reply other threads:[~2015-12-02 12:12 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 23:35 [PATCH 00/40] Sync upstream lustre client LNet core James Simmons
2015-11-20 23:35 ` [PATCH 01/40] staging: lustre: drop *_t from end of struct lnet_text_buf James Simmons
2015-11-20 23:35 ` [PATCH 02/40] staging: lustre: fix 'NULL pointer dereference' errors for LNet James Simmons
2015-12-02 7:46 ` Dan Carpenter
2015-12-15 18:08 ` Simmons, James A.
2015-11-20 23:35 ` [PATCH 03/40] staging: lustre: reflect down routes in /proc/sys/lnet/routes James Simmons
2015-12-02 7:54 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 04/40] staging: lustre: fix failure handle of create reply James Simmons
2015-11-20 23:35 ` [PATCH 05/40] staging: lustre: eliminate obsolete Cray SeaStar support James Simmons
2015-11-20 23:35 ` [PATCH 06/40] staging: lustre: remove uses of IS_ERR_VALUE() James Simmons
2015-11-21 18:45 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 07/40] staging: lustre: return +ve for blocked lnet message James Simmons
2015-11-20 23:35 ` [PATCH 08/40] staging: lustre: do not memset after LIBCFS_ALLOC James Simmons
2015-11-20 23:35 ` [PATCH 09/40] staging: lustre: Dynamic LNet Configuration (DLC) James Simmons
2015-11-20 23:35 ` [PATCH 10/40] staging: lustre: Dynamic LNet Configuration (DLC) dynamic routing James Simmons
2015-11-20 23:35 ` [PATCH 11/40] staging: lustre: DLC Feature dynamic net config James Simmons
2015-12-02 9:23 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 12/40] staging: lustre: Dynamic LNet Configuration (DLC) IOCTL changes James Simmons
2015-12-02 9:48 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command James Simmons
2015-12-02 11:20 ` Dan Carpenter
2015-12-15 18:14 ` Simmons, James A.
2015-12-15 18:19 ` Dan Carpenter
2015-12-15 18:39 ` Simmons, James A.
2015-12-15 18:48 ` Greg Kroah-Hartman
2015-12-15 19:48 ` Simmons, James A.
2015-12-15 19:55 ` 'Greg Kroah-Hartman'
2015-12-02 12:00 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 14/40] staging: lustre: fix crash due to NULL networks string James Simmons
2015-12-02 11:27 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 15/40] staging: lustre: DLC user/kernel space glue code James Simmons
2015-12-02 12:11 ` Dan Carpenter [this message]
2015-11-20 23:35 ` [PATCH 16/40] staging: lustre: make local functions static for LNet ni James Simmons
2015-11-20 23:35 ` [PATCH 17/40] staging: lustre: add sparse annotation __user wherever needed for lnet James Simmons
2015-11-20 23:35 ` [PATCH 18/40] staging: lustre: remove LUSTRE_{,SRV_}LNET_PID James Simmons
2015-11-20 23:35 ` [PATCH 19/40] staging: lustre: copy out libcfs ioctl inline buffer James Simmons
2015-12-02 12:34 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 20/40] staging: lustre: fix kernel crash when network failed to start James Simmons
2015-12-02 12:44 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 21/40] staging: lustre: improve LNet clean up code and API James Simmons
2015-12-02 12:59 ` Dan Carpenter
2015-12-02 13:20 ` [lustre-devel] " Alexander Zarochentsev
2015-12-02 13:59 ` Dan Carpenter
2015-12-15 17:10 ` Simmons, James A.
2015-12-15 17:41 ` Dan Carpenter
2015-11-20 23:35 ` [PATCH 22/40] staging: lustre: Fixes to make lnetctl function as expected James Simmons
2015-11-20 23:35 ` [PATCH 23/40] staging: lustre: return appropriate errno when adding route James Simmons
2015-11-20 23:36 ` [PATCH 24/40] staging: lustre: make some lnet functions static James Simmons
2015-11-20 23:36 ` [PATCH 25/40] staging: lustre: missed a few cases of using NULL instead of 0 James Simmons
2015-11-20 23:36 ` [PATCH 26/40] staging: lustre: startup lnet acceptor thread dynamically James Simmons
2015-11-20 23:36 ` [PATCH 27/40] staging: lustre: reject invalid net configuration for lnet James Simmons
2015-11-20 23:36 ` [PATCH 28/40] staging: lustre: return -EEXIST if NI is not unique James Simmons
2015-11-20 23:36 ` [PATCH 29/40] staging: lustre: handle lnet_check_routes() errors James Simmons
2015-11-20 23:36 ` [PATCH 30/40] staging: lustre: improvement to router checker James Simmons
2015-11-20 23:36 ` [PATCH 31/40] staging: lustre: assume a kernel build James Simmons
2015-11-20 23:36 ` [PATCH 32/40] staging: lustre: prevent assert on LNet module unload James Simmons
2015-11-20 23:36 ` [PATCH 33/40] staging: lustre: remove messages from lazy portal on NI shutdown James Simmons
2015-11-20 23:36 ` [PATCH 34/40] staging: lustre: remove unnecessary EXPORT_SYMBOL from lnet layer James Simmons
2015-11-20 23:36 ` [PATCH 35/40] staging: lustre: avoid race during lnet acceptor thread termination James Simmons
2015-11-20 23:36 ` [PATCH 36/40] staging: lustre: test for sk_sleep presence in compact-2.6.h James Simmons
2015-11-20 23:36 ` [PATCH 37/40] staging: lustre: remove unnecessary NULL check in IOC_LIBCFS_GET_NET James Simmons
2015-11-20 23:36 ` [PATCH 38/40] staging: lustre: Allocate the correct number of rtr buffers James Simmons
2015-11-20 23:36 ` [PATCH 39/40] staging: lustre: Use lnet_is_route_alive for router aliveness James Simmons
2015-11-20 23:36 ` [PATCH 40/40] staging: lustre: Remove LASSERTS from router checker James Simmons
2015-12-21 23:41 ` [PATCH 00/40] Sync upstream lustre client LNet core Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151202121154.GP18797@mwanda \
--to=dan.carpenter@oracle.com \
--cc=amir.shehata@intel.com \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox