Skip to content

Commit

Permalink
rds: transport module should be auto loaded when transport is set
Browse files Browse the repository at this point in the history
This enhancement auto loads transport module when the transport
is set via SO_RDS_TRANSPORT socket option.

Reviewed-by: Ka-Cheong Poon <[email protected]>
Reviewed-by: Håkon Bugge <[email protected]>
Signed-off-by: Rao Shoaib <[email protected]>
Signed-off-by: Somasundaram Krishnasamy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Rao Shoaib authored and davem330 committed Jun 25, 2020
1 parent 6aeaf26 commit 4c342f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion include/uapi/linux/rds.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@

/* supported values for SO_RDS_TRANSPORT */
#define RDS_TRANS_IB 0
#define RDS_TRANS_IWARP 1
#define RDS_TRANS_GAP 1
#define RDS_TRANS_TCP 2
#define RDS_TRANS_COUNT 3
#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 */
#define SIOCRDSSETTOS (SIOCPROTOPRIVATE)
Expand Down
26 changes: 17 additions & 9 deletions net/rds/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
#include "rds.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 DECLARE_RWSEM(rds_trans_sem);

Expand Down Expand Up @@ -110,18 +116,20 @@ struct rds_transport *rds_trans_get(int t_type)
{
struct rds_transport *ret = NULL;
struct rds_transport *trans;
unsigned int i;

down_read(&rds_trans_sem);
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];

if (trans && trans->t_type == t_type &&
(!trans->t_owner || try_module_get(trans->t_owner))) {
ret = trans;
break;
}
trans = transports[t_type];
if (!trans) {
up_read(&rds_trans_sem);
if (rds_trans_modules[t_type])
request_module(rds_trans_modules[t_type]);
down_read(&rds_trans_sem);
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);

return ret;
Expand Down

0 comments on commit 4c342f7

Please sign in to comment.