Commit 4c342f77 authored by Rao Shoaib's avatar Rao Shoaib Committed by David S. Miller

rds: transport module should be auto loaded when transport is set

This enhancement auto loads transport module when the transport
is set via SO_RDS_TRANSPORT socket option.
Reviewed-by: default avatarKa-Cheong Poon <ka-cheong.poon@oracle.com>
Reviewed-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
Signed-off-by: default avatarRao Shoaib <rao.shoaib@oracle.com>
Signed-off-by: default avatarSomasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6aeaf262
...@@ -64,10 +64,12 @@ ...@@ -64,10 +64,12 @@
/* supported values for SO_RDS_TRANSPORT */ /* supported values for SO_RDS_TRANSPORT */
#define RDS_TRANS_IB 0 #define RDS_TRANS_IB 0
#define RDS_TRANS_IWARP 1 #define RDS_TRANS_GAP 1
#define RDS_TRANS_TCP 2 #define RDS_TRANS_TCP 2
#define RDS_TRANS_COUNT 3 #define RDS_TRANS_COUNT 3
#define RDS_TRANS_NONE (~0) #define RDS_TRANS_NONE (~0)
/* don't use RDS_TRANS_IWARP - it is deprecated */
#define RDS_TRANS_IWARP RDS_TRANS_GAP
/* IOCTLS commands for SOL_RDS */ /* IOCTLS commands for SOL_RDS */
#define SIOCRDSSETTOS (SIOCPROTOPRIVATE) #define SIOCRDSSETTOS (SIOCPROTOPRIVATE)
......
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
#include "rds.h" #include "rds.h"
#include "loop.h" #include "loop.h"
static char * const rds_trans_modules[] = {
[RDS_TRANS_IB] = "rds_rdma",
[RDS_TRANS_GAP] = NULL,
[RDS_TRANS_TCP] = "rds_tcp",
};
static struct rds_transport *transports[RDS_TRANS_COUNT]; static struct rds_transport *transports[RDS_TRANS_COUNT];
static DECLARE_RWSEM(rds_trans_sem); static DECLARE_RWSEM(rds_trans_sem);
...@@ -110,18 +116,20 @@ struct rds_transport *rds_trans_get(int t_type) ...@@ -110,18 +116,20 @@ struct rds_transport *rds_trans_get(int t_type)
{ {
struct rds_transport *ret = NULL; struct rds_transport *ret = NULL;
struct rds_transport *trans; struct rds_transport *trans;
unsigned int i;
down_read(&rds_trans_sem); down_read(&rds_trans_sem);
for (i = 0; i < RDS_TRANS_COUNT; i++) { trans = transports[t_type];
trans = transports[i]; if (!trans) {
up_read(&rds_trans_sem);
if (trans && trans->t_type == t_type && if (rds_trans_modules[t_type])
(!trans->t_owner || try_module_get(trans->t_owner))) { request_module(rds_trans_modules[t_type]);
ret = trans; down_read(&rds_trans_sem);
break; trans = transports[t_type];
}
} }
if (trans && trans->t_type == t_type &&
(!trans->t_owner || try_module_get(trans->t_owner)))
ret = trans;
up_read(&rds_trans_sem); up_read(&rds_trans_sem);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment