diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-17 16:01:09 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-17 16:01:09 -0400 |
commit | 8d9266ffe4332afc5ac9de401ef6f825b3798585 (patch) | |
tree | d0fbf4678a4751c3780bb8b805049cbc9afc7ec7 /net | |
parent | 43cedbf0e8dfb9c5610eb7985d5f21263e313802 (diff) |
SUNRPC: Initalise the struct xprt upon allocation
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/xprt.c | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index ccd583a46ff6..efb8dc5ab81b 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -1091,38 +1091,9 @@ void xprt_release(struct rpc_task *task) | |||
1091 | xprt_free_bc_request(req); | 1091 | xprt_free_bc_request(req); |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | /** | 1094 | static void xprt_init(struct rpc_xprt *xprt) |
1095 | * xprt_create_transport - create an RPC transport | ||
1096 | * @args: rpc transport creation arguments | ||
1097 | * | ||
1098 | */ | ||
1099 | struct rpc_xprt *xprt_create_transport(struct xprt_create *args) | ||
1100 | { | 1095 | { |
1101 | struct rpc_xprt *xprt; | ||
1102 | struct rpc_rqst *req; | 1096 | struct rpc_rqst *req; |
1103 | struct xprt_class *t; | ||
1104 | |||
1105 | spin_lock(&xprt_list_lock); | ||
1106 | list_for_each_entry(t, &xprt_list, list) { | ||
1107 | if (t->ident == args->ident) { | ||
1108 | spin_unlock(&xprt_list_lock); | ||
1109 | goto found; | ||
1110 | } | ||
1111 | } | ||
1112 | spin_unlock(&xprt_list_lock); | ||
1113 | printk(KERN_ERR "RPC: transport (%d) not supported\n", args->ident); | ||
1114 | return ERR_PTR(-EIO); | ||
1115 | |||
1116 | found: | ||
1117 | xprt = t->setup(args); | ||
1118 | if (IS_ERR(xprt)) { | ||
1119 | dprintk("RPC: xprt_create_transport: failed, %ld\n", | ||
1120 | -PTR_ERR(xprt)); | ||
1121 | return xprt; | ||
1122 | } | ||
1123 | if (test_and_set_bit(XPRT_INITIALIZED, &xprt->state)) | ||
1124 | /* ->setup returned a pre-initialized xprt: */ | ||
1125 | return xprt; | ||
1126 | 1097 | ||
1127 | spin_lock_init(&xprt->transport_lock); | 1098 | spin_lock_init(&xprt->transport_lock); |
1128 | spin_lock_init(&xprt->reserve_lock); | 1099 | spin_lock_init(&xprt->reserve_lock); |
@@ -1156,6 +1127,42 @@ found: | |||
1156 | 1127 | ||
1157 | xprt_init_xid(xprt); | 1128 | xprt_init_xid(xprt); |
1158 | 1129 | ||
1130 | } | ||
1131 | |||
1132 | /** | ||
1133 | * xprt_create_transport - create an RPC transport | ||
1134 | * @args: rpc transport creation arguments | ||
1135 | * | ||
1136 | */ | ||
1137 | struct rpc_xprt *xprt_create_transport(struct xprt_create *args) | ||
1138 | { | ||
1139 | struct rpc_xprt *xprt; | ||
1140 | struct xprt_class *t; | ||
1141 | |||
1142 | spin_lock(&xprt_list_lock); | ||
1143 | list_for_each_entry(t, &xprt_list, list) { | ||
1144 | if (t->ident == args->ident) { | ||
1145 | spin_unlock(&xprt_list_lock); | ||
1146 | goto found; | ||
1147 | } | ||
1148 | } | ||
1149 | spin_unlock(&xprt_list_lock); | ||
1150 | printk(KERN_ERR "RPC: transport (%d) not supported\n", args->ident); | ||
1151 | return ERR_PTR(-EIO); | ||
1152 | |||
1153 | found: | ||
1154 | xprt = t->setup(args); | ||
1155 | if (IS_ERR(xprt)) { | ||
1156 | dprintk("RPC: xprt_create_transport: failed, %ld\n", | ||
1157 | -PTR_ERR(xprt)); | ||
1158 | return xprt; | ||
1159 | } | ||
1160 | if (test_and_set_bit(XPRT_INITIALIZED, &xprt->state)) | ||
1161 | /* ->setup returned a pre-initialized xprt: */ | ||
1162 | return xprt; | ||
1163 | |||
1164 | xprt_init(xprt); | ||
1165 | |||
1159 | dprintk("RPC: created transport %p with %u slots\n", xprt, | 1166 | dprintk("RPC: created transport %p with %u slots\n", xprt, |
1160 | xprt->max_reqs); | 1167 | xprt->max_reqs); |
1161 | return xprt; | 1168 | return xprt; |